Skip to content

Commit

Permalink
iss1304 - Narrow down todo questions checked
Browse files Browse the repository at this point in the history
  • Loading branch information
EJMFarrow committed Nov 11, 2024
1 parent 0773e6b commit 99efead
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adminui/todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
core_php_time_limit::raise(60); // Prevent PHP timeouts.

$qtodos = [];
$questions = $bulktester->stack_questions_in_category($currentcategoryid);
$questions = $bulktester->stack_questions_in_category_with_todo($currentcategoryid);
if (!$questions) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions lang/en/qtype_stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

$string['privacy:metadata'] = 'The STACK question type plugin does not store any personal data.';
$string['cachedef_parsercache'] = 'STACK parsed Maxima expressions';
$string['cachedef_librarycache'] = 'STACK question library renders and file structure';

$string['mbstringrequired'] = 'Installing the MBSTRING library is required for STACK.';
$string['yamlrecommended'] = 'Installing the YAML library is recommended for STACK.';
Expand Down
36 changes: 36 additions & 0 deletions stack/bulktester.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,42 @@ public function stack_questions_in_category($categoryid) {
WHERE be.id = qbe.id)", $qcparams);
}

/**
* Find all stack questions in a given category with a todo block, returning only
* the latest version of each question.
* @param type $categoryid the id of a question category of interest
* @return all stack question ids in any state and any version in the given
* category. Each row in the returned list of rows has an id, name and version number.
*/
public function stack_questions_in_category_with_todo($categoryid) {
global $DB;

// See question/engine/bank.php around line 500, but this does not return the last version.
$qcparams['readystatus'] = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY;
return $DB->get_records_sql_menu("
SELECT q.id, q.name AS id2
FROM {question} q
JOIN {question_versions} qv ON qv.questionid = q.id
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
JOIN {qtype_stack_options} qso ON qso.questionid = q.id
WHERE qbe.questioncategoryid = {$categoryid}
AND q.parent = 0
AND qv.status = :readystatus
AND q.qtype = 'stack'
AND qv.version = (SELECT MAX(v.version)
FROM {question_versions} v
JOIN {question_bank_entries} be
ON be.id = v.questionbankentryid
WHERE be.id = qbe.id)
AND (
q.questiontext REGEXP '[[][[]todo'
OR q.generalfeedback REGEXP '[[][[]todo'
OR qso.questionnote REGEXP '[[][[]todo'
OR qso.specificfeedback REGEXP '[[][[]todo'
OR qso.questiondescription REGEXP '[[][[]todo'
)", $qcparams);
}

/**
* Get a list of all the categories within the supplied contextid that
* contain stack questions in any state and any version.
Expand Down

0 comments on commit 99efead

Please sign in to comment.