Prepares and shows the course page
432361
def show_page(self, course):
        
        username = self.user_manager.session_username()
        if not self.user_manager.course_is_open_to_user(course, lti=False):
            return self.template_helper.get_renderer().course_unavailable()
        else:
            tasks = course.get_tasks()
            last_submissions = self.submission_manager.get_user_last_submissions(5, {"courseid": course.get_id(), "taskid": {"$in": list(tasks.keys())}})

            for submission in last_submissions:
                    submission["taskname"] = tasks[submission['taskid']].get_name(self.user_manager.session_language())

            tasks_data = {}
            user_tasks = self.database.user_tasks.find({"username": username, "courseid": course.get_id(), "taskid": {"$in": list(tasks.keys())}})
            is_admin = self.user_manager.has_staff_rights_on_course(course, username)

            tasks_score = [0.0, 0.0]

            for taskid, task in tasks.items():
                tasks_data[taskid] = {"visible": task.get_accessible_time().after_start() or is_admin, "succeeded": False,
                                      "grade": 0.0}
                tasks_score[1] += task.get_grading_weight() if tasks_data[taskid]["visible"] else 0

            for user_task in user_tasks:
                tasks_data[user_task["taskid"]]["succeeded"] = user_task["succeeded"]
                tasks_data[user_task["taskid"]]["grade"] = user_task["grade"]

                weighted_score = user_task["grade"]*tasks[user_task["taskid"]].get_grading_weight()
                tasks_score[0] += weighted_score if tasks_data[user_task["taskid"]]["visible"] else 0

            course_grade = round(tasks_score[0]/tasks_score[1]) if tasks_score[1] > 0 else 0
            tag_list = course.get_all_tags_names_as_list(is_admin, self.user_manager.session_language())
            user_info = self.database.users.find_one({"username": username})

            return self.template_helper.get_renderer().course(user_info, course, last_submissions, tasks, tasks_data, course_grade, tag_list)
681002
def page(self, course, task, submission):
        
        submission = self.submission_manager.get_input_from_submission(submission)
        submission = self.submission_manager.get_feedback_from_submission(
            submission,
            show_everything=True,
            translation=self.app._translations.get(self.user_manager.session_language(), gettext.NullTranslations())
        )

        to_display = {
            problem.get_id(): {
                "id": problem.get_id(),
                "name": problem.get_name(self.user_manager.session_language()),
                "defined": True
            } for problem in task.get_problems()
        }

        to_display.update({
            pid: {
                "id": pid,
                "name": pid,
                "defined": False
            } for pid in (set(submission["input"]) - set(to_display))
        })

        return self.template_helper.get_renderer().course_admin.submission(course, task, submission, to_display.values())
