diff --git a/controllers/api.php b/controllers/api.php index 61f45b632692772c0d8f67ca7349cd92e45a41a5..7ae985fdeb22faea07db7f37f23a8b699830a305 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 b882172e75b467500958e8081c5e537a725d84f9..c416d66595cf77387ec56a5e62be29874fb81a82 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; }); } },