mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
removing lock date same as due date option
This commit is contained in:
@@ -16,7 +16,6 @@ this is my description in markdown
|
|||||||
|
|
||||||
`here is code`
|
`here is code`
|
||||||
",
|
",
|
||||||
LockAtDueDate = true,
|
|
||||||
LockAt = DateTime.MaxValue,
|
LockAt = DateTime.MaxValue,
|
||||||
DueAt = DateTime.MaxValue,
|
DueAt = DateTime.MaxValue,
|
||||||
ShuffleAnswers = true,
|
ShuffleAnswers = true,
|
||||||
@@ -30,7 +29,6 @@ this is my description in markdown
|
|||||||
|
|
||||||
markdown.Should().Contain("Name: Test Quiz");
|
markdown.Should().Contain("Name: Test Quiz");
|
||||||
markdown.Should().Contain(quiz.Description);
|
markdown.Should().Contain(quiz.Description);
|
||||||
markdown.Should().Contain("LockAtDueDate: true");
|
|
||||||
markdown.Should().Contain("ShuffleAnswers: true");
|
markdown.Should().Contain("ShuffleAnswers: true");
|
||||||
markdown.Should().Contain("OneQuestionAtATime: false");
|
markdown.Should().Contain("OneQuestionAtATime: false");
|
||||||
markdown.Should().Contain("AssignmentGroup: someId");
|
markdown.Should().Contain("AssignmentGroup: someId");
|
||||||
@@ -43,7 +41,6 @@ this is my description in markdown
|
|||||||
{
|
{
|
||||||
Name = "Test Quiz",
|
Name = "Test Quiz",
|
||||||
Description = "desc",
|
Description = "desc",
|
||||||
LockAtDueDate = true,
|
|
||||||
LockAt = DateTime.MaxValue,
|
LockAt = DateTime.MaxValue,
|
||||||
DueAt = DateTime.MaxValue,
|
DueAt = DateTime.MaxValue,
|
||||||
ShuffleAnswers = true,
|
ShuffleAnswers = true,
|
||||||
@@ -88,10 +85,11 @@ lines
|
|||||||
*a) true
|
*a) true
|
||||||
b) false
|
b) false
|
||||||
|
|
||||||
endline
|
endline
|
||||||
";
|
";
|
||||||
markdown.Should().Contain(expectedQuestionString);
|
markdown.Should().Contain(expectedQuestionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void QuzMarkdownIncludesMultipleAnswerQuestion()
|
public void QuzMarkdownIncludesMultipleAnswerQuestion()
|
||||||
{
|
{
|
||||||
@@ -99,7 +97,6 @@ b) false
|
|||||||
{
|
{
|
||||||
Name = "Test Quiz",
|
Name = "Test Quiz",
|
||||||
Description = "desc",
|
Description = "desc",
|
||||||
LockAtDueDate = true,
|
|
||||||
LockAt = DateTime.MaxValue,
|
LockAt = DateTime.MaxValue,
|
||||||
DueAt = DateTime.MaxValue,
|
DueAt = DateTime.MaxValue,
|
||||||
ShuffleAnswers = true,
|
ShuffleAnswers = true,
|
||||||
@@ -139,7 +136,6 @@ oneline question
|
|||||||
{
|
{
|
||||||
var rawMarkdownQuiz = @"
|
var rawMarkdownQuiz = @"
|
||||||
Name: Test Quiz
|
Name: Test Quiz
|
||||||
LockAtDueDate: true
|
|
||||||
ShuffleAnswers: true
|
ShuffleAnswers: true
|
||||||
OneQuestionAtATime: false
|
OneQuestionAtATime: false
|
||||||
DueAt: 2023-08-21T23:59:00
|
DueAt: 2023-08-21T23:59:00
|
||||||
@@ -154,7 +150,6 @@ description
|
|||||||
var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
|
var quiz = LocalQuiz.ParseMarkdown(rawMarkdownQuiz);
|
||||||
|
|
||||||
quiz.Name.Should().Be("Test Quiz");
|
quiz.Name.Should().Be("Test Quiz");
|
||||||
quiz.LockAtDueDate.Should().Be(true);
|
|
||||||
quiz.ShuffleAnswers.Should().Be(true);
|
quiz.ShuffleAnswers.Should().Be(true);
|
||||||
quiz.OneQuestionAtATime.Should().BeFalse();
|
quiz.OneQuestionAtATime.Should().BeFalse();
|
||||||
quiz.AllowedAttempts.Should().Be(-1);
|
quiz.AllowedAttempts.Should().Be(-1);
|
||||||
@@ -168,7 +163,6 @@ description");
|
|||||||
{
|
{
|
||||||
var rawMarkdownQuiz = @"
|
var rawMarkdownQuiz = @"
|
||||||
Name: Test Quiz
|
Name: Test Quiz
|
||||||
LockAtDueDate: true
|
|
||||||
ShuffleAnswers: true
|
ShuffleAnswers: true
|
||||||
OneQuestionAtATime: false
|
OneQuestionAtATime: false
|
||||||
DueAt: 2023-08-21T23:59:00
|
DueAt: 2023-08-21T23:59:00
|
||||||
@@ -210,7 +204,6 @@ b) false
|
|||||||
{
|
{
|
||||||
var rawMarkdownQuiz = @"
|
var rawMarkdownQuiz = @"
|
||||||
Name: Test Quiz
|
Name: Test Quiz
|
||||||
LockAtDueDate: true
|
|
||||||
ShuffleAnswers: true
|
ShuffleAnswers: true
|
||||||
OneQuestionAtATime: false
|
OneQuestionAtATime: false
|
||||||
DueAt: 2023-08-21T23:59:00
|
DueAt: 2023-08-21T23:59:00
|
||||||
@@ -247,7 +240,6 @@ Which events are triggered when the user clicks on an input field?
|
|||||||
{
|
{
|
||||||
var rawMarkdownQuiz = @"
|
var rawMarkdownQuiz = @"
|
||||||
Name: Test Quiz
|
Name: Test Quiz
|
||||||
LockAtDueDate: true
|
|
||||||
ShuffleAnswers: true
|
ShuffleAnswers: true
|
||||||
OneQuestionAtATime: false
|
OneQuestionAtATime: false
|
||||||
DueAt: 2023-08-21T23:59:00
|
DueAt: 2023-08-21T23:59:00
|
||||||
@@ -280,7 +272,6 @@ b) false
|
|||||||
{
|
{
|
||||||
var rawMarkdownQuiz = @"
|
var rawMarkdownQuiz = @"
|
||||||
Name: Test Quiz
|
Name: Test Quiz
|
||||||
LockAtDueDate: true
|
|
||||||
ShuffleAnswers: true
|
ShuffleAnswers: true
|
||||||
OneQuestionAtATime: false
|
OneQuestionAtATime: false
|
||||||
DueAt: 2023-08-21T23:59:00
|
DueAt: 2023-08-21T23:59:00
|
||||||
@@ -306,7 +297,6 @@ essay
|
|||||||
{
|
{
|
||||||
var rawMarkdownQuiz = @"
|
var rawMarkdownQuiz = @"
|
||||||
Name: Test Quiz
|
Name: Test Quiz
|
||||||
LockAtDueDate: true
|
|
||||||
ShuffleAnswers: true
|
ShuffleAnswers: true
|
||||||
OneQuestionAtATime: false
|
OneQuestionAtATime: false
|
||||||
DueAt: 2023-08-21T23:59:00
|
DueAt: 2023-08-21T23:59:00
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
catch(QuizMarkdownParseException e)
|
catch(QuizMarkdownParseException e)
|
||||||
{
|
{
|
||||||
error = e.Message;
|
error = e.Message;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
{
|
{
|
||||||
if (quizContext.Quiz != null)
|
if (quizContext.Quiz != null)
|
||||||
{
|
{
|
||||||
if (!lockAtDueDate)
|
|
||||||
lockAtDueDate = quizContext.Quiz.LockAtDueDate;
|
|
||||||
if (lockAt == null)
|
if (lockAt == null)
|
||||||
lockAt = quizContext.Quiz.LockAt;
|
lockAt = quizContext.Quiz.LockAt;
|
||||||
if (!shuffleAnswers)
|
if (!shuffleAnswers)
|
||||||
@@ -32,32 +30,11 @@
|
|||||||
quizContext.StateHasChanged -= reload;
|
quizContext.StateHasChanged -= reload;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool lockAtDueDate { get; set; }
|
|
||||||
private DateTime? lockAt { get; set; }
|
private DateTime? lockAt { get; set; }
|
||||||
private bool shuffleAnswers { get; set; }
|
private bool shuffleAnswers { get; set; }
|
||||||
private bool oneQuestionAtATime { get; set; }
|
private bool oneQuestionAtATime { get; set; }
|
||||||
private int allowedAttempts { 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)
|
private void setAssignmentGroup(LocalAssignmentGroup? group)
|
||||||
{
|
{
|
||||||
if(quizContext.Quiz == null)
|
if(quizContext.Quiz == null)
|
||||||
@@ -81,19 +58,6 @@
|
|||||||
@if(planner.LocalCourse != null )
|
@if(planner.LocalCourse != null )
|
||||||
{
|
{
|
||||||
<div>
|
<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
|
<ButtonSelect
|
||||||
Label="Assignment Group"
|
Label="Assignment Group"
|
||||||
Options="planner.LocalCourse.Settings.AssignmentGroups"
|
Options="planner.LocalCourse.Settings.AssignmentGroups"
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<MarkdownQuizForm />
|
<MarkdownQuizForm />
|
||||||
|
|
||||||
@* <QuizForm /> *@
|
@* <QuizForm /> *@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -63,7 +63,12 @@ public class QuizEditorContext
|
|||||||
var currentModule = getCurrentModule(Quiz, planner.LocalCourse);
|
var currentModule = getCurrentModule(Quiz, planner.LocalCourse);
|
||||||
|
|
||||||
var updatedModules = planner.LocalCourse.Modules
|
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();
|
.ToArray();
|
||||||
|
|
||||||
planner.LocalCourse = planner.LocalCourse with { Modules = updatedModules };
|
planner.LocalCourse = planner.LocalCourse with { Modules = updatedModules };
|
||||||
@@ -127,7 +132,7 @@ public class QuizEditorContext
|
|||||||
|
|
||||||
private static LocalModule getCurrentModule(LocalQuiz newQuiz, LocalCourse course)
|
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");
|
?? throw new Exception("could not find current module in quiz editor context");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ public record LocalQuiz
|
|||||||
// public ulong? CanvasId { get; init; } = null;
|
// public ulong? CanvasId { get; init; } = null;
|
||||||
public required string Name { get; init; }
|
public required string Name { get; init; }
|
||||||
public required string Description { get; init; }
|
public required string Description { get; init; }
|
||||||
public bool LockAtDueDate { get; init; } = true;
|
|
||||||
public DateTime? LockAt { get; init; }
|
public DateTime? LockAt { get; init; }
|
||||||
public DateTime DueAt { get; init; }
|
public DateTime DueAt { get; init; }
|
||||||
public bool ShuffleAnswers { get; init; } = true;
|
public bool ShuffleAnswers { get; init; } = true;
|
||||||
@@ -43,7 +42,6 @@ public record LocalQuiz
|
|||||||
var questionMarkdown = string.Join(questionDelimiter, questionMarkdownArray);
|
var questionMarkdown = string.Join(questionDelimiter, questionMarkdownArray);
|
||||||
|
|
||||||
return $@"Name: {Name}
|
return $@"Name: {Name}
|
||||||
LockAtDueDate: {LockAtDueDate.ToString().ToLower()}
|
|
||||||
LockAt: {LockAt}
|
LockAt: {LockAt}
|
||||||
DueAt: {DueAt}
|
DueAt: {DueAt}
|
||||||
ShuffleAnswers: {ShuffleAnswers.ToString().ToLower()}
|
ShuffleAnswers: {ShuffleAnswers.ToString().ToLower()}
|
||||||
@@ -75,13 +73,21 @@ Description: {Description}
|
|||||||
|
|
||||||
private static LocalQuiz getQuizWithOnlySettings(string settings)
|
private static LocalQuiz getQuizWithOnlySettings(string settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
var name = extractLabelValue(settings, "Name");
|
var name = extractLabelValue(settings, "Name");
|
||||||
var lockAtDueDate = bool.Parse(extractLabelValue(settings, "LockAtDueDate"));
|
|
||||||
var shuffleAnswers = bool.Parse(extractLabelValue(settings, "ShuffleAnswers"));
|
var shuffleAnswers = bool.Parse(extractLabelValue(settings, "ShuffleAnswers"));
|
||||||
var oneQuestionAtATime = bool.Parse(extractLabelValue(settings, "OneQuestionAtATime"));
|
var oneQuestionAtATime = bool.Parse(extractLabelValue(settings, "OneQuestionAtATime"));
|
||||||
var allowedAttempts = int.Parse(extractLabelValue(settings, "AllowedAttempts"));
|
var allowedAttempts = int.Parse(extractLabelValue(settings, "AllowedAttempts"));
|
||||||
var dueAt = DateTime.Parse(extractLabelValue(settings, "DueAt"));
|
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 description = extractDescription(settings);
|
||||||
var assignmentGroup = extractLabelValue(settings, "AssignmentGroup");
|
var assignmentGroup = extractLabelValue(settings, "AssignmentGroup");
|
||||||
|
|
||||||
@@ -89,7 +95,6 @@ Description: {Description}
|
|||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
Description = description,
|
Description = description,
|
||||||
LockAtDueDate = lockAtDueDate,
|
|
||||||
LockAt = lockAt,
|
LockAt = lockAt,
|
||||||
DueAt = dueAt,
|
DueAt = dueAt,
|
||||||
ShuffleAnswers = shuffleAnswers,
|
ShuffleAnswers = shuffleAnswers,
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ public record LocalQuizQuestion
|
|||||||
? $"{correctIndicator}{questionLetter}) "
|
? $"{correctIndicator}{questionLetter}) "
|
||||||
: $"[{correctIndicator}] ";
|
: $"[{correctIndicator}] ";
|
||||||
|
|
||||||
var textWithSpecificNewline = answer.Text.Replace(Environment.NewLine, Environment.NewLine + " ");
|
// var textWithSpecificNewline = answer.Text.Replace(Environment.NewLine, Environment.NewLine + " ");
|
||||||
return $"{questionTypeIndicator}{textWithSpecificNewline}";
|
return $"{questionTypeIndicator}{answer.Text}";
|
||||||
});
|
});
|
||||||
var answersText = string.Join(Environment.NewLine, answerArray);
|
var answersText = string.Join(Environment.NewLine, answerArray);
|
||||||
var questionTypeIndicator = QuestionType == "essay" || QuestionType == "short_answer" ? QuestionType : "";
|
var questionTypeIndicator = QuestionType == "essay" || QuestionType == "short_answer" ? QuestionType : "";
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class CanvasQuizService
|
|||||||
one_question_at_a_time = false,
|
one_question_at_a_time = false,
|
||||||
cant_go_back = false,
|
cant_go_back = false,
|
||||||
due_at = localQuiz.DueAt,
|
due_at = localQuiz.DueAt,
|
||||||
lock_at = localQuiz.LockAtDueDate ? localQuiz.DueAt : localQuiz.LockAt,
|
lock_at = localQuiz.LockAt,
|
||||||
assignment_group_id = canvasAssignmentGroupId,
|
assignment_group_id = canvasAssignmentGroupId,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user