Skip to content

Commit

Permalink
Fixing small bugs
Browse files Browse the repository at this point in the history
- when editing a quiz, the last comment gets lost
- deleting a quiz doesn't update the list (but does delete it)
- uploading a new version doesn't work
  • Loading branch information
ineiti committed May 30, 2024
1 parent fbbd9be commit 58ab3ff
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ This software is licensed under AGPL-3.0 or later, at your convenience.
- bugs:
- ui
- on mobile devices, long answers are hidden partially
- stats: unuseful numbering (1.4, 2.8) for small values
- stats
- when all values are 0, it doesn't show nicely
- features
Expand All @@ -182,6 +183,11 @@ This software is licensed under AGPL-3.0 or later, at your convenience.

# CHANGELOG

2024-05-30:
- when editing a quiz, the last comment gets lost
- deleting a quiz doesn't update the list (but does delete it)
- uploading a new version doesn't work

2024-05-28:
- recover user with a `/recover#secret` path
- corrections bug:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class CourseManageComponent {
}
this.stats.add(StatsService.quiz_delete);
await this.updateDojo();
await this.updateQuizzes();
}
}

Expand All @@ -106,6 +107,7 @@ export class CourseManageComponent {
const quiz = await this.livequiz.getQuiz(this.updateQuizId!);
quiz.json = q.toJson();
quiz.update();
quiz.json = "";
this.stats.add(StatsService.quiz_update);
} else {
q.owners.push(this.user.id);
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/lib/structs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ extro
expect(q.questions[1].options.regexp).not.toBe(undefined);
});

it('doesn\'t lose last comment', () => {
const q = Quiz.fromStr(quiz1);
const qText = q.toText();
expect(qText.trim()).toBe(quiz1);
})

it('calculates the scores', () => {
const q = Quiz.fromStr(readFileSync(`${__dirname}/../selenium/quiz2.md`).toString());
const attempts: DojoAttempt[] = JSON.parse(readFileSync(`${__dirname}/../selenium/quiz2.answers.json`).toString())
Expand All @@ -128,4 +134,15 @@ describe("(de)serialization", () => {
s.update();
expect(s.toJson()).toBe(json_s);
})
});
});

const quiz1 = `# Test
## Multi
Question
= 1
- one
- three
some more comments`;
6 changes: 4 additions & 2 deletions frontend/src/lib/structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Quiz extends Nomad {
continue;
}
const linePre = line.replace(/`(.*?)`/g, "<span class='pre'>$1</span>");
const interpret = linePre.match(/([#=~;-]*) *(.*)/);
const interpret = linePre.match(/^([#=~;-]*) *(.*) *$/);
if (interpret?.length != 3) {
console.error(`Cannot parse line ${line}`);
continue;
Expand All @@ -103,6 +103,8 @@ export class Quiz extends Nomad {
if (maxChoices < 0) {
current.options.regexp = new OptionRegexp(reg);
}
current.intro = current.intro.trim();
current.explanation = current.explanation.trim();
q.questions.push(current);
}
current = new Question();
Expand Down Expand Up @@ -164,7 +166,7 @@ export class Question {
}

toText(): string {
return `## ${this.title}\n\n${this.intro}\n\n` + this.options.toText();
return `## ${this.title}\n\n${this.intro}\n\n` + this.options.toText() + `\n\n${this.explanation}`;
}

toJson(): JSONQuestion {
Expand Down

0 comments on commit 58ab3ff

Please sign in to comment.