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

Revert "switch assignment payload type to integer, fixes #265"

This reverts commit 4cbbbf74.
parent 2f1f86e6
Branches
No related tags found
No related merge requests found
...@@ -24,7 +24,8 @@ class ApiController extends StudipController ...@@ -24,7 +24,8 @@ class ApiController extends StudipController
foreach ($assignments as $assignment) { foreach ($assignments as $assignment) {
if ($assignment->type !== 'exam') { if ($assignment->type !== 'exam') {
$data[] = [ $data[] = [
'id' => (int) $assignment->id, 'id' => $assignment->id,
'link' => $this->url_for('api/assignment', $assignment->id),
'title' => $assignment->test->title, 'title' => $assignment->test->title,
'type' => $assignment->type, 'type' => $assignment->type,
'icon' => $assignment->getTypeIcon()->getShape(), 'icon' => $assignment->getTypeIcon()->getShape(),
...@@ -62,7 +63,7 @@ class ApiController extends StudipController ...@@ -62,7 +63,7 @@ class ApiController extends StudipController
} }
$data = [ $data = [
'id' => (int) $assignment->id, 'id' => $assignment->id,
'title' => $assignment->test->title, 'title' => $assignment->test->title,
'type' => $assignment->type, 'type' => $assignment->type,
'icon' => $assignment->getTypeIcon()->getShape(), 'icon' => $assignment->getTypeIcon()->getShape(),
...@@ -81,7 +82,8 @@ class ApiController extends StudipController ...@@ -81,7 +82,8 @@ class ApiController extends StudipController
$exercise = $exercise_ref->exercise; $exercise = $exercise_ref->exercise;
$data['exercises'][] = [ $data['exercises'][] = [
'id' => (int) $exercise->id, 'id' => $exercise->id,
'link' => $this->url_for('api/exercise', $assignment_id, $exercise->id),
'type' => $exercise->type, 'type' => $exercise->type,
'title' => $exercise->title, 'title' => $exercise->title,
'template' => $template->render(), 'template' => $template->render(),
...@@ -120,7 +122,7 @@ class ApiController extends StudipController ...@@ -120,7 +122,7 @@ class ApiController extends StudipController
$exercise = $exercise_ref->exercise; $exercise = $exercise_ref->exercise;
$data = [ $data = [
'id' => (int) $exercise->id, 'id' => $exercise->id,
'type' => $exercise->type, 'type' => $exercise->type,
'title' => $exercise->title, 'title' => $exercise->title,
'template' => $template->render(), 'template' => $template->render(),
...@@ -138,7 +140,6 @@ class ApiController extends StudipController ...@@ -138,7 +140,6 @@ class ApiController extends StudipController
$solution = $assignment->getSolution($user_id, $exercise->id); $solution = $assignment->getSolution($user_id, $exercise->id);
$max_tries = $assignment->getMaxTries(); $max_tries = $assignment->getMaxTries();
$max_points = $exercise_ref->points; $max_points = $exercise_ref->points;
$sample_solution = false;
$show_solution = false; $show_solution = false;
$tries_left = null; $tries_left = null;
......
...@@ -84,10 +84,8 @@ const CoursewareTestBlock = { ...@@ -84,10 +84,8 @@ const CoursewareTestBlock = {
</template> </template>
<template #selected-option="{title, icon, start, end}"> <template #selected-option="{title, icon, start, end}">
<studip-icon :shape="icon" role="info"/> <studip-icon :shape="icon" role="info"/>
<template v-if="title">
{{title}} ({{start}} - {{end}}) {{title}} ({{start}} - {{end}})
</template> </template>
</template>
<template #option="{title, icon, start, end, block}"> <template #option="{title, icon, start, end, block}">
<studip-icon :shape="icon" role="info"/> <studip-icon :shape="icon" role="info"/>
{{ block ? block + ' / ' + title : title }}<br> {{ block ? block + ' / ' + title : title }}<br>
...@@ -117,7 +115,7 @@ const CoursewareTestBlock = { ...@@ -117,7 +115,7 @@ const CoursewareTestBlock = {
data() { data() {
return { return {
assignments: [], assignments: [],
assignment_id: 0, assignment_id: '',
assignment: null, assignment: null,
errorMessage: null, errorMessage: null,
exercises: [], exercises: [],
...@@ -165,7 +163,7 @@ const CoursewareTestBlock = { ...@@ -165,7 +163,7 @@ const CoursewareTestBlock = {
}); });
}, },
loadSelectedAssignment() { loadSelectedAssignment() {
if (!this.assignment_id) { if (this.assignment_id === '') {
this.errorMessage = this.$gettext('Es wurde noch kein Aufgabenblatt ausgewählt.'); this.errorMessage = this.$gettext('Es wurde noch kein Aufgabenblatt ausgewählt.');
return; return;
} }
......
...@@ -64,7 +64,7 @@ class TestBlock extends BlockType ...@@ -64,7 +64,7 @@ class TestBlock extends BlockType
*/ */
public function initialPayload(): array public function initialPayload(): array
{ {
return ['assignment' => 0]; return ['assignment' => ''];
} }
/** /**
...@@ -76,7 +76,7 @@ class TestBlock extends BlockType ...@@ -76,7 +76,7 @@ class TestBlock extends BlockType
'type' => 'object', 'type' => 'object',
'properties' => [ 'properties' => [
'assignment' => [ 'assignment' => [
'type' => 'integer' 'type' => 'string'
] ]
] ]
]; ];
...@@ -108,17 +108,6 @@ class TestBlock extends BlockType ...@@ -108,17 +108,6 @@ class TestBlock extends BlockType
return []; return [];
} }
/**
* Returns the decoded payload of the block associated with this instance.
*/
public function getPayload()
{
$payload = parent::getPayload();
$payload['assignment'] = (int) $payload['assignment'];
return $payload;
}
/** /**
* Copy the payload of this block into the given range id. * Copy the payload of this block into the given range id.
*/ */
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<? else: ?> <? else: ?>
<?= $this->render_partial($exercise->getSolveTemplate($solution, $assignment, $user_id)) ?> <?= $this->render_partial($exercise->getSolveTemplate($solution, $assignment, $user_id)) ?>
<? if (!empty($exercise->options['comment'])): ?> <? if ($exercise->options['comment']): ?>
<label> <label>
<?= _vips('Bemerkungen zur Lösung (optional)') ?> <?= _vips('Bemerkungen zur Lösung (optional)') ?>
<textarea name="student_comment"><?= htmlReady($solution->student_comment) ?></textarea> <textarea name="student_comment"><?= htmlReady($solution->student_comment) ?></textarea>
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<?= $this->render_partial($exercise->getSolveTemplate($solution, $assignment, $solver_id)) ?> <?= $this->render_partial($exercise->getSolveTemplate($solution, $assignment, $solver_id)) ?>
<? if (!empty($exercise->options['comment'])) : ?> <? if (isset($exercise->options['comment']) && $exercise->options['comment']) : ?>
<label> <label>
<?= _vips('Bemerkungen zur Lösung (optional)') ?> <?= _vips('Bemerkungen zur Lösung (optional)') ?>
<textarea name="student_comment"><?= $solution ? htmlReady($solution->student_comment) : '' ?></textarea> <textarea name="student_comment"><?= $solution ? htmlReady($solution->student_comment) : '' ?></textarea>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment