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


PHP question_attempt::set_number_in_usage方法代码示例

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


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

示例1: load_from_records

 /**
  * Create a question_attempt_step from records loaded from the database.
  *
  * For internal use only.
  *
  * @param Iterator $records Raw records loaded from the database.
  * @param int $questionattemptid The id of the question_attempt to extract.
  * @return question_attempt The newly constructed question_attempt_step.
  */
 public static function load_from_records($records, $questionattemptid, question_usage_observer $observer, $preferredbehaviour)
 {
     $record = $records->current();
     while ($record->questionattemptid != $questionattemptid) {
         $record = $records->next();
         if (!$records->valid()) {
             throw new coding_exception("Question attempt {$questionattemptid} not found in the database.");
         }
         $record = $records->current();
     }
     try {
         $question = question_bank::load_question($record->questionid);
     } catch (Exception $e) {
         // The question must have been deleted somehow. Create a missing
         // question to use in its place.
         $question = question_bank::get_qtype('missingtype')->make_deleted_instance($record->questionid, $record->maxmark + 0);
     }
     $qa = new question_attempt($question, $record->questionusageid, null, $record->maxmark + 0);
     $qa->set_database_id($record->questionattemptid);
     $qa->set_number_in_usage($record->slot);
     $qa->variant = $record->variant + 0;
     $qa->minfraction = $record->minfraction + 0;
     $qa->set_flagged($record->flagged);
     $qa->questionsummary = $record->questionsummary;
     $qa->rightanswer = $record->rightanswer;
     $qa->responsesummary = $record->responsesummary;
     $qa->timemodified = $record->timemodified;
     $qa->behaviour = question_engine::make_behaviour($record->behaviour, $qa, $preferredbehaviour);
     $i = 0;
     while ($record && $record->questionattemptid == $questionattemptid && !is_null($record->attemptstepid)) {
         $qa->steps[$i] = question_attempt_step::load_from_records($records, $record->attemptstepid);
         if ($i == 0) {
             $question->apply_attempt_state($qa->steps[0]);
         }
         $i++;
         if ($records->valid()) {
             $record = $records->current();
         } else {
             $record = false;
         }
     }
     $qa->observer = $observer;
     return $qa;
 }
开发者ID:hatone,项目名称:moodle,代码行数:53,代码来源:questionattempt.php

示例2: add_question

 /**
  * Add another question to this usage.
  *
  * The added question is not started until you call {@link start_question()}
  * on it.
  *
  * @param question_definition $question the question to add.
  * @param number $maxmark the maximum this question will be marked out of in
  *      this attempt (optional). If not given, $question->defaultmark is used.
  * @return int the number used to identify this question within this usage.
  */
 public function add_question(question_definition $question, $maxmark = null)
 {
     $qa = new question_attempt($question, $this->get_id(), $this->observer, $maxmark);
     if (count($this->questionattempts) == 0) {
         $this->questionattempts[1] = $qa;
     } else {
         $this->questionattempts[] = $qa;
     }
     $qa->set_number_in_usage(end(array_keys($this->questionattempts)));
     $this->observer->notify_attempt_added($qa);
     return $qa->get_slot();
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:23,代码来源:questionusage.php


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