Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Moodle renderer used to display special elements of the lesson module
  20   *
  21   * @package mod_lesson
  22   * @copyright  2009 Sam Hemelryk
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   **/
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  class mod_lesson_renderer extends plugin_renderer_base {
  29      /**
  30       * Returns the header for the lesson module
  31       *
  32       * @param lesson $lesson a lesson object.
  33       * @param string $currenttab current tab that is shown.
  34       * @param bool   $extraeditbuttons if extra edit buttons should be displayed.
  35       * @param int    $lessonpageid id of the lesson page that needs to be displayed.
  36       * @param string $extrapagetitle String to appent to the page title.
  37       * @return string
  38       */
  39      public function header($lesson, $cm, $currenttab = '', $extraeditbuttons = false, $lessonpageid = null, $extrapagetitle = null) {
  40          global $CFG, $USER;
  41  
  42          $activityname = format_string($lesson->name, true, $lesson->course);
  43          if (empty($extrapagetitle)) {
  44              $title = $this->page->course->shortname.": ".$activityname;
  45          } else {
  46              $title = $this->page->course->shortname.": ".$activityname.": ".$extrapagetitle;
  47          }
  48  
  49          // Build the buttons
  50          $context = context_module::instance($cm->id);
  51  
  52          // Header setup.
  53          $this->page->set_title($title);
  54          $this->page->set_heading($this->page->course->fullname);
  55  
  56          $canmanage = has_capability('mod/lesson:manage', $context);
  57          $activityheader = $this->page->activityheader;
  58          $activitypage = new moodle_url('/mod/' . $this->page->activityname . '/view.php');
  59          $setactive = $activitypage->compare($this->page->url, URL_MATCH_BASE);
  60          if ($activityheader->is_title_allowed()) {
  61              $title = $canmanage && $setactive ?
  62                          $this->output->heading_with_help($activityname, 'overview', 'lesson') :
  63                          $activityname;
  64              $activityheader->set_title($title);
  65          }
  66  
  67          // If we have the capability to manage the lesson but not within the view page,
  68          // there's no reason to show activity/completion information.
  69          if ($canmanage && !$setactive) {
  70              $activityheader->set_hidecompletion(true);
  71          }
  72  
  73          $output = $this->output->header();
  74  
  75          foreach ($lesson->messages as $message) {
  76              $output .= $this->output->notification($message[0], $message[1], $message[2]);
  77          }
  78  
  79          return $output;
  80      }
  81  
  82      /**
  83       * Returns the footer
  84       * @return string
  85       */
  86      public function footer() {
  87          return $this->output->footer();
  88      }
  89  
  90      /**
  91       * Returns HTML for a lesson inaccessible message
  92       *
  93       * @param string $message
  94       * @return <type>
  95       */
  96      public function lesson_inaccessible($message) {
  97          global $CFG;
  98          $output  =  $this->output->box_start('generalbox boxaligncenter');
  99          $output .=  $this->output->box_start('center');
 100          $output .=  $message;
 101          $output .=  $this->output->box('<a href="'.$CFG->wwwroot.'/course/view.php?id='. $this->page->course->id .'">'. get_string('returnto', 'lesson', format_string($this->page->course->fullname, true)) .'</a>', 'lessonbutton standardbutton');
 102          $output .=  $this->output->box_end();
 103          $output .=  $this->output->box_end();
 104          return $output;
 105      }
 106  
 107      /**
 108       * Returns HTML to prompt the user to log in
 109       * @param lesson $lesson
 110       * @param bool $failedattempt
 111       * @return string
 112       */
 113      public function login_prompt(lesson $lesson, $failedattempt = false) {
 114          global $CFG;
 115          $output  = $this->output->box_start('password-form');
 116          $output .= $this->output->box_start('generalbox boxaligncenter');
 117          $output .=  '<form id="password" method="post" action="'.$CFG->wwwroot.'/mod/lesson/view.php" autocomplete="off">';
 118          $output .=  '<fieldset class="invisiblefieldset center">';
 119          $output .=  '<input type="hidden" name="id" value="'. $this->page->cm->id .'" />';
 120          $output .=  '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
 121          if ($failedattempt) {
 122              $output .=  $this->output->notification(get_string('loginfail', 'lesson'));
 123          }
 124          $output .= get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name)).'<br /><br />';
 125          $output .= get_string('enterpassword', 'lesson')." <input type=\"password\" name=\"userpassword\" /><br /><br />";
 126          $output .= "<div class='lessonbutton standardbutton submitbutton'><input type='submit' value='".get_string('continue', 'lesson')."' /></div>";
 127          $output .= " <div class='lessonbutton standardbutton submitbutton'><input type='submit' name='backtocourse' value='".get_string('cancel', 'lesson')."' /></div>";
 128          $output .=  '</fieldset></form>';
 129          $output .=  $this->output->box_end();
 130          $output .=  $this->output->box_end();
 131          return $output;
 132      }
 133  
 134      /**
 135       * Returns HTML to display dependancy errors
 136       *
 137       * @param object $dependentlesson
 138       * @param array $errors
 139       * @return string
 140       */
 141      public function dependancy_errors($dependentlesson, $errors) {
 142          $output  = $this->output->box_start('generalbox boxaligncenter');
 143          $output .= get_string('completethefollowingconditions', 'lesson', $dependentlesson->name);
 144          $output .= $this->output->box(implode('<br />'.get_string('and', 'lesson').'<br />', $errors),'center');
 145          $output .= $this->output->box_end();
 146          return $output;
 147      }
 148  
 149      /**
 150       * Returns HTML to display a message
 151       * @param string $message
 152       * @param single_button $button
 153       * @return string
 154       */
 155      public function message($message, single_button $button = null) {
 156          $output  = $this->output->box_start('generalbox boxaligncenter');
 157          $output .= $message;
 158          if ($button !== null) {
 159              $output .= $this->output->box($this->output->render($button), 'lessonbutton standardbutton');
 160          }
 161          $output .= $this->output->box_end();
 162          return $output;
 163      }
 164  
 165      /**
 166       * Returns HTML to display a continue button
 167       * @param lesson $lesson
 168       * @param int $lastpageseen
 169       * @return string
 170       */
 171      public function continue_links(lesson $lesson, $lastpageseenid) {
 172          global $CFG;
 173          $output = $this->output->box(get_string('youhaveseen','lesson'), 'generalbox boxaligncenter');
 174          $output .= $this->output->box_start('center');
 175  
 176          $yeslink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id,
 177              'pageid' => $lastpageseenid, 'startlastseen' => 'yes')), get_string('yes'), array('class' => 'btn btn-primary'));
 178          $output .= html_writer::tag('span', $yeslink, array('class'=>'lessonbutton standardbutton'));
 179          $output .= '&nbsp;';
 180  
 181          $nolink = html_writer::link(new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id,
 182              'pageid' => $lesson->firstpageid, 'startlastseen' => 'no')), get_string('no'), array('class' => 'btn btn-secondary'));
 183          $output .= html_writer::tag('span', $nolink, array('class'=>'lessonbutton standardbutton'));
 184  
 185          $output .= $this->output->box_end();
 186          return $output;
 187      }
 188  
 189      /**
 190       * Returns HTML to display a page to the user
 191       * @param lesson $lesson
 192       * @param lesson_page $page
 193       * @param object $attempt
 194       * @return string
 195       */
 196      public function display_page(lesson $lesson, lesson_page $page, $attempt) {
 197          // We need to buffer here as there is an mforms display call
 198          ob_start();
 199          echo $page->display($this, $attempt);
 200          $output = ob_get_contents();
 201          ob_end_clean();
 202          return $output;
 203      }
 204  
 205      /**
 206       * Returns HTML to display a collapsed edit form
 207       *
 208       * @param lesson $lesson
 209       * @param int $pageid
 210       * @return string
 211       */
 212      public function display_edit_collapsed(lesson $lesson, $pageid) {
 213          global $DB, $CFG;
 214  
 215          $manager = lesson_page_type_manager::get($lesson);
 216          $qtypes = $manager->get_page_type_strings();
 217          $npages = count($lesson->load_all_pages());
 218  
 219          $table = new html_table();
 220          $table->head = array(get_string('pagetitle', 'lesson'), get_string('qtype', 'lesson'), get_string('jumps', 'lesson'), get_string('actions', 'lesson'));
 221          $table->align = array('left', 'left', 'left', 'center');
 222          $table->data = array();
 223  
 224          $canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id));
 225  
 226          while ($pageid != 0) {
 227              $page = $lesson->load_page($pageid);
 228              $data = array();
 229              $url = new moodle_url('/mod/lesson/edit.php', array(
 230                  'id'     => $this->page->cm->id,
 231                  'mode'   => 'single',
 232                  'pageid' => $page->id
 233              ));
 234              $data[] = html_writer::link($url, format_string($page->title, true), array('id' => 'lesson-' . $page->id));
 235              $data[] = $qtypes[$page->qtype];
 236              $data[] = implode("<br />\n", $page->jumps);
 237              if ($canedit) {
 238                  $data[] = $this->page_action_links($page, $npages, true);
 239              } else {
 240                  $data[] = '';
 241              }
 242              $table->data[] = $data;
 243              $pageid = $page->nextpageid;
 244          }
 245  
 246          return html_writer::table($table);
 247      }
 248  
 249      /**
 250       * Returns HTML to display the full edit page
 251       *
 252       * @param lesson $lesson
 253       * @param int $pageid
 254       * @param int $prevpageid
 255       * @param bool $single
 256       * @return string
 257       */
 258      public function display_edit_full(lesson $lesson, $pageid, $prevpageid, $single=false) {
 259          global $DB, $CFG;
 260  
 261          $manager = lesson_page_type_manager::get($lesson);
 262          $qtypes = $manager->get_page_type_strings();
 263          $npages = count($lesson->load_all_pages());
 264          $canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id));
 265  
 266          $content = '';
 267          if ($canedit) {
 268              $content = $this->add_page_links($lesson, $prevpageid);
 269          }
 270  
 271          $options = new stdClass;
 272          $options->noclean = true;
 273  
 274          while ($pageid != 0 && $single!=='stop') {
 275              $page = $lesson->load_page($pageid);
 276  
 277              $pagetable = new html_table();
 278              $pagetable->align = array('right','left');
 279              $pagetable->width = '100%';
 280              $pagetable->tablealign = 'center';
 281              $pagetable->cellspacing = 0;
 282              $pagetable->cellpadding = '5px';
 283              $pagetable->data = array();
 284  
 285              $pageheading = new html_table_cell();
 286  
 287              $pageheading->text = html_writer::tag('a', '', array('id' => 'lesson-' . $pageid)) . format_string($page->title);
 288              if ($canedit) {
 289                  $pageheading->text .= ' '.$this->page_action_links($page, $npages);
 290              }
 291              $pageheading->style = 'text-align:center';
 292              $pageheading->colspan = 2;
 293              $pageheading->scope = 'col';
 294              $pagetable->head = array($pageheading);
 295  
 296              $cell = new html_table_cell();
 297              $cell->colspan = 2;
 298              $cell->style = 'text-align:left';
 299              $cell->text = $page->contents;
 300              $pagetable->data[] = new html_table_row(array($cell));
 301  
 302              $cell = new html_table_cell();
 303              $cell->colspan = 2;
 304              $cell->style = 'text-align:center';
 305              $cell->text = '<strong>'.$qtypes[$page->qtype] . $page->option_description_string().'</strong>';
 306              $pagetable->data[] = new html_table_row(array($cell));
 307  
 308              $pagetable = $page->display_answers($pagetable);
 309  
 310              $content .= html_writer::start_tag('div');
 311              $content .= html_writer::table($pagetable);
 312              $content .= html_writer::end_tag('div');
 313  
 314              if ($canedit) {
 315                  $content .= $this->add_page_links($lesson, $pageid);
 316              }
 317  
 318              // check the prev links - fix (silently) if necessary - there was a bug in
 319              // versions 1 and 2 when add new pages. Not serious then as the backwards
 320              // links were not used in those versions
 321              if ($page->prevpageid != $prevpageid) {
 322                  // fix it
 323                  $DB->set_field("lesson_pages", "prevpageid", $prevpageid, array("id" => $page->id));
 324                  debugging("<p>***prevpageid of page $page->id set to $prevpageid***");
 325              }
 326  
 327              $prevpageid = $page->id;
 328              $pageid = $page->nextpageid;
 329  
 330              if ($single === true) {
 331                  $single = 'stop';
 332              }
 333  
 334          }
 335  
 336          return $this->output->box($content, 'edit_pages_box');
 337      }
 338  
 339      /**
 340       * Returns HTML to display the add page links
 341       *
 342       * @param lesson $lesson
 343       * @param int $prevpageid
 344       * @return string
 345       */
 346      public function add_page_links(lesson $lesson, $prevpageid=false) {
 347          global $CFG;
 348  
 349          $links = array();
 350  
 351          $importquestionsurl = new moodle_url('/mod/lesson/import.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
 352          $links[] = html_writer::link($importquestionsurl, get_string('importquestions', 'lesson'));
 353  
 354          $manager = lesson_page_type_manager::get($lesson);
 355          foreach($manager->get_add_page_type_links($prevpageid) as $link) {
 356              $links[] = html_writer::link($link['addurl'], $link['name']);
 357          }
 358  
 359          $addquestionurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
 360          $links[] = html_writer::link($addquestionurl, get_string('addaquestionpagehere', 'lesson'));
 361  
 362          return $this->output->box(implode(" | \n", $links), 'addlinks');
 363      }
 364  
 365      /**
 366       * Return HTML to display add first page links
 367       * @param lesson $lesson
 368       * @return string
 369       */
 370      public function add_first_page_links(lesson $lesson) {
 371          $prevpageid = 0;
 372  
 373          $headinglevel = $this->page->activityheader->get_heading_level(3);
 374          $output = $this->output->heading(get_string("whatdofirst", "lesson"), $headinglevel);
 375          $links = array();
 376  
 377          $importquestionsurl = new moodle_url('/mod/lesson/import.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
 378          $links[] = html_writer::link($importquestionsurl, get_string('importquestions', 'lesson'));
 379  
 380          $manager = lesson_page_type_manager::get($lesson);
 381          foreach ($manager->get_add_page_type_links($prevpageid) as $link) {
 382              $link['addurl']->param('firstpage', 1);
 383              $links[] = html_writer::link($link['addurl'], $link['name']);
 384          }
 385  
 386          $addquestionurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid, 'firstpage'=>1));
 387          $links[] = html_writer::link($addquestionurl, get_string('addaquestionpage', 'lesson'));
 388  
 389          return $this->output->box($output.'<p>'.implode('</p><p>', $links).'</p>', 'generalbox firstpageoptions');
 390      }
 391  
 392      /**
 393       * Returns HTML to display action links for a page
 394       *
 395       * @param lesson_page $page
 396       * @param bool $printmove
 397       * @param bool $printaddpage
 398       * @return string
 399       */
 400      public function page_action_links(lesson_page $page, $printmove, $printaddpage=false) {
 401          global $CFG;
 402  
 403          $actions = array();
 404  
 405          if ($printmove) {
 406              $url = new moodle_url('/mod/lesson/lesson.php',
 407                      array('id' => $this->page->cm->id, 'action' => 'move', 'pageid' => $page->id, 'sesskey' => sesskey()));
 408              $label = get_string('movepagenamed', 'lesson', format_string($page->title));
 409              $img = $this->output->pix_icon('t/move', $label);
 410              $actions[] = html_writer::link($url, $img, array('title' => $label));
 411          }
 412          $url = new moodle_url('/mod/lesson/editpage.php', array('id' => $this->page->cm->id, 'pageid' => $page->id, 'edit' => 1));
 413          $label = get_string('updatepagenamed', 'lesson', format_string($page->title));
 414          $img = $this->output->pix_icon('t/edit', $label);
 415          $actions[] = html_writer::link($url, $img, array('title' => $label));
 416  
 417          // Duplicate action.
 418          $url = new moodle_url('/mod/lesson/lesson.php', array('id' => $this->page->cm->id, 'pageid' => $page->id,
 419                  'action' => 'duplicate', 'sesskey' => sesskey()));
 420          $label = get_string('duplicatepagenamed', 'lesson', format_string($page->title));
 421          $img = $this->output->pix_icon('e/copy', $label, 'mod_lesson');
 422          $actions[] = html_writer::link($url, $img, array('title' => $label));
 423  
 424          $url = new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id, 'pageid' => $page->id));
 425          $label = get_string('previewpagenamed', 'lesson', format_string($page->title));
 426          $img = $this->output->pix_icon('t/preview', $label);
 427          $actions[] = html_writer::link($url, $img, array('title' => $label));
 428  
 429          $url = new moodle_url('/mod/lesson/lesson.php',
 430                  array('id' => $this->page->cm->id, 'action' => 'confirmdelete', 'pageid' => $page->id, 'sesskey' => sesskey()));
 431          $label = get_string('deletepagenamed', 'lesson', format_string($page->title));
 432          $img = $this->output->pix_icon('t/delete', $label);
 433          $actions[] = html_writer::link($url, $img, array('title' => $label));
 434  
 435          if ($printaddpage) {
 436              $options = array();
 437              $manager = lesson_page_type_manager::get($page->lesson);
 438              $links = $manager->get_add_page_type_links($page->id);
 439              foreach ($links as $link) {
 440                  $options[$link['type']] = $link['name'];
 441              }
 442              $options[0] = get_string('addaquestionpage', 'lesson');
 443  
 444              $addpageurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$page->id, 'sesskey'=>sesskey()));
 445              $addpageselect = new single_select($addpageurl, 'qtype', $options, null, array(''=>get_string('addanewpage', 'lesson').'...'), 'addpageafter'.$page->id);
 446              $addpageselect->attributes = ['aria-label' => get_string('actions', 'lesson')];
 447              $addpageselector = $this->output->render($addpageselect);
 448          }
 449  
 450          if (isset($addpageselector)) {
 451              $actions[] = $addpageselector;
 452          }
 453  
 454          return implode(' ', $actions);
 455      }
 456  
 457      /**
 458       * Prints the on going message to the user.
 459       *
 460       * With custom grading On, displays points
 461       * earned out of total points possible thus far.
 462       * With custom grading Off, displays number of correct
 463       * answers out of total attempted.
 464       *
 465       * @param object $lesson The lesson that the user is taking.
 466       * @return void
 467       **/
 468  
 469       /**
 470        * Prints the on going message to the user.
 471        *
 472        * With custom grading On, displays points
 473        * earned out of total points possible thus far.
 474        * With custom grading Off, displays number of correct
 475        * answers out of total attempted.
 476        *
 477        * @param lesson $lesson
 478        * @return string
 479        */
 480      public function ongoing_score(lesson $lesson) {
 481          return $this->output->box($lesson->get_ongoing_score_message(), "ongoing center");
 482      }
 483  
 484      /**
 485       * Returns HTML to display a progress bar of progression through a lesson
 486       *
 487       * @param lesson $lesson
 488       * @param int $progress optional, if empty it will be calculated
 489       * @return string
 490       */
 491      public function progress_bar(lesson $lesson, $progress = null) {
 492          $context = context_module::instance($this->page->cm->id);
 493  
 494          // lesson setting to turn progress bar on or off
 495          if (!$lesson->progressbar) {
 496              return '';
 497          }
 498  
 499          // catch teachers
 500          if (has_capability('mod/lesson:manage', $context)) {
 501              return $this->output->notification(get_string('progressbarteacherwarning2', 'lesson'));
 502          }
 503  
 504          if ($progress === null) {
 505              $progress = $lesson->calculate_progress();
 506          }
 507  
 508          $content = html_writer::start_tag('div');
 509          $content .= html_writer::start_tag('div', array('class' => 'progress'));
 510          $content .= html_writer::start_tag('div', array('class' => 'progress-bar bar', 'role' => 'progressbar',
 511              'style' => 'width: ' . $progress .'%', 'aria-valuenow' => $progress, 'aria-valuemin' => 0, 'aria-valuemax' => 100));
 512          $content .= $progress . "%";
 513          $content .= html_writer::end_tag('div');
 514          $content .= html_writer::end_tag('div');
 515          $printprogress = html_writer::tag('div', get_string('progresscompleted', 'lesson', $progress) . $content);
 516          return $this->output->box($printprogress, 'progress_bar');
 517      }
 518  
 519      /**
 520       * Returns HTML to show the start of a slideshow
 521       * @param lesson $lesson
 522       */
 523      public function slideshow_start(lesson $lesson) {
 524          $attributes = array();
 525          $attributes['class'] = 'slideshow';
 526          $attributes['style'] = 'background-color:'.$lesson->properties()->bgcolor.';height:'.
 527                  $lesson->properties()->height.'px;width:'.$lesson->properties()->width.'px;';
 528          $output = html_writer::start_tag('div', $attributes);
 529          return $output;
 530      }
 531      /**
 532       * Returns HTML to show the end of a slideshow
 533       */
 534      public function slideshow_end() {
 535          $output = html_writer::end_tag('div');
 536          return $output;
 537      }
 538      /**
 539       * Returns a P tag containing contents
 540       * @param string $contents
 541       * @param string $class
 542       */
 543      public function paragraph($contents, $class='') {
 544          $attributes = array();
 545          if ($class !== '') {
 546              $attributes['class'] = $class;
 547          }
 548          $output = html_writer::tag('p', $contents, $attributes);
 549          return $output;
 550      }
 551  
 552      /**
 553       * Returns the HTML for displaying the end of lesson page.
 554       *
 555       * @param  lesson $lesson lesson instance
 556       * @param  stdclass $data lesson data to be rendered
 557       * @return string         HTML contents
 558       */
 559      public function display_eol_page(lesson $lesson, $data) {
 560  
 561          $output = '';
 562          $canmanage = $lesson->can_manage();
 563          $course = $lesson->courserecord;
 564  
 565          if ($lesson->custom && !$canmanage && (($data->gradeinfo->nquestions < $lesson->minquestions))) {
 566              $output .= $this->box_start('generalbox boxaligncenter');
 567          }
 568  
 569          if ($data->gradelesson) {
 570              $headinglevel = $this->page->activityheader->get_heading_level();
 571              $output .= $this->heading(get_string("congratulations", "lesson"), $headinglevel);
 572              $output .= $this->box_start('generalbox boxaligncenter');
 573          }
 574  
 575          if ($data->notenoughtimespent !== false) {
 576              $output .= $this->paragraph(get_string("notenoughtimespent", "lesson", $data->notenoughtimespent), 'center');
 577          }
 578  
 579          if ($data->numberofpagesviewed !== false) {
 580              $output .= $this->paragraph(get_string("numberofpagesviewed", "lesson", $data->numberofpagesviewed), 'center');
 581          }
 582          if ($data->youshouldview !== false) {
 583              $output .= $this->paragraph(get_string("youshouldview", "lesson", $data->youshouldview), 'center');
 584          }
 585          if ($data->numberofcorrectanswers !== false) {
 586              $output .= $this->paragraph(get_string("numberofcorrectanswers", "lesson", $data->numberofcorrectanswers), 'center');
 587          }
 588  
 589          if ($data->displayscorewithessays !== false) {
 590              $output .= $this->box(get_string("displayscorewithessays", "lesson", $data->displayscorewithessays), 'center');
 591          } else if ($data->displayscorewithoutessays !== false) {
 592              $output .= $this->box(get_string("displayscorewithoutessays", "lesson", $data->displayscorewithoutessays), 'center');
 593          }
 594  
 595          if ($data->yourcurrentgradeisoutof !== false) {
 596              $output .= $this->paragraph(get_string("yourcurrentgradeisoutof", "lesson", $data->yourcurrentgradeisoutof), 'center');
 597          }
 598          if ($data->yourcurrentgradeis !== false) {
 599              $output .= $this->paragraph(get_string("yourcurrentgradeis", "lesson", $data->yourcurrentgradeis), 'center');
 600          }
 601          if ($data->eolstudentoutoftimenoanswers !== false) {
 602              $output .= $this->paragraph(get_string("eolstudentoutoftimenoanswers", "lesson"));
 603          }
 604          if ($data->welldone !== false) {
 605              $output .= $this->paragraph(get_string("welldone", "lesson"));
 606          }
 607  
 608          if ($data->progresscompleted !== false) {
 609              $output .= $this->progress_bar($lesson, $data->progresscompleted);
 610          }
 611  
 612          if ($data->displayofgrade !== false) {
 613              $output .= $this->paragraph(get_string("displayofgrade", "lesson"), 'center');
 614          }
 615  
 616          $output .= $this->box_end(); // End of Lesson button to Continue.
 617  
 618          if ($data->reviewlesson !== false) {
 619              $output .= html_writer::link($data->reviewlesson, get_string('reviewlesson', 'lesson'),
 620                  array('class' => 'centerpadded lessonbutton standardbutton pr-3'));
 621          }
 622          if ($data->modattemptsnoteacher !== false) {
 623              $output .= $this->paragraph(get_string("modattemptsnoteacher", "lesson"), 'centerpadded');
 624          }
 625  
 626          if ($data->activitylink !== false) {
 627              $output .= $data->activitylink;
 628          }
 629  
 630          $url = new moodle_url('/course/view.php', array('id' => $course->id));
 631          $output .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)),
 632                  array('class' => 'centerpadded lessonbutton standardbutton pr-3'));
 633  
 634          if (has_capability('gradereport/user:view', context_course::instance($course->id))
 635                  && $course->showgrades && $lesson->grade != 0 && !$lesson->practice) {
 636              $url = new moodle_url('/grade/index.php', array('id' => $course->id));
 637              $output .= html_writer::link($url, get_string('viewgrades', 'lesson'),
 638                  array('class' => 'centerpadded lessonbutton standardbutton pr-3'));
 639          }
 640          return $output;
 641      }
 642  
 643      /**
 644       * Render the override action menu.
 645       *
 646       * @param \mod_lesson\output\override_action_menu $overrideactionmenu The overrideactionmenu
 647       *
 648       * @return string The rendered override action menu.
 649       */
 650      public function render_override_action_menu(\mod_lesson\output\override_action_menu $overrideactionmenu): string {
 651          $context = $overrideactionmenu->export_for_template($this);
 652          return $this->render_from_template('mod_lesson/override_action_menu', $context);
 653      }
 654  
 655      /**
 656       * Render the edit action buttons.
 657       *
 658       * @param \mod_lesson\output\edit_action_buttons $editbuttons The editbuttons
 659       *
 660       * @return string The rendered edit action buttons.
 661       */
 662      public function render_edit_action_buttons(\mod_lesson\output\edit_action_buttons $editbuttons): string {
 663          $context = $editbuttons->export_for_template($this);
 664          return $this->render_from_template('mod_lesson/edit_action_buttons', $context);
 665      }
 666  
 667      /**
 668       * Render the edit action area.
 669       *
 670       * @param \mod_lesson\output\edit_action_area $editarea The edit area.
 671       * @return string The rendered edit action area.
 672       */
 673      public function render_edit_action_area(\mod_lesson\output\edit_action_area $editarea): string {
 674          $context = $editarea->export_for_template($this);
 675          return $this->render_from_template('mod_lesson/edit_action_area', $context);
 676      }
 677  
 678      /**
 679       * Render the report action menu
 680       *
 681       * @param \mod\lesson\output\report_action_menu $reportmenu The reportmenu.
 682       * @return string The rendered report action menu.
 683       */
 684      public function render_report_action_menu(\mod_lesson\output\report_action_menu $reportmenu): string {
 685          $context = $reportmenu->export_for_template($this);
 686          return $this->render_from_template('mod_lesson/report_action_menu', $context);
 687      }
 688  }