|
56 | 56 | '{qtype_stack_options} o, {question_versions} v WHERE q.id = o.questionid AND q.id = v.id ' . ' |
57 | 57 | AND NOT v.status = "hidden" AND o.compiledcache = ?;'; |
58 | 58 |
|
59 | | -$notcompiled = $DB->get_recordset_sql($query, ['{}']); |
60 | | - |
61 | | -$nnotcompiled = 0; |
62 | | -$ncompiled = 0; |
63 | | -foreach ($notcompiled as $item) { |
64 | | - $nnotcompiled = $item->notcompiled; |
65 | | -} |
66 | | -$notcompiled->close(); |
| 59 | +$notcompiled = $DB->get_record_sql($query, ['{}']); |
| 60 | +$nnotcompiled = $notcompiled->notcompiled; |
67 | 61 |
|
68 | 62 | $query = 'SELECT count(*) as compiled FROM {question} q, ' . |
69 | 63 | '{qtype_stack_options} o, {question_versions} v WHERE q.id = o.questionid AND q.id = v.id ' . ' |
70 | | - AND NOT v.status = "hidden" AND o.compiledcache = ?;'; |
71 | | - |
72 | | -$compiled = $DB->get_recordset_sql($query, ['{}']); |
| 64 | + AND NOT v.status = "hidden" AND o.compiledcache != ?;'; |
73 | 65 |
|
74 | | -foreach ($compiled as $item) { |
75 | | - $ncompiled = $item->compiled; |
76 | | -} |
77 | | -$compiled->close(); |
| 66 | +$compiled = $DB->get_record_sql($query, ['{}']); |
| 67 | +$ncompiled = $compiled->compiled; |
78 | 68 |
|
79 | 69 | echo $OUTPUT->header(); |
80 | 70 | echo $OUTPUT->heading($title); |
81 | 71 |
|
82 | 72 | echo '<p>This tool only acts on succesfully compiled questions, to compile questions run the bulk tester ' . |
83 | 73 | 'or preview/use those questions.</p><p>'; |
84 | | -if ($ncompiled !== $notcompiled) { |
| 74 | +if ($nnotcompiled) { |
85 | 75 | echo stack_string_error('errors') . '. '; |
86 | 76 | } |
87 | 77 | echo 'Currently there are ' . $ncompiled . ' compiled questions and ' . $nnotcompiled . |
|
108 | 98 | echo $OUTPUT->single_button( |
109 | 99 | new moodle_url($PAGE->url, ['todo' => 1, 'sesskey' => sesskey()]), |
110 | 100 | 'Find "todo"'); |
| 101 | +echo $OUTPUT->single_button( |
| 102 | + new moodle_url($PAGE->url, ['broken' => 1, 'sesskey' => sesskey()]), |
| 103 | + 'Find "broken"'); |
111 | 104 |
|
112 | 105 | if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) { |
113 | 106 | /* |
|
328 | 321 | // Load the whole question, simpler to get the contexts correct that way. |
329 | 322 | foreach ($qs as $item) { |
330 | 323 | $q = question_bank::load_question($item->questionid); |
331 | | - $tags = $q->get_question_todos(); |
| 324 | + list($hastodos, $tags) = $q->get_question_todos(); |
332 | 325 | list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); |
333 | 326 | $qurl = qbank_previewquestion\helper::question_preview_url($item->questionid, |
334 | 327 | null, null, null, null, $context); |
|
339 | 332 | echo '</tbody></table>'; |
340 | 333 | } |
341 | 334 |
|
| 335 | +if (data_submitted() && optional_param('broken', false, PARAM_BOOL)) { |
| 336 | + /* |
| 337 | + * Question marked as broken. |
| 338 | + */ |
| 339 | + $qs = $DB->get_recordset_sql('SELECT q.id as questionid, q.name as name |
| 340 | + FROM {question} q |
| 341 | + JOIN {question_versions} qv ON qv.questionid = q.id |
| 342 | + JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid |
| 343 | + JOIN {qtype_stack_options} o ON q.id = o.questionid |
| 344 | + WHERE o.isbroken = 1 |
| 345 | + AND qv.version = ( |
| 346 | + SELECT MAX(version) |
| 347 | + FROM {question_versions} v |
| 348 | + WHERE v.questionbankentryid = qbe.id |
| 349 | + )'); |
| 350 | + echo '<h4>Questions with most recent version marked as broken</h4>'; |
| 351 | + echo '<table><thead><tr><th>Question</th><th>Version</th></thead><tbody>'; |
| 352 | + // Load the whole question, simpler to get the contexts correct that way. |
| 353 | + foreach ($qs as $item) { |
| 354 | + $q = question_bank::load_question($item->questionid); |
| 355 | + list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); |
| 356 | + $editurl = new \moodle_url('/question/bank/editquestion/question.php', [ |
| 357 | + 'id' => $urlparams['questionid'], |
| 358 | + 'returnURL' => new moodle_url('/question/type/stack/adminui/dependencies.php'), |
| 359 | + 'courseid' => $urlparams['courseid'], |
| 360 | + ]); |
| 361 | + echo '<tr><td>' . $item->name . ' ' . |
| 362 | + $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit'))) . |
| 363 | + '</td><td>' . $q->version . '</td></tr>'; |
| 364 | + } |
| 365 | + echo '</tbody></table>'; |
| 366 | +} |
| 367 | + |
342 | 368 | echo $OUTPUT->footer(); |
0 commit comments