当前位置: 首页>>代码示例>>PHP>>正文


PHP lesson_page::create方法代码示例

本文整理汇总了PHP中lesson_page::create方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson_page::create方法的具体用法?PHP lesson_page::create怎么用?PHP lesson_page::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lesson_page的用法示例。


在下文中一共展示了lesson_page::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_content

 public function create_content($lesson, $record = array())
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/mod/lesson/locallib.php';
     $now = time();
     $this->pagecount++;
     $record = (array) $record + array('lessonid' => $lesson->id, 'title' => 'Lesson page ' . $this->pagecount, 'timecreated' => $now, 'qtype' => 20, 'pageid' => 0);
     if (!isset($record['contents_editor'])) {
         $record['contents_editor'] = array('text' => 'Contents of lesson page ' . $this->pagecount, 'format' => FORMAT_MOODLE, 'itemid' => 0);
     }
     $context = context_module::instance($lesson->cmid);
     $page = lesson_page::create((object) $record, new lesson($lesson), $context, $CFG->maxbytes);
     return $DB->get_record('lesson_pages', array('id' => $page->id), '*', MUST_EXIST);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:14,代码来源:lib.php

示例2: stdClass

    $data = new stdClass();
    $data->id = $cm->id;
    $data->pageid = $pageid;
    if ($qtype) {
        //TODO: the handling of form for the selection of question type is a bloody hack! (skodak)
        $data->qtype = $qtype;
    }
    $data = file_prepare_standard_editor($data, 'contents', $editoroptions, null);
    $mform->set_data($data);
    $PAGE->navbar->add(get_string('addanewpage', 'lesson'), $PAGE->url);
    if ($qtype !== 'unknown') {
        $PAGE->navbar->add(get_string($mform->qtypestring, 'lesson'));
    }
}
if ($data = $mform->get_data()) {
    require_sesskey();
    if ($edit) {
        $data->lessonid = $data->id;
        $data->id = $data->pageid;
        unset($data->pageid);
        unset($data->edit);
        $editpage->update($data, $context, $PAGE->course->maxbytes);
    } else {
        $editpage = lesson_page::create($data, $lesson, $context, $PAGE->course->maxbytes);
    }
    redirect($returnto);
}
$lessonoutput = $PAGE->get_renderer('mod_lesson');
echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('edit', 'lesson'));
$mform->display();
echo $lessonoutput->footer();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:editpage.php

示例3: create_question_numeric

 /**
  * Create shortanswer question pages.
  * @param object $lesson
  * @param array $record
  * @return int
  */
 public function create_question_numeric($lesson, $record = array())
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/mod/lesson/locallib.php';
     $now = time();
     $this->pagecount++;
     $record = (array) $record + array('lessonid' => $lesson->id, 'title' => 'Lesson numerical question ' . $this->pagecount, 'timecreated' => $now, 'qtype' => 8, 'pageid' => 0);
     if (!isset($record['contents_editor'])) {
         $record['contents_editor'] = array('text' => 'Numerical question ' . $this->pagecount, 'format' => FORMAT_HTML, 'itemid' => 0);
     }
     // First Answer (correct).
     if (!isset($record['answer_editor'][0])) {
         $record['answer_editor'][0] = array('text' => $this->pagecount, 'format' => FORMAT_MOODLE);
     }
     if (!isset($record['jumpto'][0])) {
         $record['jumpto'][0] = LESSON_NEXTPAGE;
     }
     $context = context_module::instance($lesson->cmid);
     $page = lesson_page::create((object) $record, new lesson($lesson), $context, $CFG->maxbytes);
     return $DB->get_record('lesson_pages', array('id' => $page->id), '*', MUST_EXIST);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:lib.php

示例4: duplicate_page

 /**
  * Duplicate the lesson page.
  *
  * @param  int $pageid Page ID of the page to duplicate.
  * @return void.
  */
 public function duplicate_page($pageid)
 {
     global $PAGE;
     $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course);
     $context = context_module::instance($cm->id);
     // Load the page.
     $page = $this->load_page($pageid);
     $properties = $page->properties();
     // The create method checks to see if these properties are set and if not sets them to zero, hence the unsetting here.
     if (!$properties->qoption) {
         unset($properties->qoption);
     }
     if (!$properties->layout) {
         unset($properties->layout);
     }
     if (!$properties->display) {
         unset($properties->display);
     }
     $properties->pageid = $pageid;
     // Add text and format into the format required to create a new page.
     $properties->contents_editor = array('text' => $properties->contents, 'format' => $properties->contentsformat);
     $answers = $page->get_answers();
     // Answers need to be added to $properties.
     $i = 0;
     $answerids = array();
     foreach ($answers as $answer) {
         // Needs to be rearranged to work with the create function.
         $properties->answer_editor[$i] = array('text' => $answer->answer, 'format' => $answer->answerformat);
         $properties->response_editor[$i] = array('text' => $answer->response, 'format' => $answer->responseformat);
         $answerids[] = $answer->id;
         $properties->jumpto[$i] = $answer->jumpto;
         $properties->score[$i] = $answer->score;
         $i++;
     }
     // Create the duplicate page.
     $newlessonpage = lesson_page::create($properties, $this, $context, $PAGE->course->maxbytes);
     $newanswers = $newlessonpage->get_answers();
     // Copy over the file areas as well.
     $this->copy_page_files('page_contents', $pageid, $newlessonpage->id, $context->id);
     $j = 0;
     foreach ($newanswers as $answer) {
         if (isset($answer->answer) && strpos($answer->answer, '@@PLUGINFILE@@') !== false) {
             $this->copy_page_files('page_answers', $answerids[$j], $answer->id, $context->id);
         }
         if (isset($answer->response) && !is_array($answer->response) && strpos($answer->response, '@@PLUGINFILE@@') !== false) {
             $this->copy_page_files('page_responses', $answerids[$j], $answer->id, $context->id);
         }
         $j++;
     }
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:56,代码来源:locallib.php


注:本文中的lesson_page::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。