359126
function init() {
		$_option = 'pressbooks_theme_options_' . $this->getSlug();
		$_page = $_option;
		$_section = $this->getSlug() . '_options_section';

		if ( false === get_option( $_option ) ) {
			add_option( $_option, $this->defaults );
		}

		$custom_styles = Container::get( 'Styles' );
		$v2_compatible = $custom_styles->isCurrentThemeCompatible( 2 );

		add_settings_section(
			$_section,
			$this->getTitle(),
			[ $this, 'display' ],
			$_page
		);

		add_settings_field(
			'chapter_numbers',
			__( 'Part and Chapter Numbers', 'pressbooks' ),
			[ $this, 'renderChapterNumbersField' ],
			$_page,
			$_section,
			[
				__( 'Display part and chapter numbers', 'pressbooks' ),
			]
		);

		add_settings_field(
			'part_label',
			__( 'Part Label', 'pressbooks' ),
			[ $this, 'renderPartLabelField' ],
			$_page,
			$_section,
			[
				__( 'The "part" label is used in the table of contents and in part titles in your webbook and exports.', 'pressbooks' ),
				'label_for' => 'part_label',
			]
		);

		add_settings_field(
			'chapter_label',
			__( 'Chapter Label', 'pressbooks' ),
			[ $this, 'renderChapterLabelField' ],
			$_page,
			$_section,
			[
				__( 'The "chapter" label is used in the table of contents and in chapter titles in your webbook and exports.', 'pressbooks' ),
				'label_for' => 'chapter_label',
			]
		);

		add_settings_field(
			'parse_subsections',
			__( 'Two-Level TOC', 'pressbooks' ),
			[ $this, 'renderTwoLevelTOCField' ],
			$_page,
			$_section,
			[
				__( 'Enable two-level table of contents (displays headings under chapter titles)', 'pressbooks' ),
			]
		);

		add_settings_field(
			'attachment_attributions',
			__( 'Media Attributions', 'pressbooks' ),
			[ $this, 'renderAttachmentAttributionsField' ],
			$_page,
			$_section,
			[
				__( 'Display attributions at the end of a chapter', 'pressbooks' ),
			]
		);

		if ( Container::get( 'Styles' )->isCurrentThemeCompatible( 1 ) === true || Container::get( 'Styles' )->isCurrentThemeCompatible( 2 ) === true ) { // we can only enable foreign language typography for themes that use SCSS

			add_settings_field(
				'pressbooks_global_typography',
				__( 'Language & Script Support', 'pressbooks' ),
				[ $this, 'renderLanguagesField' ],
				$_page,
				$_section,
				[
					__( 'Include fonts to support the following languages and scripts:', 'pressbooks' ),
				]
			);

			register_setting(
				$_page,
				'pressbooks_global_typography',
				[ $this, 'sanitizeLanguages' ]
			);

		}

		add_settings_field(
			'copyright_license',
			__( 'Chapter Licenses', 'pressbooks' ),
			[ $this, 'renderCopyrightLicenseField' ],
			$_page,
			$_section,
			[
				0 => __( 'Do not display section level copyright license', 'pressbooks' ),
				1 => __( 'Display section level license on table of contents in export formats', 'pressbooks' ),
				2 => __( 'Display section level license at end of chapter in export formats', 'pressbooks' ),
			]
		);

		if ( $v2_compatible ) {
			foreach ( [
				'examples' => __( 'Examples', 'pressbooks' ),
				'exercises' => __( 'Exercises', 'pressbooks' ),
				'takeaways' => __( 'Key Takeaways', 'pressbooks' ),
				'objectives' => __( 'Learning Objectives', 'pressbooks' ),
			] as $key => $label ) {
				add_settings_field(
					"edu_textbox_{$key}_section",
					sprintf( '<span style="font-size:1.3em;">%s</span>', $label ),
					[ $this, 'renderTextboxHeader' ],
					$_page,
					$_section,
					[
						sprintf( __( 'Customize colors for %s textboxes using the fields below.', 'pressbooks' ), $label ),
					]
				);

				add_settings_field(
					"edu_textbox_{$key}_header_color",
					sprintf( '<span class="screen-reader-text">%1$s </span>%2$s', $label, __( 'Header Color', 'pressbooks' ) ),
					[ $this, 'renderTextboxColorField' ],
					$_page,
					$_section,
					[
						'key' => "edu_textbox_{$key}_header_color",
						'description' => sprintf( __( 'The header text color for a %s textbox.', 'pressbooks' ), $label ),
					]
				);
				add_settings_field(
					"edu_textbox_{$key}_header_background",
					sprintf( '<span class="screen-reader-text">%1$s </span>%2$s', $label, __( 'Header Background', 'pressbooks' ) ),
					[ $this, 'renderTextboxColorField' ],
					$_page,
					$_section,
					[
						'key' => "edu_textbox_{$key}_header_background",
						'description' => sprintf( __( 'The header background color for a %s textbox.', 'pressbooks' ), $label ),
					]
				);
				add_settings_field(
					"edu_textbox_{$key}_background",
					sprintf( '<span class="screen-reader-text">%1$s </span>%2$s', $label, __( 'Background', 'pressbooks' ) ),
					[ $this, 'renderTextboxColorField' ],
					$_page,
					$_section,
					[
						'key' => "edu_textbox_{$key}_background",
						'description' => sprintf( __( 'The background color for a %s textbox.', 'pressbooks' ), $label ),
					]
				);
			}
		}

		/**
		 * Add custom settings fields.
		 *
		 * @since 3.9.7
		 *
		 * @param string $arg1
		 * @param string $arg2
		 */
		do_action( 'pb_theme_options_global_add_settings_fields', $_page, $_section );

		register_setting(
			$_page,
			$_option,
			[ $this, 'sanitize' ]
		);
	}
