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


PHP question_attempt_step::get_id方法代码示例

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


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

示例1: apply_attempt_state

 /**
  * When an in-progress {@link question_attempt} is re-loaded from the
  * database, this method is called so that the question can re-initialise
  * its internal state as needed by this attempt.
  *
  * For example, the multiple choice question type needs to set the order
  * of the choices to the order that was set up when start_attempt was called
  * originally. All the information required to do this should be in the
  * $step object, which is the first step of the question_attempt being loaded.
  *
  * @param question_attempt_step The first step of the {@link question_attempt}
  *      being loaded.
  */
 public function apply_attempt_state(\question_attempt_step $step)
 {
     global $DB;
     $attemptid = $this->get_attemptid_by_stepid($step->get_id());
     $this->usageid = $this->get_question_usageid($attemptid);
     // Retrive all vars initialized in start_attempt().
     foreach ($step->get_qt_data() as $name => $value) {
         if (substr($name, 0, 5) === '_var_') {
             $varid = substr($name, 5);
             $varname = $this->vars[$varid]->varname;
             $this->questiontext = str_replace('{$' . $varname . '}', $value, $this->questiontext);
             // Store vars (as array form) to be used later to get the correct response
             $this->varvalues[$varid] = explode(',', $value);
             if (!($values = $DB->get_field('qtype_programmedresp_val', 'varvalues', array('attemptid' => $this->usageid, 'varid' => $varid)))) {
                 // Add a new random value
                 $val = new stdClass();
                 $val->attemptid = $this->usageid;
                 $val->varid = $varid;
                 $val->varvalues = programmedresp_serialize($this->varvalues[$varid]);
                 if (!$DB->insert_record('qtype_programmedresp_val', $val)) {
                     print_error('errordb', 'qtype_programmedresp');
                 }
             }
         }
     }
 }
开发者ID:fontinixxl,项目名称:moodle-qtype_linkerdesc,代码行数:39,代码来源:question.php

示例2: apply_attempt_state

 /**
  * When an in-progress {@link question_attempt} is re-loaded from the database, this method is called so that the
  * question can re-initialise its internal state as needed by this attempt. For example, the multiple choice
  * question type needs to set the order of the choices to the order that was set up when start_attempt was called
  * originally. All the information required to do this should be in the $step object, which is the first step of the
  * question_attempt being loaded.
  *
  * @param question_attempt_step The first step of the {@link question_attempt} being loaded.
  */
 public function apply_attempt_state(question_attempt_step $step)
 {
     global $DB;
     $stepid = $step->get_id();
     // We need a place to store the feedback generated by JUnit.
     // Therefore we want to know the questionattemptid.
     if (!empty($stepid)) {
         $record = $DB->get_record('question_attempt_steps', array('id' => $stepid), 'questionattemptid');
         if ($record) {
             $this->questionattemptid = $record->questionattemptid;
         }
     }
 }
开发者ID:r9loic,项目名称:JavaunittestV2,代码行数:22,代码来源:question.php


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