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