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


PHP stdClass::properties方法代码示例

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


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

示例1: update

 /**
  * Updates a lesson page and its answers within the database
  *
  * @param object $properties
  * @return bool
  */
 public function update($properties, $context = null, $maxbytes = null)
 {
     global $DB, $PAGE;
     $answers = $this->get_answers();
     $properties->id = $this->properties->id;
     $properties->lessonid = $this->lesson->id;
     if (empty($properties->qoption)) {
         $properties->qoption = '0';
     }
     if (empty($context)) {
         $context = $PAGE->context;
     }
     if ($maxbytes === null) {
         $maxbytes = get_user_max_upload_file_size($context);
     }
     $properties->timemodified = time();
     $properties = file_postupdate_standard_editor($properties, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes), $context, 'mod_lesson', 'page_contents', $properties->id);
     $DB->update_record("lesson_pages", $properties);
     // Trigger an event: page updated.
     \mod_lesson\event\page_updated::create_from_lesson_page($this, $context)->trigger();
     if ($this->type == self::TYPE_STRUCTURE && $this->get_typeid() != LESSON_PAGE_BRANCHTABLE) {
         // These page types have only one answer to save the jump and score.
         if (count($answers) > 1) {
             $answer = array_shift($answers);
             foreach ($answers as $a) {
                 $DB->delete_record('lesson_answers', array('id' => $a->id));
             }
         } else {
             if (count($answers) == 1) {
                 $answer = array_shift($answers);
             } else {
                 $answer = new stdClass();
                 $answer->lessonid = $properties->lessonid;
                 $answer->pageid = $properties->id;
                 $answer->timecreated = time();
             }
         }
         $answer->timemodified = time();
         if (isset($properties->jumpto[0])) {
             $answer->jumpto = $properties->jumpto[0];
         }
         if (isset($properties->score[0])) {
             $answer->score = $properties->score[0];
         }
         if (!empty($answer->id)) {
             $DB->update_record("lesson_answers", $answer->properties());
         } else {
             $DB->insert_record("lesson_answers", $answer);
         }
     } else {
         for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
             if (!array_key_exists($i, $this->answers)) {
                 $this->answers[$i] = new stdClass();
                 $this->answers[$i]->lessonid = $this->lesson->id;
                 $this->answers[$i]->pageid = $this->id;
                 $this->answers[$i]->timecreated = $this->timecreated;
             }
             if (isset($properties->answer_editor[$i])) {
                 if (is_array($properties->answer_editor[$i])) {
                     // Multichoice and true/false pages have an HTML editor.
                     $this->answers[$i]->answer = $properties->answer_editor[$i]['text'];
                     $this->answers[$i]->answerformat = $properties->answer_editor[$i]['format'];
                 } else {
                     // Branch tables, shortanswer and mumerical pages have only a text field.
                     $this->answers[$i]->answer = $properties->answer_editor[$i];
                     $this->answers[$i]->answerformat = FORMAT_MOODLE;
                 }
             }
             if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i])) {
                 $this->answers[$i]->response = $properties->response_editor[$i]['text'];
                 $this->answers[$i]->responseformat = $properties->response_editor[$i]['format'];
             }
             if (isset($this->answers[$i]->answer) && $this->answers[$i]->answer != '') {
                 if (isset($properties->jumpto[$i])) {
                     $this->answers[$i]->jumpto = $properties->jumpto[$i];
                 }
                 if ($this->lesson->custom && isset($properties->score[$i])) {
                     $this->answers[$i]->score = $properties->score[$i];
                 }
                 if (!isset($this->answers[$i]->id)) {
                     $this->answers[$i]->id = $DB->insert_record("lesson_answers", $this->answers[$i]);
                 } else {
                     $DB->update_record("lesson_answers", $this->answers[$i]->properties());
                 }
                 // Save files in answers and responses.
                 if (isset($properties->response_editor[$i])) {
                     $this->save_answers_files($context, $maxbytes, $this->answers[$i], $properties->answer_editor[$i], $properties->response_editor[$i]);
                 } else {
                     $this->save_answers_files($context, $maxbytes, $this->answers[$i], $properties->answer_editor[$i]);
                 }
             } else {
                 if (isset($this->answers[$i]->id)) {
                     $DB->delete_records('lesson_answers', array('id' => $this->answers[$i]->id));
                     unset($this->answers[$i]);
//.........这里部分代码省略.........
开发者ID:mongo0se,项目名称:moodle,代码行数:101,代码来源:locallib.php

示例2: update

 public function update($properties, $context = null, $maxbytes = null)
 {
     global $DB, $PAGE;
     $properties->id = $this->properties->id;
     $properties->lessonid = $this->lesson->id;
     if (empty($properties->qoption)) {
         $properties->qoption = '0';
     }
     $properties->timemodified = time();
     $properties = file_postupdate_standard_editor($properties, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $PAGE->course->maxbytes), context_module::instance($PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
     $DB->update_record("lesson_pages", $properties);
     $answers = $this->get_answers();
     if (count($answers) > 1) {
         $answer = array_shift($answers);
         foreach ($answers as $a) {
             $DB->delete_record('lesson_answers', array('id' => $a->id));
         }
     } else {
         if (count($answers) == 1) {
             $answer = array_shift($answers);
         } else {
             $answer = new stdClass();
         }
     }
     $answer->timemodified = time();
     if (isset($properties->jumpto[0])) {
         $answer->jumpto = $properties->jumpto[0];
     }
     if (isset($properties->score[0])) {
         $answer->score = $properties->score[0];
     }
     if (!empty($answer->id)) {
         $DB->update_record("lesson_answers", $answer->properties());
     } else {
         $DB->insert_record("lesson_answers", $answer);
     }
     return true;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:38,代码来源:endofbranch.php

示例3: update

 /**
  * Updates a lesson page and its answers within the database
  *
  * @param object $properties
  * @return bool
  */
 public function update($properties, $context = null, $maxbytes = null)
 {
     global $DB, $PAGE;
     $answers = $this->get_answers();
     $properties->id = $this->properties->id;
     $properties->lessonid = $this->lesson->id;
     if (empty($properties->qoption)) {
         $properties->qoption = '0';
     }
     if (empty($context)) {
         $context = $PAGE->context;
     }
     if ($maxbytes === null) {
         $maxbytes = get_user_max_upload_file_size($context);
     }
     $properties->timemodified = time();
     $properties = file_postupdate_standard_editor($properties, 'contents', array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes), $context, 'mod_lesson', 'page_contents', $properties->id);
     $DB->update_record("lesson_pages", $properties);
     if ($this->type == self::TYPE_STRUCTURE && $this->get_typeid() != LESSON_PAGE_BRANCHTABLE) {
         if (count($answers) > 1) {
             $answer = array_shift($answers);
             foreach ($answers as $a) {
                 $DB->delete_record('lesson_answers', array('id' => $a->id));
             }
         } else {
             if (count($answers) == 1) {
                 $answer = array_shift($answers);
             } else {
                 $answer = new stdClass();
                 $answer->lessonid = $properties->lessonid;
                 $answer->pageid = $properties->id;
                 $answer->timecreated = time();
             }
         }
         $answer->timemodified = time();
         if (isset($properties->jumpto[0])) {
             $answer->jumpto = $properties->jumpto[0];
         }
         if (isset($properties->score[0])) {
             $answer->score = $properties->score[0];
         }
         if (!empty($answer->id)) {
             $DB->update_record("lesson_answers", $answer->properties());
         } else {
             $DB->insert_record("lesson_answers", $answer);
         }
     } else {
         for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
             if (!array_key_exists($i, $this->answers)) {
                 $this->answers[$i] = new stdClass();
                 $this->answers[$i]->lessonid = $this->lesson->id;
                 $this->answers[$i]->pageid = $this->id;
                 $this->answers[$i]->timecreated = $this->timecreated;
             }
             if (!empty($properties->answer_editor[$i]) && is_array($properties->answer_editor[$i])) {
                 $this->answers[$i]->answer = $properties->answer_editor[$i]['text'];
                 $this->answers[$i]->answerformat = $properties->answer_editor[$i]['format'];
             }
             if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i])) {
                 $this->answers[$i]->response = $properties->response_editor[$i]['text'];
                 $this->answers[$i]->responseformat = $properties->response_editor[$i]['format'];
             }
             if (isset($this->answers[$i]->answer) && $this->answers[$i]->answer != '') {
                 if (isset($properties->jumpto[$i])) {
                     $this->answers[$i]->jumpto = $properties->jumpto[$i];
                 }
                 if ($this->lesson->custom && isset($properties->score[$i])) {
                     $this->answers[$i]->score = $properties->score[$i];
                 }
                 if (!isset($this->answers[$i]->id)) {
                     $this->answers[$i]->id = $DB->insert_record("lesson_answers", $this->answers[$i]);
                 } else {
                     $DB->update_record("lesson_answers", $this->answers[$i]->properties());
                 }
             } else {
                 if (isset($this->answers[$i]->id)) {
                     $DB->delete_records('lesson_answers', array('id' => $this->answers[$i]->id));
                     unset($this->answers[$i]);
                 }
             }
         }
     }
     return true;
 }
开发者ID:educacionbe,项目名称:cursos,代码行数:90,代码来源:locallib.php


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