Skip to content
Snippets Groups Projects
Commit 076886d5 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Update dependences checker to work with moodle 4 DB changes.

More work required on hidden questions.
parent 1657a97e
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ require_once(__DIR__ . '/../../../engine/lib.php');
require_once(__DIR__ . '/../stack/utils.class.php');
require_once(__DIR__ . '/../stack/options.class.php');
require_once(__DIR__ . '/../stack/maximaparser/utils.php');
require_once(__DIR__ . '/../vle_specific.php');
require_login();
$context = context_system::instance();
......@@ -48,8 +49,15 @@ $title = 'Dependency checker';
$PAGE->set_title($title);
// Figure out the number of questions that can be explored.
$notcompiled = $DB->get_recordset_sql('SELECT count(*) as notcompiled FROM {question} q, ' .
'{qtype_stack_options} o WHERE q.id = o.questionid AND q.hidden = 0 AND o.compiledcache = ?;', ['{}']);
$query = 'SELECT count(*) as notcompiled FROM {question} q, ' .
'{qtype_stack_options} o WHERE q.id = o.questionid AND o.compiledcache = ?;';
// TODO: figure out about hidden questions in Moodle 4+.
// This needs to be added to all versions below in which I've omitted this clause.
if (stack_determine_moodle_version() < 400) {
$query = 'SELECT count(*) as notcompiled FROM {question} q, ' .
'{qtype_stack_options} o WHERE q.id = o.questionid AND q.hidden = 0 AND o.compiledcache = ?;';
}
$notcompiled = $DB->get_recordset_sql($query, ['{}']);
$nnotcompiled = 0;
$ncompiled = 0;
......@@ -58,8 +66,14 @@ foreach ($notcompiled as $item) {
}
$notcompiled->close();
$compiled = $DB->get_recordset_sql('SELECT count(*) as compiled FROM {question} q, {qtype_stack_options} ' .
'o WHERE q.id = o.questionid AND q.hidden = 0 AND NOT o.compiledcache = ?;', ['{}']);
$query = 'SELECT count(*) as compiled FROM {question} q, ' .
'{qtype_stack_options} o WHERE q.id = o.questionid AND NOT o.compiledcache = ?;';
if (stack_determine_moodle_version() < 400) {
$query = 'SELECT count(*) as compiled FROM {question} q, {qtype_stack_options} ' .
'o WHERE q.id = o.questionid AND q.hidden = 0 AND NOT o.compiledcache = ?;';
}
$compiled = $DB->get_recordset_sql($query, ['{}']);
foreach ($compiled as $item) {
$ncompiled = $item->compiled;
......@@ -99,7 +113,7 @@ if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) {
* Both are noted in the compiled cache as important meta.
*/
$qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' .
'q.id = o.questionid AND q.hidden = 0 AND ' .
'q.id = o.questionid AND ' .
$DB->sql_like('o.compiledcache', ':trg') . ';', ['trg' => '%"includes"%']);
echo '<h4>Questions using includes</h4>';
echo '<table><thead><tr><th>Question</th><th>Keyval includes</th><th>Castext includes</th></tr></thead><tbody>';
......@@ -145,7 +159,7 @@ if (data_submitted() && optional_param('jsxgraphs', false, PARAM_BOOL)) {
* form then we probably have something else in play or a "TODO" note.
*/
$qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' .
'q.id = o.questionid AND q.hidden = 0 AND ' .
'q.id = o.questionid AND ' .
$DB->sql_like('o.compiledcache', ':trg', false) . ';', ['trg' => '%jsxgraph%']);
echo '<h4>Questions containing JSXGraph related terms</h4>';
echo '<table><thead><tr><th>Question</th>' .
......@@ -186,7 +200,7 @@ if (data_submitted() && optional_param('script', false, PARAM_BOOL)) {
* <script present in the question
*/
$qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' .
'q.id = o.questionid AND q.hidden = 0 AND ' .
'q.id = o.questionid AND ' .
$DB->sql_like('o.compiledcache', ':trg', false) . ';', ['trg' => '%<script%']);
echo '<h4>Questions containing script tags</h4>';
echo '<table><thead><tr><th>Question</th></thead><tbody>';
......@@ -206,7 +220,7 @@ if (data_submitted() && optional_param('PLUGINFILE', false, PARAM_BOOL)) {
* @@PLUGINFILE@@ present in the question.
*/
$qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' .
'q.id = o.questionid AND q.hidden = 0 AND ' .
'q.id = o.questionid AND ' .
$DB->sql_like('o.compiledcache', ':trg') . ';', ['trg' => '%@@PLUGINFILE@@%']);
echo '<h4>Questions containing attached files handled by Moodle</h4>';
echo '<table><thead><tr><th>Question</th></thead><tbody>';
......@@ -226,7 +240,7 @@ if (data_submitted() && optional_param('langs', false, PARAM_BOOL)) {
* Questions that have localisation.
*/
$qs = $DB->get_recordset_sql('SELECT q.id as questionid FROM {question} q, {qtype_stack_options} o WHERE ' .
'q.id = o.questionid AND q.hidden = 0 AND ' . $DB->sql_like('o.compiledcache', ':trg') . ' AND NOT ' .
'q.id = o.questionid AND ' . $DB->sql_like('o.compiledcache', ':trg') . ' AND NOT ' .
$DB->sql_like('o.compiledcache', ':other') . ';', ['trg' => '%"langs":[%', 'other' => '%"langs":[]%']);
echo '<h4>Questions containing that have localisation using means we understand.</h4>';
echo '<table><thead><tr><th>Question</th><th>Langs</th></thead><tbody>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment