Add different informative messages to the given page.

@param lesson_page $page page object
@param stdClass $result the page processing result object
@param bool $reviewmode whether we are in review mode or not
@since  Moodle 3.3
518475
public function add_messages_on_page_process(lesson_page $page, $result, $reviewmode) {

        if ($this->can_manage()) {
            // This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher.
            if (lesson_display_teacher_warning($this)) {
                $warningvars = new stdClass();
                $warningvars->cluster = get_string("clusterjump", "lesson");
                $warningvars->unseen = get_string("unseenpageinbranch", "lesson");
                $this->add_message(get_string("teacherjumpwarning", "lesson", $warningvars));
            }
            // Inform teacher that s/he will not see the timer.
            if ($this->properties->timelimit) {
                $this->add_message(get_string("teachertimerwarning", "lesson"));
            }
        }
        // Report attempts remaining.
        if ($result->attemptsremaining != 0 && $this->properties->review && !$reviewmode) {
            $this->add_message(get_string('attemptsremaining', 'lesson', $result->attemptsremaining));
        }
    }
208686
protected function displayPage(SwatNoteBookPage $page, $count = 0)
    {
        echo '<tr class="swat-radio-note-book-option-row">';
        echo '<td>';

        $radio = new SwatHtmlTag('input');
        $radio->type = 'radio';
        $radio->name = $this->id;
        $radio->id = $this->id . '_' . $page->id;
        $radio->value = $this->id . '_' . $page->id;

        if ($page->id == $this->selected_page) {
            $radio->checked = 'checked';
        }

        echo '<span class="swat-radio-wrapper">';
        $radio->display();
        echo '<span class="swat-radio-shim"></span>';
        echo '</span>';

        echo '</td>';
        echo '<td>';

        $label = new SwatHtmlTag('label');
        $label->for = $this->id . '_' . $page->id;
        $label->setContent($page->title, $page->title_content_type);
        $label->display();

        echo '</td>';
        echo '</tr>';

        echo '<tr class="swat-radio-note-book-page-row">';
        echo '<td></td>';

        $td = new SwatHtmlTag('td');
        $td->class = 'swat-radio-note-book-page';

        if ($page->id == $this->selected_page) {
            $td->class .= ' selected';
        }

        $td->open();
        echo '<div class="swat-radio-note-book-page-container">';
        $page->display();
        echo '</div>';
        $td->close();

        echo '</tr>';
    }
1072573
public function add_page_links(lesson $lesson, $prevpageid=false) {
        global $CFG;

        $links = array();

        $importquestionsurl = new moodle_url('/mod/lesson/import.php',array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
        $links[] = html_writer::link($importquestionsurl, get_string('importquestions', 'lesson'));

        $manager = lesson_page_type_manager::get($lesson);
        foreach($manager->get_add_page_type_links($prevpageid) as $link) {
            $links[] = html_writer::link($link['addurl'], $link['name']);
        }

        $addquestionurl = new moodle_url('/mod/lesson/editpage.php', array('id'=>$this->page->cm->id, 'pageid'=>$prevpageid));
        $links[] = html_writer::link($addquestionurl, get_string('addaquestionpagehere', 'lesson'));

        return $this->output->box(implode(" | \n", $links), 'addlinks');
    }
377478
protected static function get_lesson_summary_for_exporter($lessonrecord, $password = '') {
        global $USER;

        $lesson = new lesson($lessonrecord);
        $lesson->update_effective_access($USER->id);
        $lessonavailable = $lesson->get_time_restriction_status() === false;
        $lessonavailable = $lessonavailable && $lesson->get_password_restriction_status($password) === false;
        $lessonavailable = $lessonavailable && $lesson->get_dependencies_restriction_status() === false;
        $canmanage = $lesson->can_manage();

        if (!$canmanage && !$lessonavailable) {
            $fields = array('intro', 'introfiles', 'mediafiles', 'practice', 'modattempts', 'usepassword',
                'grade', 'custom', 'ongoing', 'usemaxgrade',
                'maxanswers', 'maxattempts', 'review', 'nextpagedefault', 'feedback', 'minquestions',
                'maxpages', 'timelimit', 'retake', 'mediafile', 'mediaheight', 'mediawidth',
                'mediaclose', 'slideshow', 'width', 'height', 'bgcolor', 'displayleft', 'displayleftif',
                'progressbar');

            foreach ($fields as $field) {
                unset($lessonrecord->{$field});
            }
        }

        // Fields only for managers.
        if (!$canmanage) {
            $fields = array('password', 'dependency', 'conditions', 'activitylink', 'available', 'deadline',
                            'timemodified', 'completionendreached', 'completiontimespent');

            foreach ($fields as $field) {
                unset($lessonrecord->{$field});
            }
        }
        return $lessonrecord;
    }
968575
public function process_lesson_answer($data) {

        // replay the upgrade step 2010072003
        $flags = intval($data['flags']);
        if ($flags & 1) {
            $data['answer_text']  = text_to_html($data['answer_text'], false, false, true);
            $data['answerformat'] = FORMAT_HTML;
        }
        if ($flags & 2) {
            $data['response']       = text_to_html($data['response'], false, false, true);
            $data['responseformat'] = FORMAT_HTML;
        }

        // buffer for conversion of <jumpto> in line with
        // upgrade step 2010121400 from mod/lesson/db/upgrade.php
        $this->answers[] = $data;
    }
1072656
private function formatReviewText(ReviewAndRating $reviewAndRating)
    {
        $preparedText = htmlspecialchars($reviewAndRating->getReviewText());

        $reviewAndRating->setReviewText($preparedText);
    }
1281845
public function addPage(
        Result $result,
        int $page
    ): string {
        $urlParameters = $this->generateQueryUrlParameters($result);
        $urlParameters['page'] = $page;

        return $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        )['route'];
    }
