本文整理汇总了PHP中lesson_page_type_manager类的典型用法代码示例。如果您正苦于以下问题:PHP lesson_page_type_manager类的具体用法?PHP lesson_page_type_manager怎么用?PHP lesson_page_type_manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了lesson_page_type_manager类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Retrieves the lesson page type manager object
*
* If the object hasn't yet been created it is created here.
*
* @staticvar lesson_page_type_manager $pagetypemanager
* @param lesson $lesson
* @return lesson_page_type_manager
*/
public static function get(lesson $lesson)
{
static $pagetypemanager;
if (!$pagetypemanager instanceof lesson_page_type_manager) {
$pagetypemanager = new lesson_page_type_manager();
$pagetypemanager->load_lesson_types($lesson);
}
return $pagetypemanager;
}
开发者ID:nikitskynikita,项目名称:moodle,代码行数:18,代码来源:locallib.php
示例2: page_action_links
/**
* Returns HTML to display action links for a page
*
* @param lesson_page $page
* @param bool $printmove
* @param bool $printaddpage
* @return string
*/
public function page_action_links(lesson_page $page, $printmove, $printaddpage = false)
{
global $CFG;
$actions = array();
if ($printmove) {
$printmovehtml = new moodle_url('/mod/lesson/lesson.php', array('id' => $this->page->cm->id, 'action' => 'move', 'pageid' => $page->id, 'sesskey' => sesskey()));
$actions[] = html_writer::link($printmovehtml, '<img src="' . $this->output->pix_url('t/move') . '" class="iconsmall" alt="' . get_string('move') . '" />');
}
$url = new moodle_url('/mod/lesson/editpage.php', array('id' => $this->page->cm->id, 'pageid' => $page->id, 'edit' => 1));
$actions[] = html_writer::link($url, '<img src="' . $this->output->pix_url('t/edit') . '" class="iconsmall" alt="' . get_string('update') . '" />');
$url = new moodle_url('/mod/lesson/view.php', array('id' => $this->page->cm->id, 'pageid' => $page->id));
$actions[] = html_writer::link($url, '<img src="' . $this->output->pix_url('t/preview') . '" class="iconsmall" alt="' . get_string('preview') . '" />');
$url = new moodle_url('/mod/lesson/lesson.php', array('id' => $this->page->cm->id, 'action' => 'confirmdelete', 'pageid' => $page->id, 'sesskey' => sesskey()));
$actions[] = html_writer::link($url, '<img src="' . $this->output->pix_url('t/delete') . '" class="iconsmall" alt="' . get_string('delete') . '" />');
if ($printaddpage) {
$options = array();
$manager = lesson_page_type_manager::get($page->lesson);
$links = $manager->get_add_page_type_links($page->id);
foreach ($links as $link) {
$options[$link['type']] = $link['name'];
}
$options[0] = get_string('question', 'lesson');
$addpageurl = new moodle_url('/mod/lesson/editpage.php', array('id' => $this->page->cm->id, 'pageid' => $page->id, 'sesskey' => sesskey()));
$addpageselect = new single_select($addpageurl, 'qtype', $options, null, array('' => get_string('addanewpage', 'lesson') . '...'), 'addpageafter' . $page->id);
$addpageselector = $this->output->render($addpageselect);
}
if (isset($addpageselector)) {
$actions[] = $addpageselector;
}
return implode(' ', $actions);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:39,代码来源:renderer.php
示例3: array
$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
// is created here solely to check whether the selection was cancelled.
if ($qtype) {
$mformdummy = $manager->get_page_form(0, array('editoroptions' => $editoroptions, 'jumpto' => $jumpto, 'lesson' => $lesson, 'edit' => $edit, 'maxbytes' => $PAGE->course->maxbytes, 'returnto' => $returnto));
if ($mformdummy->is_cancelled()) {
redirect($returnto);
exit;
}
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:editpage.php
示例4: __construct
public function __construct($arg1, $arg2)
{
$this->manager = lesson_page_type_manager::get($arg2['lesson']);
parent::__construct($arg1, $arg2);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:5,代码来源:editpage_form.php
示例5: lesson_save_question_options
/**
* Given some question info and some data about the the answers
* this function parses, organises and saves the question
*
* This is only used when IMPORTING questions and is only called
* from format.php
* Lifted from mod/quiz/lib.php -
* 1. all reference to oldanswers removed
* 2. all reference to quiz_multichoice table removed
* 3. In SHORTANSWER questions usecase is store in the qoption field
* 4. In NUMERIC questions store the range as two answers
* 5. TRUEFALSE options are ignored
* 6. For MULTICHOICE questions with more than one answer the qoption field is true
*
* @param opject $question Contains question data like question, type and answers.
* @return object Returns $result->error or $result->notice.
**/
function lesson_save_question_options($question, $lesson) {
global $DB;
// These lines are required to ensure that all page types have
// been loaded for the following switch
if (!($lesson instanceof lesson)) {
$lesson = new lesson($lesson);
}
$manager = lesson_page_type_manager::get($lesson);
$timenow = time();
$result = new stdClass();
switch ($question->qtype) {
case LESSON_PAGE_SHORTANSWER:
$answers = array();
$maxfraction = -1;
// Insert all the new answers
foreach ($question->answer as $key => $dataanswer) {
if ($dataanswer != "") {
$answer = new stdClass;
$answer->lessonid = $question->lessonid;
$answer->pageid = $question->id;
if ($question->fraction[$key] >=0.5) {
$answer->jumpto = LESSON_NEXTPAGE;
}
$answer->timecreated = $timenow;
$answer->grade = $question->fraction[$key] * 100;
$answer->answer = $dataanswer;
$answer->response = $question->feedback[$key];
$answer->id = $DB->insert_record("lesson_answers", $answer);
$answers[] = $answer->id;
if ($question->fraction[$key] > $maxfraction) {
$maxfraction = $question->fraction[$key];
}
}
}
/// Perform sanity checks on fractional grades
if ($maxfraction != 1) {
$maxfraction = $maxfraction * 100;
$result->notice = get_string("fractionsnomax", "quiz", $maxfraction);
return $result;
}
break;
case LESSON_PAGE_NUMERICAL: // Note similarities to SHORTANSWER
$answers = array();
$maxfraction = -1;
// for each answer store the pair of min and max values even if they are the same
foreach ($question->answer as $key => $dataanswer) {
if ($dataanswer != "") {
$answer = new stdClass;
$answer->lessonid = $question->lessonid;
$answer->pageid = $question->id;
$answer->jumpto = LESSON_NEXTPAGE;
$answer->timecreated = $timenow;
$answer->grade = $question->fraction[$key] * 100;
$min = $question->answer[$key] - $question->tolerance[$key];
$max = $question->answer[$key] + $question->tolerance[$key];
$answer->answer = $min.":".$max;
// $answer->answer = $question->min[$key].":".$question->max[$key]; original line for min/max
$answer->response = $question->feedback[$key];
$answer->id = $DB->insert_record("lesson_answers", $answer);
$answers[] = $answer->id;
if ($question->fraction[$key] > $maxfraction) {
$maxfraction = $question->fraction[$key];
}
}
}
/// Perform sanity checks on fractional grades
if ($maxfraction != 1) {
$maxfraction = $maxfraction * 100;
$result->notice = get_string("fractionsnomax", "quiz", $maxfraction);
return $result;
}
//.........这里部分代码省略.........
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:format.php
示例6: lesson_save_question_options
/**
* Given some question info and some data about the the answers
* this function parses, organises and saves the question
*
* This is only used when IMPORTING questions and is only called
* from format.php
* Lifted from mod/quiz/lib.php -
* 1. all reference to oldanswers removed
* 2. all reference to quiz_multichoice table removed
* 3. In shortanswer questions usecase is store in the qoption field
* 4. In numeric questions store the range as two answers
* 5. truefalse options are ignored
* 6. For multichoice questions with more than one answer the qoption field is true
*
* @param object $question Contains question data like question, type and answers.
* @param object $lesson
* @param int $contextid
* @return object Returns $result->error or $result->notice.
**/
function lesson_save_question_options($question, $lesson, $contextid)
{
global $DB;
// These lines are required to ensure that all page types have
// been loaded for the following switch
if (!$lesson instanceof lesson) {
$lesson = new lesson($lesson);
}
$manager = lesson_page_type_manager::get($lesson);
$timenow = time();
$result = new stdClass();
// Default answer to avoid code duplication.
$defaultanswer = new stdClass();
$defaultanswer->lessonid = $question->lessonid;
$defaultanswer->pageid = $question->id;
$defaultanswer->timecreated = $timenow;
$defaultanswer->answerformat = FORMAT_HTML;
$defaultanswer->jumpto = LESSON_THISPAGE;
$defaultanswer->grade = 0;
$defaultanswer->score = 0;
switch ($question->qtype) {
case LESSON_PAGE_SHORTANSWER:
$answers = array();
$maxfraction = -1;
// Insert all the new answers
foreach ($question->answer as $key => $dataanswer) {
if ($dataanswer != "") {
$answer = clone $defaultanswer;
if ($question->fraction[$key] >= 0.5) {
$answer->jumpto = LESSON_NEXTPAGE;
$answer->score = 1;
}
$answer->grade = round($question->fraction[$key] * 100);
$answer->answer = $dataanswer;
$answer->response = $question->feedback[$key]['text'];
$answer->responseformat = $question->feedback[$key]['format'];
$answer->id = $DB->insert_record("lesson_answers", $answer);
lesson_import_question_files('response', $question->feedback[$key], $answer, $contextid);
$answers[] = $answer->id;
if ($question->fraction[$key] > $maxfraction) {
$maxfraction = $question->fraction[$key];
}
}
}
/// Perform sanity checks on fractional grades
if ($maxfraction != 1) {
$maxfraction = $maxfraction * 100;
$result->notice = get_string("fractionsnomax", "lesson", $maxfraction);
return $result;
}
break;
case LESSON_PAGE_NUMERICAL:
// Note similarities to shortanswer.
$answers = array();
$maxfraction = -1;
// for each answer store the pair of min and max values even if they are the same
foreach ($question->answer as $key => $dataanswer) {
if ($dataanswer != "") {
$answer = clone $defaultanswer;
if ($question->fraction[$key] >= 0.5) {
$answer->jumpto = LESSON_NEXTPAGE;
$answer->score = 1;
}
$answer->grade = round($question->fraction[$key] * 100);
$min = $question->answer[$key] - $question->tolerance[$key];
$max = $question->answer[$key] + $question->tolerance[$key];
$answer->answer = $min . ":" . $max;
$answer->response = $question->feedback[$key]['text'];
$answer->responseformat = $question->feedback[$key]['format'];
$answer->id = $DB->insert_record("lesson_answers", $answer);
lesson_import_question_files('response', $question->feedback[$key], $answer, $contextid);
$answers[] = $answer->id;
if ($question->fraction[$key] > $maxfraction) {
$maxfraction = $question->fraction[$key];
}
}
}
/// Perform sanity checks on fractional grades
if ($maxfraction != 1) {
$maxfraction = $maxfraction * 100;
$result->notice = get_string("fractionsnomax", "lesson", $maxfraction);
//.........这里部分代码省略.........
开发者ID:barrysspace,项目名称:moodle,代码行数:101,代码来源:format.php
注:本文中的lesson_page_type_manager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论