Skip to content

Commit

Permalink
Adding category and course shortname to bulk test report (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnupamaSarjoshi authored Apr 19, 2024
1 parent 9181364 commit f36b4df
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions classes/bulk_tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,17 @@ public function run_all_tests_for_context(context $context, $categoryid = null)
global $OUTPUT;

// Load the necessary data.
$coursename = $context->get_context_name(true, true);
$categories = $this->get_categories_for_context($context->id);
$questiontestsurl = new moodle_url('/question/type/coderunner/questiontestrun.php');
if ($context->contextlevel == CONTEXT_COURSE) {
$questiontestsurl->param('courseid', $context->instanceid);
$qparams['courseid'] = $context->instanceid;
} else if ($context->contextlevel == CONTEXT_MODULE) {
$questiontestsurl->param('cmid', $context->instanceid);
$qparams['cmid'] = $context->instanceid;
} else {
$questiontestsurl->param('courseid', SITEID);
$qparams['courseid'] = SITEID;
}
$questiontestsurl->params($qparams);
$numpasses = 0;
$failingtests = [];
$missinganswers = [];
Expand Down Expand Up @@ -233,12 +235,17 @@ public function run_all_tests_for_context(context $context, $categoryid = null)
// Report the result, and record failures for the summary.
echo " $message</li>";
flush(); // Force output to prevent timeouts and show progress.
$qparams['category'] = $currentcategoryid . ',' . $context->id;
$qparams['lastchanged'] = $question->id;
$qparams['qperpage'] = 1000;
$questionbankurl = new moodle_url('/question/edit.php', $qparams);
$questionbanklink = html_writer::link($questionbankurl, $nameandcount->name, ['target' => '_blank']);
if ($outcome === self::PASS) {
$numpasses += 1;
} else if ($outcome === self::MISSINGANSWER) {
$missinganswers[] = $questionnamelink;
$missinganswers[] = "$coursename / $questionbanklink / $questionnamelink";
} else {
$failingtests[] = "$questionnamelink: $message";
$failingtests[] = "$coursename / $questionbanklink / $questionnamelink: $message";
}
}
echo "</ul>\n";
Expand Down

0 comments on commit f36b4df

Please sign in to comment.