|
44 | 44 | $context = context::instance_by_id($contextid);
|
45 | 45 | if (has_capability('moodle/question:editall', $context)) {
|
46 | 46 | $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, |
52 | 57 | 'numquestions' => $numcoderunnerquestions,
|
53 | 58 | ];
|
54 | 59 | }
|
|
91 | 96 | echo html_writer::tag('p', '<b>jobe_host:</b> ' . $jobehost);
|
92 | 97 | echo html_writer::start_tag('ul');
|
93 | 98 | $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']; |
96 | 101 | $numcoderunnerquestions = $info['numquestions'];
|
97 | 102 |
|
98 | 103 | $testallstr = get_string('bulktestallincontext', 'qtype_coderunner');
|
|
0 commit comments