Skip to content

Commit 41a9052

Browse files
committed
Fix bug in bulk tester.
1 parent 2fce6c8 commit 41a9052

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

bulktestindex.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@
4444
$context = context::instance_by_id($contextid);
4545
if (has_capability('moodle/question:editall', $context)) {
4646
$coursecontext = $context->get_course_context(false);
47-
$coursename = $coursecontext->get_context_name(true, true);
48-
$contextname = $context->get_context_name(true, true);
49-
$name = "$coursename: $contextname";
50-
$availablequestionsbycontext[$name] = [
51-
'contextid' => $contextid,
47+
if ($coursecontext) {
48+
$coursename = $coursecontext->get_context_name(true, true);
49+
$contextname = $context->get_context_name(false, true); // Without context prefix, short version.
50+
$name = "$coursename -> Context: $contextname";
51+
} else {
52+
// Just use this part in Moodle 5...
53+
$name = $context->get_context_name(true, true); // With context prefix, short version.
54+
}
55+
$availablequestionsbycontext[$contextid] = [
56+
'name' => $name,
5257
'numquestions' => $numcoderunnerquestions,
5358
];
5459
}
@@ -91,8 +96,8 @@
9196
echo html_writer::tag('p', '<b>jobe_host:</b> ' . $jobehost);
9297
echo html_writer::start_tag('ul');
9398
$buttonstyle = 'background-color: #FFFFD0; padding: 2px 2px 0px 2px;border: 4px solid white';
94-
foreach ($availablequestionsbycontext as $name => $info) {
95-
$contextid = $info['contextid'];
99+
foreach ($availablequestionsbycontext as $contextid => $info) {
100+
$name = $info['name'];
96101
$numcoderunnerquestions = $info['numquestions'];
97102

98103
$testallstr = get_string('bulktestallincontext', 'qtype_coderunner');

0 commit comments

Comments
 (0)