689679
public void setReviewResults(java.util.Collection<ReviewResultDetail> reviewResults) {
        if (reviewResults == null) {
            this.reviewResults = null;
            return;
        }

        this.reviewResults = new java.util.ArrayList<ReviewResultDetail>(reviewResults);
    }
209016
private function AddPage(Page $page)
    {
        if (!$this->PageAllowed($page))
        {
            return;
        }
        $params = FrontendRouter::GatherParams($page->GetUrl());
        if (count($params) == 0)
        {
            $changeFreq = ChangeFrequency::ByValue($page->GetSitemapChangeFrequency());
            $priority = $page->GetSitemapRelevance();
            $lastLog = LogEvaluator::LastPageModLog($page, $this->resolver);
            $lastMod = $lastLog ? $lastLog->GetChanged() : null;
            $this->sitemap->AddUrl(FrontendRouter::PageUrl($page), $changeFreq, $priority, $lastMod);
        }
    }
1062485
private function postComment($issue, $result, $title)
    {
        if ($result === StepEvent::PASSED && $this->commentOnPass) {
            $this->jiraService->postComment($issue, sprintf('Scenario "%s" passed', $title));
        } elseif ($result === StepEvent::FAILED && $this->commentOnFail) {
            $this->jiraService->postComment($issue, sprintf('Scenario "%s" failed', $title));
        }
    }
1224463
public function render_summary_page(summary_page $page) {
        $data = $page->export_for_template($this);
        return parent::render_from_template('tool_dataprivacy/summary', $data);
    }
1118812
public function view_information($quiz, $cm, $context, $messages) {
        global $CFG;

        $output = '';

        // Print quiz name and description.
        $output .= $this->heading(format_string($quiz->name));
        $output .= $this->quiz_intro($quiz, $cm);

        // Output any access messages.
        if ($messages) {
            $output .= $this->box($this->access_messages($messages), 'quizinfo');
        }

        // Show number of attempts summary to those who can view reports.
        if (has_capability('mod/quiz:viewreports', $context)) {
            if ($strattemptnum = $this->quiz_attempt_summary_link_to_reports($quiz, $cm,
                    $context)) {
                $output .= html_writer::tag('div', $strattemptnum,
                        array('class' => 'quizattemptcounts'));
            }
        }
        return $output;
    }
1356318
public function print_header_and_tabs($cm, $course, $quiz, $reportmode = 'overview') {
        global $PAGE;
        $this->renderer = $PAGE->get_renderer('quiz_grading');
        parent::print_header_and_tabs($cm, $course, $quiz, $reportmode);
    }
608344
protected function _add_page_text()
    {
        if (!count($this->_page_text)) {
            return;
        }

        $page_number = 1;
        $eval = null;

        foreach ($this->_pages as $pid) {
            $this->reopen_object($pid);

            foreach ($this->_page_text as $pt) {
                extract($pt);

                switch ($_t) {
                    case "text":
                        $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"),
                            array($page_number, $this->_page_count), $text);
                        $this->text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
                        break;

                    case "script":
                        if (!$eval) {
                            $eval = new PhpEvaluator($this);
                        }
                        $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
                        break;

                    case 'line':
                        $this->line( $x1, $y1, $x2, $y2, $color, $width, $style );
                        break;
                }
            }

            $this->close_object();
            $page_number++;
        }
    }
