Skip to content

Commit

Permalink
Replace global $PAGE and $OUTPUT with $this->
Browse files Browse the repository at this point in the history
Linter reports use of globals as breaking the BadGlobal coding
standard in renderer.php.  Change to $this->output and $this->page
Plus a line was over the 134 character limit
  • Loading branch information
marcusgreen committed Oct 20, 2024
1 parent 717d9b2 commit 9b43ba0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class qtype_aitext_renderer extends qtype_renderer {
*/
public function formulation_and_controls(question_attempt $qa,
question_display_options $options) {
global $CFG, $PAGE, $USER;
global $CFG, $USER;

/** @var qtype_aitext_question $question */
$question = $qa->get_question();
Expand Down Expand Up @@ -96,8 +96,9 @@ public function formulation_and_controls(question_attempt $qa,
$uniqid = uniqid();
$result .= html_writer::tag('div', '',
['data-content' => 'local_ai_manager_infobox', 'data-boxid' => $uniqid]);
$PAGE->requires->js_call_amd('local_ai_manager/infobox', 'renderInfoBox',
['qtype_aitext', $USER->id, '[data-content="local_ai_manager_infobox"][data-boxid="' . $uniqid . '"]', ['feedback']]);
$this->page->requires->js_call_amd('local_ai_manager/infobox', 'renderInfoBox',
['qtype_aitext', $USER->id, '[data-content="local_ai_manager_infobox"][data-boxid="' . $uniqid . '"]',
['feedback']]);
$result .= html_writer::tag('div', $question->format_questiontext($qa),
['class' => 'qtext']);

Expand All @@ -113,7 +114,7 @@ public function formulation_and_controls(question_attempt $qa,
$result .= html_writer::end_tag('div');
$result .= html_writer::tag('div', '',
['data-content' => 'local_ai_manager_warningbox', 'data-boxid' => $uniqid]);
$PAGE->requires->js_call_amd('local_ai_manager/warningbox', 'renderWarningBox',
$this->page->requires->js_call_amd('local_ai_manager/warningbox', 'renderWarningBox',
['[data-content="local_ai_manager_warningbox"][data-boxid="' . $uniqid . '"]']);

return $result;
Expand Down Expand Up @@ -327,7 +328,6 @@ protected function class_name() {
* @throws coding_exception
*/
public function response_area_read_only($name, $qa, $step, $lines, $context) {
global $OUTPUT;
$question = $qa->get_question();
$uniqid = uniqid();
$readonlyareaid = 'aitext_readonly_area' . $uniqid;
Expand Down Expand Up @@ -373,7 +373,7 @@ public function response_area_read_only($name, $qa, $step, $lines, $context) {
$btnoptions = ['id' => $spellcheckeditbuttonid, 'class' => 'btn btn-link'];
$output .= html_writer::tag(
'button',
$OUTPUT->pix_icon(
$this->output->pix_icon(
'i/edit',
get_string('spellcheckedit', 'qtype_aitext'),
'moodle'
Expand Down Expand Up @@ -692,7 +692,6 @@ protected function class_name() {
*/
public function response_area_read_only($name, $qa, $step, $lines, $context) {
// CARE: This is basically duplicating response_area_read_only from qtype_aitext_format_editor_renderer.
global $OUTPUT;
$question = $qa->get_question();
$uniqid = uniqid();
$readonlyareaid = 'aitext_readonly_area' . $uniqid;
Expand Down Expand Up @@ -738,7 +737,7 @@ public function response_area_read_only($name, $qa, $step, $lines, $context) {
$btnoptions = ['id' => $spellcheckeditbuttonid, 'class' => 'btn btn-link'];
$output .= html_writer::tag(
'button',
$OUTPUT->pix_icon(
$this->output->pix_icon(
'i/edit',
get_string('spellcheckedit', 'qtype_aitext'),
'moodle'
Expand Down

0 comments on commit 9b43ba0

Please sign in to comment.