Skip to content

Commit

Permalink
Merge branch 'staging' into main-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofferGamel committed Nov 29, 2024
2 parents 4ab8931 + 8bfe37b commit 161604d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function get_lecturer_questions_relation_by_id(int $id): array {

/**
*
* Deletes lecturer_questions_relation by the relation id
* Deletes lecturer_questions_relation by the question id
*
*
* @param int $id
Expand All @@ -96,8 +96,8 @@ public static function get_lecturer_questions_relation_by_id(int $id): array {
* @throws dml_transaction_exception
*
*/
public static function delete_lecturer_questions_relation_by_id(int $id): void {
public static function delete_lecturer_questions_relation_by_question_id(int $id): void {
global $DB;
$DB->delete_records('livequiz_questions_lecturer', ['id' => $id]);
$DB->delete_records('livequiz_questions_lecturer', ['question_id' => $id]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,10 @@ private static function delete_question(int $questionid): void {
$answers = questions_answers_relation::get_answers_from_question($questionid);
foreach ($answers as $answer) {
$currentanswerid = $answer->get_id();
self::delete_answer($currentanswerid, $questionid);
self::delete_answer($currentanswerid);
}
quiz_questions_relation::delete_question_quiz_relation($questionid);
livequiz_questions_lecturer_relation::delete_lecturer_questions_relation_by_id($questionid);
livequiz_questions_lecturer_relation::delete_lecturer_questions_relation_by_question_id($questionid);
question::delete_question($questionid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function test_delete_question(): void {
}

/**
* Test that deleting a question, with a relation, throws.
* Test that deleting a question, with a relation, throws an exception.
*
* @covers \mod_livequiz\services\livequiz_services::submit_quiz
* @throws dml_exception
Expand Down Expand Up @@ -500,9 +500,11 @@ public function test_delete_question_throws_if_relation_exist(): void {
array_shift($testquizsubmittedquestions);
$testquizsubmitted->set_questions($testquizsubmittedquestions);

// This sets up the test to expect the exception later in the code.
$this->expectException(dml_exception::class);
$this->expectExceptionMessage('error/Cannot delete answer with participations');

// This is the actual test where the exception is thrown.
$service->submit_quiz($testquizsubmitted, $lecturerid);
$testquizresubmittedquestions = $testquizsubmitted->get_questions();
}
Expand Down

0 comments on commit 161604d

Please sign in to comment.