mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
continuing to improve quiz markdown experience
This commit is contained in:
@@ -8,7 +8,6 @@ public class QuizMarkdownTests
|
||||
{
|
||||
var quiz = new LocalQuiz()
|
||||
{
|
||||
Id = "string",
|
||||
Name = "Test Quiz",
|
||||
Description = @"
|
||||
# quiz description
|
||||
@@ -29,7 +28,6 @@ this is my description in markdown
|
||||
|
||||
var markdown = quiz.ToMarkdown();
|
||||
|
||||
markdown.Should().Contain("Id: string");
|
||||
markdown.Should().Contain("Name: Test Quiz");
|
||||
markdown.Should().Contain(quiz.Description);
|
||||
markdown.Should().Contain("LockAtDueDate: true");
|
||||
@@ -43,7 +41,6 @@ this is my description in markdown
|
||||
{
|
||||
var quiz = new LocalQuiz()
|
||||
{
|
||||
Id = "string",
|
||||
Name = "Test Quiz",
|
||||
Description = "desc",
|
||||
LockAtDueDate = true,
|
||||
@@ -100,7 +97,6 @@ b) false
|
||||
{
|
||||
var quiz = new LocalQuiz()
|
||||
{
|
||||
Id = "string",
|
||||
Name = "Test Quiz",
|
||||
Description = "desc",
|
||||
LockAtDueDate = true,
|
||||
@@ -112,7 +108,7 @@ b) false
|
||||
AllowedAttempts = -1,
|
||||
Questions = new LocalQuizQuestion[]
|
||||
{
|
||||
new LocalQuizQuestion()
|
||||
new()
|
||||
{
|
||||
Id = "somesdid",
|
||||
Text = "oneline question",
|
||||
@@ -120,9 +116,9 @@ b) false
|
||||
QuestionType = QuestionType.MULTIPLE_ANSWERS,
|
||||
Answers = new LocalQuizQuestionAnswer[]
|
||||
{
|
||||
new LocalQuizQuestionAnswer() { Correct = true, Text = "true" },
|
||||
new LocalQuizQuestionAnswer() { Correct = true, Text = "false"},
|
||||
new LocalQuizQuestionAnswer() { Correct = false, Text = "neither"},
|
||||
new() { Correct = true, Text = "true" },
|
||||
new() { Correct = true, Text = "false"},
|
||||
new() { Correct = false, Text = "neither"},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DroppableQuiz : ComponentBase
|
||||
if (planner.LocalCourse == null)
|
||||
return;
|
||||
var currentModule =
|
||||
planner.LocalCourse.Modules.First(m => m.Quizzes.Select(q => q.Id).Contains(Quiz.Id))
|
||||
planner.LocalCourse.Modules.First(m => m.Quizzes.Select(q => q.Name + q.Description).Contains(Quiz.Name + Quiz.Description))
|
||||
?? throw new Exception("in quiz callback, could not find module");
|
||||
|
||||
var defaultDueTimeDate = new DateTime(
|
||||
@@ -41,7 +41,7 @@ public class DroppableQuiz : ComponentBase
|
||||
);
|
||||
|
||||
var NewQuizList = currentModule.Quizzes
|
||||
.Select(q => q.Id != Quiz.Id ? q : q with { DueAt = defaultDueTimeDate })
|
||||
.Select(q => q.Name + q.Description != Quiz.Name + Quiz.Description ? q : q with { DueAt = defaultDueTimeDate })
|
||||
.ToArray();
|
||||
|
||||
var updatedModule = currentModule with { Quizzes = NewQuizList };
|
||||
@@ -62,11 +62,11 @@ public class DroppableQuiz : ComponentBase
|
||||
m.Name != dropModule.Name
|
||||
? m with
|
||||
{
|
||||
Quizzes = m.Quizzes.Where(q => q.Id != Quiz.Id).DistinctBy(q => q.Id)
|
||||
Quizzes = m.Quizzes.Where(q => q.Name + q.Description != Quiz.Name + Quiz.Description).DistinctBy(q => q.Name + q.Description)
|
||||
}
|
||||
: m with
|
||||
{
|
||||
Quizzes = m.Quizzes.Append(Quiz).DistinctBy(q => q.Id)
|
||||
Quizzes = m.Quizzes.Append(Quiz).DistinctBy(q => q.Name + q.Description)
|
||||
}
|
||||
)
|
||||
.ToArray();
|
||||
|
||||
@@ -6,15 +6,18 @@
|
||||
|
||||
}
|
||||
|
||||
<div class="row justify-content-between">
|
||||
<div class="row justify-content-between text-secondary">
|
||||
<div class="col">
|
||||
@((MarkupString)Question.HtmlText)
|
||||
points: @Question.Points
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
@Question.QuestionType
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@((MarkupString)Question.HtmlText)
|
||||
|
||||
@foreach(var answer in Question.Answers)
|
||||
{
|
||||
string answerPreview = answer.HtmlText.StartsWith("<p>")
|
||||
|
||||
@@ -24,13 +24,35 @@
|
||||
|
||||
@if(Quiz != null)
|
||||
{
|
||||
<div>Name: @Quiz.Name</div>
|
||||
<div>Due At: @Quiz.DueAt</div>
|
||||
<div>Lock At: @Quiz.LockAt</div>
|
||||
<div>Shuffle Answers: @Quiz.ShuffleAnswers</div>
|
||||
<div>Allowed Attempts: @Quiz.AllowedAttempts</div>
|
||||
<div>One question at a time: @Quiz.OneQuestionAtATime</div>
|
||||
<div>Assignment Group: @Quiz.LocalAssignmentGroupName</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">Name: </div>
|
||||
<div class="col-6">@Quiz.Name</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">Due At: </div>
|
||||
<div class="col-6">@Quiz.DueAt</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">Lock At: </div>
|
||||
<div class="col-6">@Quiz.LockAt</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">Shuffle Answers: </div>
|
||||
<div class="col-6">@Quiz.ShuffleAnswers</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">Allowed Attempts: </div>
|
||||
<div class="col-6">@Quiz.AllowedAttempts</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">One question at a time: </div>
|
||||
<div class="col-6">@Quiz.OneQuestionAtATime</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 text-end">Assignment Group: </div>
|
||||
<div class="col-6">@Quiz.LocalAssignmentGroupName</div>
|
||||
</div>
|
||||
|
||||
<div class="p-3">@Quiz.Description</div>
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
Console.WriteLine("new quiz");
|
||||
var newQuiz = new LocalQuiz
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
Name=Name,
|
||||
Description = "",
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ public class QuizEditorContext
|
||||
? currentModule with
|
||||
{
|
||||
Quizzes = currentModule.Quizzes
|
||||
.Select(q => q.Id == newQuiz.Id ? newQuiz : q)
|
||||
.Select(q => q.Name + q.Description == newQuiz.Name + newQuiz.Description ? newQuiz : q)
|
||||
.ToArray()
|
||||
}
|
||||
: m
|
||||
@@ -127,7 +127,7 @@ public class QuizEditorContext
|
||||
|
||||
private static LocalModule getCurrentModule(LocalQuiz newQuiz, LocalCourse course)
|
||||
{
|
||||
return course.Modules.First(m => m.Quizzes.Select(q => q.Id).Contains(newQuiz.Id))
|
||||
return course.Modules.First(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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace LocalModels;
|
||||
|
||||
public record LocalQuiz
|
||||
{
|
||||
public required string Id { get; init; }
|
||||
// public required string Id { get; init; }
|
||||
// public ulong? CanvasId { get; init; } = null;
|
||||
public required string Name { get; init; }
|
||||
public required string Description { get; init; }
|
||||
@@ -43,7 +43,6 @@ public record LocalQuiz
|
||||
var questionMarkdown = string.Join(questionDelimiter, questionMarkdownArray);
|
||||
|
||||
return $@"Name: {Name}
|
||||
Id: {Id}
|
||||
LockAtDueDate: {LockAtDueDate.ToString().ToLower()}
|
||||
LockAt: {LockAt}
|
||||
DueAt: {DueAt}
|
||||
@@ -88,7 +87,6 @@ Description: {Description}
|
||||
|
||||
return new LocalQuiz()
|
||||
{
|
||||
Id = "id-" + name,
|
||||
Name = name,
|
||||
Description = description,
|
||||
LockAtDueDate = lockAtDueDate,
|
||||
|
||||
Reference in New Issue
Block a user