33023
function prepareDOM() {
        var i, pageNum,
            zoomLevel, maxZoom,
            ptWidth, ptHeight,
            pxWidth, pxHeight,
            pt2px = util.calculatePtSize(),
            dimensions = config.metadata.dimensions,
            skeleton = '';

        // adjust page scale if the pages are too small/big
        // it's adjusted so 100% == DOCUMENT_100_PERCENT_WIDTH px;
        config.pageScale = DOCUMENT_100_PERCENT_WIDTH / (dimensions.width * pt2px);

        // add zoom levels to accomodate the scale
        zoomLevel = config.zoomLevels[config.zoomLevels.length - 1];
        maxZoom = 3 / config.pageScale;
        while (zoomLevel < maxZoom) {
            zoomLevel += zoomLevel / 2;
            config.zoomLevels.push(zoomLevel);
        }

        dimensions.exceptions = dimensions.exceptions || {};

        // create skeleton
        for (i = config.pageStart - 1; i < config.pageEnd; i++) {
            pageNum = i + 1;
            if (pageNum in dimensions.exceptions) {
                ptWidth = dimensions.exceptions[pageNum].width;
                ptHeight = dimensions.exceptions[pageNum].height;
            } else {
                ptWidth = dimensions.width;
                ptHeight = dimensions.height;
            }
            pxWidth = ptWidth * pt2px;
            pxHeight = ptHeight * pt2px;
            pxWidth *= config.pageScale;
            pxHeight *= config.pageScale;
            skeleton += util.template(Crocodoc.pageTemplate, {
                w: pxWidth,
                h: pxHeight
            });
        }

        // insert skeleton and keep a reference to the jq object
        config.$pages = $(skeleton).appendTo(config.$doc);
    }
889417
protected function _preparePage()
    {
        parent::_preparePage();
        $this->getColumnSet()->getChildBlock('store_id')->setFilterConditionCallback([$this, 'filterStoreCondition']);
        $this->getColumnSet()->getChildBlock('thesaurus_terms_summary')->setFilterConditionCallback([$this, 'filterTermsCondition']);
    }
591980
def is_sequence_start_page(self, url):
        
        return (
            len(url.path.segments) == 6 and
            url.path.segments[0] == 'courses' and
            url.path.segments[2] == 'courseware' and
            url.path.segments[5] == '1'
        )
423642
def page(self, course):
        
        if not self.webdav_host:
            raise web.notfound()

        url = self.webdav_host + "/" + course.get_id()
        username = self.user_manager.session_username()
        apikey = self.user_manager.session_api_key()
        return self.template_helper.get_renderer().course_admin.webdav(course, url, username, apikey)
415886
def POST(self):  # pylint: disable=arguments-differ
        
        if not self.app.welcome_page:
            raise web.seeother("/courselist")
        return self.show_page(self.app.welcome_page)
813700
def course_menu(course, template_helper):
    
    scoreboards = course.get_descriptor().get('scoreboard', [])

    if scoreboards != []:
        return str(template_helper.get_custom_renderer('frontend/plugins/scoreboard', layout=False).course_menu(course))
    else:
        return None
632081
public function display_edit_full(lesson $lesson, $pageid, $prevpageid, $single=false) {
        global $DB, $CFG;

        $manager = lesson_page_type_manager::get($lesson);
        $qtypes = $manager->get_page_type_strings();
        $npages = count($lesson->load_all_pages());
        $canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id));

        $content = '';
        if ($canedit) {
            $content = $this->add_page_links($lesson, $prevpageid);
        }

        $options = new stdClass;
        $options->noclean = true;

        while ($pageid != 0 && $single!=='stop') {
            $page = $lesson->load_page($pageid);

            $pagetable = new html_table();
            $pagetable->align = array('right','left');
            $pagetable->width = '100%';
            $pagetable->tablealign = 'center';
            $pagetable->cellspacing = 0;
            $pagetable->cellpadding = '5px';
            $pagetable->data = array();

            $pageheading = new html_table_cell();

            $pageheading->text = html_writer::tag('a', '', array('id' => 'lesson-' . $pageid)) . format_string($page->title);
            if ($canedit) {
                $pageheading->text .= ' '.$this->page_action_links($page, $npages);
            }
            $pageheading->style = 'text-align:center';
            $pageheading->colspan = 2;
            $pageheading->scope = 'col';
            $pagetable->head = array($pageheading);

            $cell = new html_table_cell();
            $cell->colspan = 2;
            $cell->style = 'text-align:left';
            $cell->text = $page->contents;
            $pagetable->data[] = new html_table_row(array($cell));

            $cell = new html_table_cell();
            $cell->colspan = 2;
            $cell->style = 'text-align:center';
            $cell->text = '<strong>'.$qtypes[$page->qtype] . $page->option_description_string().'</strong>';
            $pagetable->data[] = new html_table_row(array($cell));

            $pagetable = $page->display_answers($pagetable);

            $content .= html_writer::start_tag('div');
            $content .= html_writer::table($pagetable);
            $content .= html_writer::end_tag('div');

            if ($canedit) {
                $content .= $this->add_page_links($lesson, $pageid);
            }

            // check the prev links - fix (silently) if necessary - there was a bug in
            // versions 1 and 2 when add new pages. Not serious then as the backwards
            // links were not used in those versions
            if ($page->prevpageid != $prevpageid) {
                // fix it
                $DB->set_field("lesson_pages", "prevpageid", $prevpageid, array("id" => $page->id));
                debugging("<p>***prevpageid of page $page->id set to $prevpageid***");
            }

            $prevpageid = $page->id;
            $pageid = $page->nextpageid;

            if ($single === true) {
                $single = 'stop';
            }

        }

        return $this->output->box($content, 'edit_pages_box');
    }
