mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
removing lock date same as due date option
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 : "";
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user