Skip to content

Commit c2b887d

Browse files
committed
Showing solutions as soon as they are refreshed
1 parent bf8d44a commit c2b887d

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

app/Http/Controllers/QuestionController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ public function refreshProperties(Question $question): array
151151

152152
try {
153153

154-
$response['type'] = 'error';
155-
$authorized = Gate::inspect('refreshProperties', [$question]);
156-
if (!$authorized->allowed()) {
157-
$response['message'] = $authorized->message();
158-
return $response;
159-
}
154+
$response['type'] = 'error';
155+
$authorized = Gate::inspect('refreshProperties', [$question]);
156+
if (!$authorized->allowed()) {
157+
$response['message'] = $authorized->message();
158+
return $response;
159+
}
160160

161161
$response['type'] = 'error';
162162
$question->refreshProperties();
163-
163+
$response['solution_html'] = $question->solution_html ?: null;
164164
$response['type'] = 'success';
165165
} catch (Exception $e) {
166166
$h = new Handler(app());

resources/js/pages/instructors/assignment_information/questions.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@
262262
{{ item.submission }}
263263
</td>
264264
<td>{{ item.points }}</td>
265-
<td><SolutionFileHtml :key="item.question_id" :questions="items" :current-page="item.order"
266-
:format-filename="false"
267-
/>
265+
<td>
266+
<SolutionFileHtml :key="item.question_id" :questions="items" :current-page="item.order"
267+
:format-filename="false"
268+
/>
268269
<td v-if="user.role === 2">
269270
<b-tooltip :target="getTooltipTarget('edit',item.question_id)"
270271
delay="500"
@@ -335,6 +336,7 @@ import {
335336
updateNonLearningTreeInLearningTreeMessage
336337
} from '~/helpers/AssessmentTypeWarnings'
337338
import SolutionFileHtml from '~/components/SolutionFileHtml'
339+
338340
export default {
339341
middleware: 'auth',
340342
components: {
@@ -405,12 +407,15 @@ export default {
405407
this.items[i].refresh_status = data.type === 'success'
406408
? '<span class="text-success">Success</span>'
407409
: '<span class="text-danger">Error</span>'
410+
if (data.type === 'success' && data.solution_html) {
411+
this.items[i].solution_html = data.solution_html
412+
this.items[i].type = 'html'
413+
}
408414
} catch (error) {
409415
this.items[i].refresh_status = '<span class="text-danger">Error</span>'
410416
}
411417
this.$forceUpdate()
412418
}
413-
414419
},
415420
viewQuestionInModal (question, action) {
416421
this.alphaAssignmentQuestion = question

0 commit comments

Comments
 (0)