1055116
def show
      @question_sheet = @answer_sheet.question_sheet
      pf = Qe.table_name_prefix
      @elements = @question_sheet.pages.collect {|p| p.elements.includes(:pages).order("#{pf}pages.number,#{pf}page_elements.position").all}.flatten
      @elements = QuestionSet.new(@elements, @answer_sheet).elements.group_by{ |e| e.pages.first }
    end
657314
def content(options = {}, &block)
      config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block)
    end
36478
def __get_course_html(self):
        
        self._headers['Referer'] = 'http://jwc.wyu.edu.cn/student/menu.asp'
        r = requests.get('http://jwc.wyu.edu.cn/student/f3.asp', headers=self._headers, cookies=self._cookies)
        return r.content.decode(_.get_charset(r.content))
72716
def preload_pages():
    """"""
    try:
        _add_url_rule([page.url for page in Page.query.all()])
    except Exception:  # pragma: no cover
        current_app.logger.warn('Pages were not loaded.')
        raise
109809
function ezNewPage()
    {
        $pageRequired = 1;
        if ( isset( $this->ez['columns'] ) && $this->ez['columns']['on'] == 1 )
        {
            // check if this is just going to a new column
            // increment the column number

            $this->ez['columns']['colNum']++;
            if ( $this->ez['columns']['colNum'] <= $this->ez['columns']['options']['num'] )
            {
                // then just reset to the top of the next column
                $pageRequired=0;
            }
            else
            {
                $this->ez['columns']['colNum'] = 1;
                $this->ez['topMargin'] = $this->ez['columns']['margins'][2];
            }

            $width = $this->ez['columns']['width'];
            $this->ez['leftMargin'] = $this->ez['columns']['margins'][0] + ( $this->ez['columns']['colNum'] - 1 ) * ( $this->ez['columns']['options']['gap'] + $width );
            $this->ez['rightMargin'] = $this->ez['pageWidth'] - $this->ez['leftMargin'] - $width;
        }

        if ( $pageRequired )
        {
            // make a new page, setting the writing point back to the top
            $this->y = $this->ez['pageHeight']-$this->ez['topMargin'] - $this->getFontHeight();
            $this->ez['xOffset'] = 0;
            // make the new page with a call to the basic class.
            $this->ezPageCount++;
            if ( isset( $this->ez['insertMode'] ) && $this->ez['insertMode'] == 1 )
            {
                $id = $this->ezPages[$this->ezPageCount] = $this->newPage( 1, $this->ez['insertOptions']['id'], $this->ez['insertOptions']['pos'] );
                // then manipulate the insert options so that inserted pages follow each other
                $this->ez['insertOptions']['id'] = $id;
                $this->ez['insertOptions']['pos'] = 'after';
            }
            else
            {
                $this->ezPages[$this->ezPageCount] = $this->newPage();
            }
        }
        else
        {
            $this->y = $this->ez['pageHeight']-$this->ez['topMargin'] - $this->getFontHeight();
            $this->ez['xOffset'] = 0;
        }
        $this->RightMarginArray = array();
        $this->LeftMarginArray = array();
    }
