From a19f5d1f23f74fc0d7e81c73ffd42cead39a9c96 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Thu, 3 Nov 2022 17:37:48 +0100 Subject: [PATCH] update courseware block for changes in #125 --- controllers/api.php | 4 ++-- js/test-block.js | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/controllers/api.php b/controllers/api.php index 61f45b6..7ae985f 100644 --- a/controllers/api.php +++ b/controllers/api.php @@ -71,7 +71,7 @@ class ApiController extends StudipController 'end' => date('d.m.Y, H:i', strtotime($assignment->end)), 'active' => $assignment->active, 'block' => $assignment->block->name, - 'reset_allowed' => $assignment->isRunning() && $assignment->isResetAllowed(), + 'reset_allowed' => $assignment->isRunning($user_id) && $assignment->isResetAllowed(), 'points' => $assignment->test->getTotalPoints(), 'release_status' => $released, 'exercises' => [] @@ -143,7 +143,7 @@ class ApiController extends StudipController $reached_points = $solution->points; $show_solution = false; - if ($assignment->isRunning()) { + if ($assignment->isRunning($user_id)) { // if a solution has been submitted during a selftest if ($max_tries && $solution) { $tries_left = $max_tries - $solution->countTries(); diff --git a/js/test-block.js b/js/test-block.js index b882172..c416d66 100644 --- a/js/test-block.js +++ b/js/test-block.js @@ -91,12 +91,12 @@ const CoursewareTestBlock = { </template> </component> <studip-dialog - v-if="showResetDialog" + v-if="exerciseResetId" :title="$gettext('Bitte bestätigen Sie die Aktion')" :question="$gettext('Wollen Sie die Lösung dieser Aufgabe wirklich löschen?')" height="180" @confirm="resetSolution" - @close="showResetDialog = false" + @close="exerciseResetId = null" ></studip-dialog> </div>`, @@ -114,8 +114,7 @@ const CoursewareTestBlock = { errorMessage: null, exercises: [], exercise_pos: 0, - exerciseResetId: null, - showResetDialog: false + exerciseResetId: null } }, methods: { @@ -224,17 +223,20 @@ const CoursewareTestBlock = { }, resetDialogHandler(event) { this.exerciseResetId = event.currentTarget.form.getAttribute('exercise'); - this.showResetDialog = true; }, resetSolution() { $.ajax({ type: 'DELETE', url: vips_url('api/solution/' + this.assignment.id + '/' + this.exerciseResetId, { block_id: this.block.id }) }) + .fail(xhr => { + let info = xhr.responseJSON ? xhr.responseJSON.message : xhr.statusText; + this.$store.dispatch('companionError', { info: info }); + this.exerciseResetId = null; + }) .done(() => { this.reloadExercise(this.exerciseResetId); this.exerciseResetId = null; - this.showResetDialog = false; }); } }, -- GitLab