本文整理汇总了PHP中lesson_page::load方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson_page::load方法的具体用法?PHP lesson_page::load怎么用?PHP lesson_page::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lesson_page
的用法示例。
在下文中一共展示了lesson_page::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates a new lesson_page within the database and returns the correct pagetype
* object to use to interact with the new lesson
*
* @final
* @static
* @param object $properties
* @param lesson $lesson
* @return lesson_page Specialised object that extends lesson_page
*/
public static final function create($properties, lesson $lesson, $context, $maxbytes)
{
global $DB;
$newpage = new stdClass();
$newpage->title = $properties->title;
$newpage->contents = $properties->contents_editor['text'];
$newpage->contentsformat = $properties->contents_editor['format'];
$newpage->lessonid = $lesson->id;
$newpage->timecreated = time();
$newpage->qtype = $properties->qtype;
$newpage->qoption = isset($properties->qoption) ? 1 : 0;
$newpage->layout = isset($properties->layout) ? 1 : 0;
$newpage->display = isset($properties->display) ? 1 : 0;
$newpage->prevpageid = 0;
// this is a first page
$newpage->nextpageid = 0;
// this is the only page
if ($properties->pageid) {
$prevpage = $DB->get_record("lesson_pages", array("id" => $properties->pageid), 'id, nextpageid');
if (!$prevpage) {
print_error('cannotfindpages', 'lesson');
}
$newpage->prevpageid = $prevpage->id;
$newpage->nextpageid = $prevpage->nextpageid;
} else {
$nextpage = $DB->get_record('lesson_pages', array('lessonid' => $lesson->id, 'prevpageid' => 0), 'id');
if ($nextpage) {
// This is the first page, there are existing pages put this at the start
$newpage->nextpageid = $nextpage->id;
}
}
$newpage->id = $DB->insert_record("lesson_pages", $newpage);
$editor = new stdClass();
$editor->id = $newpage->id;
$editor->contents_editor = $properties->contents_editor;
$editor = file_postupdate_standard_editor($editor, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes), $context, 'mod_lesson', 'page_contents', $editor->id);
$DB->update_record("lesson_pages", $editor);
if ($newpage->prevpageid > 0) {
$DB->set_field("lesson_pages", "nextpageid", $newpage->id, array("id" => $newpage->prevpageid));
}
if ($newpage->nextpageid > 0) {
$DB->set_field("lesson_pages", "prevpageid", $newpage->id, array("id" => $newpage->nextpageid));
}
$page = lesson_page::load($newpage, $lesson);
$page->create_answers($properties);
$lesson->add_message(get_string('insertedpage', 'lesson') . ': ' . format_string($newpage->title, true), 'notifysuccess');
return $page;
}
示例2: optional_param
$edit = optional_param('edit', false, PARAM_BOOL);
$returnto = optional_param('returnto', null, PARAM_URL);
if (empty($returnto)) {
$returnto = new moodle_url('/mod/lesson/edit.php', array('id' => $id));
$returnto->set_anchor('lesson-' . $pageid);
}
$cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:edit', $context);
$PAGE->set_url('/mod/lesson/editpage.php', array('pageid' => $pageid, 'id' => $id, 'qtype' => $qtype));
$PAGE->set_pagelayout('admin');
if ($edit) {
$editpage = lesson_page::load($pageid, $lesson);
$qtype = $editpage->qtype;
$edit = true;
} else {
$edit = false;
}
$jumpto = lesson_page::get_jumptooptions($pageid, $lesson);
$manager = lesson_page_type_manager::get($lesson);
$editoroptions = array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes);
// If the previous page was the Question type selection form, this form
// will have a different name (e.g. _qf__lesson_add_page_form_selection
// versus _qf__lesson_add_page_form_multichoice). This causes confusion
// in moodleform::_process_submission because the array key check doesn't
// tie up with the current form name, which in turn means the "submitted"
// check ends up evaluating as false, thus it's not possible to check whether
// the Question type selection was cancelled. For this reason, a dummy form