528666
public function Index($DiscussionID = '', $DiscussionStub = '', $Page = '') {
      // Setup head
      $Session = Gdn::Session();
      $this->AddJsFile('jquery.autogrow.js');
      $this->AddJsFile('discussion.js');
      $this->AddJsFile('autosave.js');
      Gdn_Theme::Section('Discussion');
      
      // Load the discussion record
      $DiscussionID = (is_numeric($DiscussionID) && $DiscussionID > 0) ? $DiscussionID : 0;
      if (!array_key_exists('Discussion', $this->Data))
         $this->SetData('Discussion', $this->DiscussionModel->GetID($DiscussionID), TRUE);
         
      if(!is_object($this->Discussion)) {
         throw new Exception(sprintf(T('%s Not Found'), T('Discussion')), 404);
      }
      
      // Define the query offset & limit.
      $Limit = C('Vanilla.Comments.PerPage', 30);

      $OffsetProvided = $Page != '';
      list($Offset, $Limit) = OffsetLimit($Page, $Limit);
      
      // Check permissions
      $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', $this->Discussion->PermissionCategoryID);
      $this->SetData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, TRUE);
      
      if (strcasecmp(GetValue('Type', $this->Discussion), 'redirect') === 0) {
         $this->RedirectDiscussion($this->Discussion);
      }
      
      $Category = CategoryModel::Categories($this->Discussion->CategoryID);
      $this->SetData('Category', $Category);
      
      if ($CategoryCssClass = GetValue('CssClass', $Category))
         Gdn_Theme::Section($CategoryCssClass);
      
      $this->SetData('Breadcrumbs', CategoryModel::GetAncestors($this->CategoryID));
      
      // Setup
      $this->Title($this->Discussion->Name);

      // Actual number of comments, excluding the discussion itself.
      $ActualResponses = $this->Discussion->CountComments;

      $this->Offset = $Offset;
      if (C('Vanilla.Comments.AutoOffset')) {
//         if ($this->Discussion->CountCommentWatch > 1 && $OffsetProvided == '')
//            $this->AddDefinition('ScrollTo', 'a[name=Item_'.$this->Discussion->CountCommentWatch.']');
         if (!is_numeric($this->Offset) || $this->Offset < 0 || !$OffsetProvided) {
            // Round down to the appropriate offset based on the user's read comments & comments per page
            $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
            if ($CountCommentWatch > $ActualResponses)
               $CountCommentWatch = $ActualResponses;

            // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
            $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($ActualResponses <= $Limit)
            $this->Offset = 0;

         if ($this->Offset == $ActualResponses)
            $this->Offset -= $Limit;
      } else {
         if ($this->Offset == '')
            $this->Offset = 0;
      }

      if ($this->Offset < 0)
         $this->Offset = 0;
      
      
      $LatestItem = $this->Discussion->CountCommentWatch;
      if ($LatestItem === NULL) {
         $LatestItem = 0;
      } elseif ($LatestItem < $this->Discussion->CountComments) {
         $LatestItem += 1;
      }
      
      $this->SetData('_LatestItem', $LatestItem);
      
      // Set the canonical url to have the proper page title.
      $this->CanonicalUrl(DiscussionUrl($this->Discussion, PageNumber($this->Offset, $Limit, 0, FALSE)));
      
//      Url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::Url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::Session()->UserID != 0)), TRUE), Gdn::Session()->UserID == 0);
      
      // Load the comments
      $this->SetData('Comments', $this->CommentModel->Get($DiscussionID, $Limit, $this->Offset));
      
      $PageNumber = PageNumber($this->Offset, $Limit);
      $this->SetData('Page', $PageNumber);
      $this->_SetOpenGraph();
      
      
      include_once(PATH_LIBRARY.'/vendors/simplehtmldom/simple_html_dom.php');
      if ($PageNumber == 1) {
         $this->Description(SliceParagraph(Gdn_Format::PlainText($this->Discussion->Body, $this->Discussion->Format), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::To($this->Discussion->Body, $this->Discussion->Format));
      } else {
         $this->Data['Title'] .= sprintf(T(' - Page %s'), PageNumber($this->Offset, $Limit));
         
         $FirstComment = $this->Data('Comments')->FirstRow();
         $FirstBody = GetValue('Body', $FirstComment);
         $FirstFormat = GetValue('Format', $FirstComment);
         $this->Description(SliceParagraph(Gdn_Format::PlainText($FirstBody, $FirstFormat), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::To($FirstBody, $FirstFormat));
      }

      if ($Dom) {
         foreach($Dom->find('img') as $img) {
            if (isset($img->src))
               $this->Image($img->src);
         }
      }
      
      // Queue notification.
      if ($this->Request->Get('new') && C('Vanilla.QueueNotifications')) {
         $this->AddDefinition('NotifyNewDiscussion', 1);
      }
         
      // Make sure to set the user's discussion watch records
      $this->CommentModel->SetWatch($this->Discussion, $Limit, $this->Offset, $this->Discussion->CountComments);

      // Build a pager
      $PagerFactory = new Gdn_PagerFactory();
		$this->EventArguments['PagerType'] = 'Pager';
		$this->FireEvent('BeforeBuildPager');
      $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
      $this->Pager->ClientID = 'Pager';
         
      $this->Pager->Configure(
         $this->Offset,
         $Limit,
         $ActualResponses,
         array('DiscussionUrl')
      );
      $this->Pager->Record = $this->Discussion;
      PagerModule::Current($this->Pager);
      $this->FireEvent('AfterBuildPager');
      
      // Define the form for the comment input
      $this->Form = Gdn::Factory('Form', 'Comment');
      $this->Form->Action = Url('/vanilla/post/comment/');
      $this->DiscussionID = $this->Discussion->DiscussionID;
      $this->Form->AddHidden('DiscussionID', $this->DiscussionID);
      $this->Form->AddHidden('CommentID', '');

      // Look in the session stash for a comment
      $StashComment = $Session->Stash('CommentForDiscussionID_'.$this->Discussion->DiscussionID, '', FALSE);
      if ($StashComment)
         $this->Form->SetFormValue('Body', $StashComment);
         
      // Retrieve & apply the draft if there is one:
      if (Gdn::Session()->UserID) {
         $DraftModel = new DraftModel();
         $Draft = $DraftModel->Get($Session->UserID, 0, 1, $this->Discussion->DiscussionID)->FirstRow();
         $this->Form->AddHidden('DraftID', $Draft ? $Draft->DraftID : '');
         if ($Draft && !$this->Form->IsPostBack()) {
            $this->Form->SetValue('Body', $Draft->Body);
            $this->Form->SetValue('Format', $Draft->Format);
         }
      }
      
      // Deliver JSON data if necessary
      if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'comments';
      }
      
		// Inform moderator of checked comments in this discussion
		$CheckedComments = $Session->GetAttribute('CheckedComments', array());
		if (count($CheckedComments) > 0)
			ModerationController::InformCheckedComments($this);

      // Add modules
      $this->AddModule('DiscussionFilterModule');
      $this->AddModule('NewDiscussionModule');
      $this->AddModule('CategoriesModule');
      $this->AddModule('BookmarkedModule');
      
		$this->CanEditComments = Gdn::Session()->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', 'any') && C('Vanilla.AdminCheckboxes.Use');

      // Report the discussion id so js can use it.      
      $this->AddDefinition('DiscussionID', $DiscussionID);
      
      $this->FireEvent('BeforeDiscussionRender');
      $this->Render();
   }
660472
public function render_assign_submit_for_grading_page($page) {
        $o = '';

        $o .= $this->output->container_start('submitforgrading');
        $o .= $this->output->heading(get_string('confirmsubmissionheading', 'assign'), 3);

        $cancelurl = new moodle_url('/mod/assign/view.php', array('id' => $page->coursemoduleid));
        if (count($page->notifications)) {
            // At least one of the submission plugins is not ready for submission.

            $o .= $this->output->heading(get_string('submissionnotready', 'assign'), 4);

            foreach ($page->notifications as $notification) {
                $o .= $this->output->notification($notification);
            }

            $o .= $this->output->continue_button($cancelurl);
        } else {
            // All submission plugins ready - show the confirmation form.
            $o .= $this->moodleform($page->confirmform);
        }
        $o .= $this->output->container_end();

        return $o;
    }
1300329
public function editReview($review_id = null)
    {
        $this->setReview($review_id);
        $this->setTitleEditReview();
        $this->setBreadcrumbEditReview();

        $this->setData('review', $this->data_review);

        $this->submitEditReview();
        $this->setDataUserEditReview();
        $this->setDataProductEditReview();
        $this->outputEditReview();
    }