Skip to content
Snippets Groups Projects
Commit 3cee8ada authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

update courseware block for changes in #125

parent 23c0f448
No related branches found
No related tags found
No related merge requests found
...@@ -71,7 +71,7 @@ class ApiController extends StudipController ...@@ -71,7 +71,7 @@ class ApiController extends StudipController
'end' => date('d.m.Y, H:i', strtotime($assignment->end)), 'end' => date('d.m.Y, H:i', strtotime($assignment->end)),
'active' => $assignment->active, 'active' => $assignment->active,
'block' => $assignment->block->name, 'block' => $assignment->block->name,
'reset_allowed' => $assignment->isRunning() && $assignment->isResetAllowed(), 'reset_allowed' => $assignment->isRunning($user_id) && $assignment->isResetAllowed(),
'points' => $assignment->test->getTotalPoints(), 'points' => $assignment->test->getTotalPoints(),
'release_status' => $released, 'release_status' => $released,
'exercises' => [] 'exercises' => []
...@@ -143,7 +143,7 @@ class ApiController extends StudipController ...@@ -143,7 +143,7 @@ class ApiController extends StudipController
$reached_points = $solution->points; $reached_points = $solution->points;
$show_solution = false; $show_solution = false;
if ($assignment->isRunning()) { if ($assignment->isRunning($user_id)) {
// if a solution has been submitted during a selftest // if a solution has been submitted during a selftest
if ($max_tries && $solution) { if ($max_tries && $solution) {
$tries_left = $max_tries - $solution->countTries(); $tries_left = $max_tries - $solution->countTries();
......
...@@ -91,12 +91,12 @@ const CoursewareTestBlock = { ...@@ -91,12 +91,12 @@ const CoursewareTestBlock = {
</template> </template>
</component> </component>
<studip-dialog <studip-dialog
v-if="showResetDialog" v-if="exerciseResetId"
:title="$gettext('Bitte bestätigen Sie die Aktion')" :title="$gettext('Bitte bestätigen Sie die Aktion')"
:question="$gettext('Wollen Sie die Lösung dieser Aufgabe wirklich löschen?')" :question="$gettext('Wollen Sie die Lösung dieser Aufgabe wirklich löschen?')"
height="180" height="180"
@confirm="resetSolution" @confirm="resetSolution"
@close="showResetDialog = false" @close="exerciseResetId = null"
></studip-dialog> ></studip-dialog>
</div>`, </div>`,
...@@ -114,8 +114,7 @@ const CoursewareTestBlock = { ...@@ -114,8 +114,7 @@ const CoursewareTestBlock = {
errorMessage: null, errorMessage: null,
exercises: [], exercises: [],
exercise_pos: 0, exercise_pos: 0,
exerciseResetId: null, exerciseResetId: null
showResetDialog: false
} }
}, },
methods: { methods: {
...@@ -224,17 +223,20 @@ const CoursewareTestBlock = { ...@@ -224,17 +223,20 @@ const CoursewareTestBlock = {
}, },
resetDialogHandler(event) { resetDialogHandler(event) {
this.exerciseResetId = event.currentTarget.form.getAttribute('exercise'); this.exerciseResetId = event.currentTarget.form.getAttribute('exercise');
this.showResetDialog = true;
}, },
resetSolution() { resetSolution() {
$.ajax({ $.ajax({
type: 'DELETE', type: 'DELETE',
url: vips_url('api/solution/' + this.assignment.id + '/' + this.exerciseResetId, { block_id: this.block.id }) 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(() => { .done(() => {
this.reloadExercise(this.exerciseResetId); this.reloadExercise(this.exerciseResetId);
this.exerciseResetId = null; this.exerciseResetId = null;
this.showResetDialog = false;
}); });
} }
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment