removing lock date same as due date option

This commit is contained in:
2023-10-13 12:24:02 -06:00
parent 1fb90756e1
commit e7daf5f77f
8 changed files with 25 additions and 59 deletions

View File

@@ -16,7 +16,6 @@ this is my description in markdown
`here is code`
",
LockAtDueDate = true,
LockAt = DateTime.MaxValue,
DueAt = DateTime.MaxValue,
ShuffleAnswers = true,
@@ -30,7 +29,6 @@ this is my description in markdown
markdown.Should().Contain("Name: Test Quiz");
markdown.Should().Contain(quiz.Description);
markdown.Should().Contain("LockAtDueDate: true");
markdown.Should().Contain("ShuffleAnswers: true");
markdown.Should().Contain("OneQuestionAtATime: false");
markdown.Should().Contain("AssignmentGroup: someId");
@@ -43,7 +41,6 @@ this is my description in markdown
{
Name = "Test Quiz",
Description = "desc",
LockAtDueDate = true,
LockAt = DateTime.MaxValue,
DueAt = DateTime.MaxValue,
ShuffleAnswers = true,
@@ -88,10 +85,11 @@ lines
*a) true
b) false
endline
endline
";
markdown.Should().Contain(expectedQuestionString);
}
[Test]
public void QuzMarkdownIncludesMultipleAnswerQuestion()
{
@@ -99,7 +97,6 @@ b) false
{
Name = "Test Quiz",
Description = "desc",
LockAtDueDate = true,
LockAt = DateTime.MaxValue,
DueAt = DateTime.MaxValue,
ShuffleAnswers = true,
@@ -139,7 +136,6 @@ oneline question
{
var rawMarkdownQuiz = @"
Name: Test Quiz
LockAtDueDate: true
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
@@ -154,7 +150,6 @@ description
var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
quiz.Name.Should().Be("Test Quiz");
quiz.LockAtDueDate.Should().Be(true);
quiz.ShuffleAnswers.Should().Be(true);
quiz.OneQuestionAtATime.Should().BeFalse();
quiz.AllowedAttempts.Should().Be(-1);
@@ -168,7 +163,6 @@ description");
{
var rawMarkdownQuiz = @"
Name: Test Quiz
LockAtDueDate: true
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
@@ -210,7 +204,6 @@ b) false
{
var rawMarkdownQuiz = @"
Name: Test Quiz
LockAtDueDate: true
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
@@ -247,7 +240,6 @@ Which events are triggered when the user clicks on an input field?
{
var rawMarkdownQuiz = @"
Name: Test Quiz
LockAtDueDate: true
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
@@ -280,7 +272,6 @@ b) false
{
var rawMarkdownQuiz = @"
Name: Test Quiz
LockAtDueDate: true
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00
@@ -306,7 +297,6 @@ essay
{
var rawMarkdownQuiz = @"
Name: Test Quiz
LockAtDueDate: true
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 2023-08-21T23:59:00

View File

@@ -27,6 +27,7 @@
catch(QuizMarkdownParseException e)
{
error = e.Message;
StateHasChanged();
}
}
}

View File

@@ -13,8 +13,6 @@
{
if (quizContext.Quiz != null)
{
if (!lockAtDueDate)
lockAtDueDate = quizContext.Quiz.LockAtDueDate;
if (lockAt == null)
lockAt = quizContext.Quiz.LockAt;
if (!shuffleAnswers)
@@ -32,32 +30,11 @@
quizContext.StateHasChanged -= reload;
}
private bool lockAtDueDate { get; set; }
private DateTime? lockAt { get; set; }
private bool shuffleAnswers { get; set; }
private bool oneQuestionAtATime { get; set; }
private int allowedAttempts { get; set; }
private void handleLockAtDueDateChange()
{
if(quizContext.Quiz == null)
return;
var newValue = !quizContext.Quiz.LockAtDueDate;
var newQuiz = newValue
? quizContext.Quiz with
{
LockAtDueDate = newValue,
LockAt = quizContext.Quiz.DueAt
}
: quizContext.Quiz with
{
LockAtDueDate = newValue
};
quizContext.SaveQuiz(newQuiz);
}
private void setAssignmentGroup(LocalAssignmentGroup? group)
{
if(quizContext.Quiz == null)
@@ -81,19 +58,6 @@
@if(planner.LocalCourse != null )
{
<div>
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
id="lockAtDueDate"
checked="@lockAtDueDate"
@onchange="handleLockAtDueDateChange">
<label
class="form-check-label" for="lockAtDueDate">
Lock at Due Date
</label>
</div>
<ButtonSelect
Label="Assignment Group"
Options="planner.LocalCourse.Settings.AssignmentGroups"

View File

@@ -42,6 +42,7 @@
}
<MarkdownQuizForm />
@* <QuizForm /> *@
<div class="row">

View File

@@ -63,7 +63,12 @@ public class QuizEditorContext
var currentModule = getCurrentModule(Quiz, planner.LocalCourse);
var updatedModules = planner.LocalCourse.Modules
.Where(m => m.Name != currentModule.Name)
.Select(m => m.Name != currentModule.Name
? m
: m with {
Quizzes = m.Quizzes.Where(q => q.Name + q.Description != Quiz.Name + Quiz.Description).ToArray()
}
)
.ToArray();
planner.LocalCourse = planner.LocalCourse with { Modules = updatedModules };
@@ -127,7 +132,7 @@ public class QuizEditorContext
private static LocalModule getCurrentModule(LocalQuiz newQuiz, LocalCourse course)
{
return course.Modules.First(m => m.Quizzes.Select(q => q.Name + q.Description).Contains(newQuiz.Name + newQuiz.Description))
return course.Modules.FirstOrDefault(m => m.Quizzes.Select(q => q.Name + q.Description).Contains(newQuiz.Name + newQuiz.Description))
?? throw new Exception("could not find current module in quiz editor context");
}
}

View File

@@ -9,7 +9,6 @@ public record LocalQuiz
// public ulong? CanvasId { get; init; } = null;
public required string Name { get; init; }
public required string Description { get; init; }
public bool LockAtDueDate { get; init; } = true;
public DateTime? LockAt { get; init; }
public DateTime DueAt { get; init; }
public bool ShuffleAnswers { get; init; } = true;
@@ -43,7 +42,6 @@ public record LocalQuiz
var questionMarkdown = string.Join(questionDelimiter, questionMarkdownArray);
return $@"Name: {Name}
LockAtDueDate: {LockAtDueDate.ToString().ToLower()}
LockAt: {LockAt}
DueAt: {DueAt}
ShuffleAnswers: {ShuffleAnswers.ToString().ToLower()}
@@ -75,13 +73,21 @@ Description: {Description}
private static LocalQuiz getQuizWithOnlySettings(string settings)
{
var name = extractLabelValue(settings, "Name");
var lockAtDueDate = bool.Parse(extractLabelValue(settings, "LockAtDueDate"));
var shuffleAnswers = bool.Parse(extractLabelValue(settings, "ShuffleAnswers"));
var oneQuestionAtATime = bool.Parse(extractLabelValue(settings, "OneQuestionAtATime"));
var allowedAttempts = int.Parse(extractLabelValue(settings, "AllowedAttempts"));
var dueAt = DateTime.Parse(extractLabelValue(settings, "DueAt"));
var lockAt = DateTime.Parse(extractLabelValue(settings, "LockAt"));
var rawLockAt = extractLabelValue(settings, "LockAt");
DateTime? lockAt = DateTime.TryParse(rawLockAt, out DateTime parsedLockAt)
? parsedLockAt
: null;
var description = extractDescription(settings);
var assignmentGroup = extractLabelValue(settings, "AssignmentGroup");
@@ -89,7 +95,6 @@ Description: {Description}
{
Name = name,
Description = description,
LockAtDueDate = lockAtDueDate,
LockAt = lockAt,
DueAt = dueAt,
ShuffleAnswers = shuffleAnswers,

View File

@@ -26,8 +26,8 @@ public record LocalQuizQuestion
? $"{correctIndicator}{questionLetter}) "
: $"[{correctIndicator}] ";
var textWithSpecificNewline = answer.Text.Replace(Environment.NewLine, Environment.NewLine + " ");
return $"{questionTypeIndicator}{textWithSpecificNewline}";
// var textWithSpecificNewline = answer.Text.Replace(Environment.NewLine, Environment.NewLine + " ");
return $"{questionTypeIndicator}{answer.Text}";
});
var answersText = string.Join(Environment.NewLine, answerArray);
var questionTypeIndicator = QuestionType == "essay" || QuestionType == "short_answer" ? QuestionType : "";

View File

@@ -59,7 +59,7 @@ public class CanvasQuizService
one_question_at_a_time = false,
cant_go_back = false,
due_at = localQuiz.DueAt,
lock_at = localQuiz.LockAtDueDate ? localQuiz.DueAt : localQuiz.LockAt,
lock_at = localQuiz.LockAt,
assignment_group_id = canvasAssignmentGroupId,
}
};