856385
protected function prepareDocument()
	{
		$app   = JFactory::getApplication();
		$menus = $app->getMenu();

		// Because the application sets a default page title, we need to get it from the menu item itself
		$menu = $menus->getActive();

		if ($menu)
		{
			$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
		}
		else
		{
			$this->params->def('page_heading', JText::_($this->pageHeading));
		}

		$title = $this->params->get('page_title', '');

		if (empty($title))
		{
			$title = $app->get('sitename');
		}
		elseif ($app->get('sitename_pagetitles', 0) == 1)
		{
			$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
		}
		elseif ($app->get('sitename_pagetitles', 0) == 2)
		{
			$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
		}

		$this->document->setTitle($title);

		if ($this->params->get('menu-meta_description'))
		{
			$this->document->setDescription($this->params->get('menu-meta_description'));
		}

		if ($this->params->get('menu-meta_keywords'))
		{
			$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
		}

		if ($this->params->get('robots'))
		{
			$this->document->setMetadata('robots', $this->params->get('robots'));
		}
	}
383637
protected function section_edit_control_items($course, $section, $onsectionpage = false) {
        global $PAGE;

        if (!$PAGE->user_is_editing()) {
            return array();
        }

        $sectionreturn = $onsectionpage ? $section->section : null;

        $coursecontext = context_course::instance($course->id);
        $numsections = course_get_format($course)->get_last_section_number();
        $isstealth = $section->section > $numsections;

        $baseurl = course_get_url($course, $sectionreturn);
        $baseurl->param('sesskey', sesskey());

        $controls = array();

        if (!$isstealth && has_capability('moodle/course:update', $coursecontext)) {
            if ($section->section > 0
                && get_string_manager()->string_exists('editsection', 'format_'.$course->format)) {
                $streditsection = get_string('editsection', 'format_'.$course->format);
            } else {
                $streditsection = get_string('editsection');
            }

            $controls['edit'] = array(
                'url'   => new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $sectionreturn)),
                'icon' => 'i/settings',
                'name' => $streditsection,
                'pixattr' => array('class' => ''),
                'attr' => array('class' => 'icon edit'));
        }

        if ($section->section) {
            $url = clone($baseurl);
            if (!$isstealth) {
                if (has_capability('moodle/course:sectionvisibility', $coursecontext)) {
                    if ($section->visible) { // Show the hide/show eye.
                        $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
                        $url->param('hide', $section->section);
                        $controls['visiblity'] = array(
                            'url' => $url,
                            'icon' => 'i/hide',
                            'name' => $strhidefromothers,
                            'pixattr' => array('class' => ''),
                            'attr' => array('class' => 'icon editing_showhide',
                                'data-sectionreturn' => $sectionreturn, 'data-action' => 'hide'));
                    } else {
                        $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
                        $url->param('show',  $section->section);
                        $controls['visiblity'] = array(
                            'url' => $url,
                            'icon' => 'i/show',
                            'name' => $strshowfromothers,
                            'pixattr' => array('class' => ''),
                            'attr' => array('class' => 'icon editing_showhide',
                                'data-sectionreturn' => $sectionreturn, 'data-action' => 'show'));
                    }
                }

                if (!$onsectionpage) {
                    if (has_capability('moodle/course:movesections', $coursecontext)) {
                        $url = clone($baseurl);
                        if ($section->section > 1) { // Add a arrow to move section up.
                            $url->param('section', $section->section);
                            $url->param('move', -1);
                            $strmoveup = get_string('moveup');
                            $controls['moveup'] = array(
                                'url' => $url,
                                'icon' => 'i/up',
                                'name' => $strmoveup,
                                'pixattr' => array('class' => ''),
                                'attr' => array('class' => 'icon moveup'));
                        }

                        $url = clone($baseurl);
                        if ($section->section < $numsections) { // Add a arrow to move section down.
                            $url->param('section', $section->section);
                            $url->param('move', 1);
                            $strmovedown = get_string('movedown');
                            $controls['movedown'] = array(
                                'url' => $url,
                                'icon' => 'i/down',
                                'name' => $strmovedown,
                                'pixattr' => array('class' => ''),
                                'attr' => array('class' => 'icon movedown'));
                        }
                    }
                }
            }

            if (course_can_delete_section($course, $section)) {
                if (get_string_manager()->string_exists('deletesection', 'format_'.$course->format)) {
                    $strdelete = get_string('deletesection', 'format_'.$course->format);
                } else {
                    $strdelete = get_string('deletesection');
                }
                $url = new moodle_url('/course/editsection.php', array(
                    'id' => $section->id,
                    'sr' => $sectionreturn,
                    'delete' => 1,
                    'sesskey' => sesskey()));
                $controls['delete'] = array(
                    'url' => $url,
                    'icon' => 'i/delete',
                    'name' => $strdelete,
                    'pixattr' => array('class' => ''),
                    'attr' => array('class' => 'icon editing_delete'));
            }
        }

        return $controls;
    }