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


PHP question_state::get方法代码示例

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


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

示例1: load_from_records

 /**
  * Create a question_attempt_step from records loaded from the database.
  * @param Iterator $records Raw records loaded from the database.
  * @param int $stepid The id of the records to extract.
  * @param string $qtype The question type of which this is an attempt.
  *      If not given, each record must include a qtype field.
  * @return question_attempt_step The newly constructed question_attempt_step.
  */
 public static function load_from_records($records, $attemptstepid, $qtype = null)
 {
     $currentrec = $records->current();
     while ($currentrec->attemptstepid != $attemptstepid) {
         $records->next();
         if (!$records->valid()) {
             throw new coding_exception('Question attempt step ' . $attemptstepid . ' not found in the database.');
         }
         $currentrec = $records->current();
     }
     $record = $currentrec;
     $contextid = null;
     $data = array();
     while ($currentrec && $currentrec->attemptstepid == $attemptstepid) {
         if (!is_null($currentrec->name)) {
             $data[$currentrec->name] = $currentrec->value;
         }
         $records->next();
         if ($records->valid()) {
             $currentrec = $records->current();
         } else {
             $currentrec = false;
         }
     }
     $step = new question_attempt_step_read_only($data, $record->timecreated, $record->userid);
     $step->state = question_state::get($record->state);
     $step->id = $record->attemptstepid;
     if (!is_null($record->fraction)) {
         $step->fraction = $record->fraction + 0;
     }
     // This next chunk of code requires getting $contextid and $qtype here.
     // Somehow, we need to get that information to this point by modifying
     // all the paths by which this method can be called.
     // Can we only return files when it's possible? Should there be some kind of warning?
     if (is_null($qtype)) {
         $qtype = $record->qtype;
     }
     foreach (question_bank::get_qtype($qtype)->response_file_areas() as $area) {
         if (empty($step->data[$area])) {
             continue;
         }
         $step->data[$area] = new question_file_loader($step, $area, $step->data[$area], $record->contextid);
     }
     return $step;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:53,代码来源:questionattemptstep.php

示例2: make_review_link

    /**
     * Make a link to review an individual question in a popup window.
     *
     * @param string $data HTML fragment. The text to make into the link.
     * @param object $attempt data for the row of the table being output.
     * @param int $slot the number used to identify this question within this usage.
     */
    public function make_review_link($data, $attempt, $slot) {
        global $OUTPUT;

        $stepdata = $this->lateststeps[$attempt->usageid][$slot];
        $state = question_state::get($stepdata->state);

        $flag = '';
        if ($stepdata->flagged) {
            $flag = $OUTPUT->pix_icon('i/flagged', get_string('flagged', 'question'),
                    'moodle', array('class' => 'questionflag'));
        }

        $feedbackimg = '';
        if ($state->is_finished() && $state != question_state::$needsgrading) {
            $feedbackimg = $this->icon_for_fraction($stepdata->fraction);
        }

        $output = html_writer::tag('span', $feedbackimg . html_writer::tag('span',
                $data, array('class' => $state->get_state_class(true))) . $flag, array('class' => 'que'));

        $url = new moodle_url('/mod/quiz/reviewquestion.php',
                array('attempt' => $attempt->attempt, 'slot' => $slot));
        $output = $OUTPUT->action_link($url, $output,
                new popup_action('click', $url, 'reviewquestion',
                        array('height' => 450, 'width' => 650)),
                array('title' => get_string('reviewresponse', 'quiz')));

        return $output;
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:36,代码来源:attemptsreport_table.php

示例3: other_cols

 /**
  * @param string $colname the name of the column.
  * @param object $attempt the row of data - see the SQL in display() in
  * mod/quiz/report/overview/report.php to see what fields are present,
  * and what they are called.
  * @return string the contents of the cell.
  */
 public function other_cols($colname, $attempt)
 {
     if (!preg_match('/^qsgrade(\\d+)$/', $colname, $matches)) {
         return null;
     }
     $slot = $matches[1];
     $question = $this->questions[$slot];
     if (!isset($this->lateststeps[$attempt->usageid][$slot])) {
         return '-';
     }
     $stepdata = $this->lateststeps[$attempt->usageid][$slot];
     $state = question_state::get($stepdata->state);
     if ($question->maxmark == 0) {
         $grade = '-';
     } else {
         if (is_null($stepdata->fraction)) {
             if ($state == question_state::$needsgrading) {
                 $grade = get_string('requiresgrading', 'question');
             } else {
                 $grade = '-';
             }
         } else {
             $grade = quiz_rescale_grade($stepdata->fraction * $question->maxmark, $this->quiz, 'question');
         }
     }
     if ($this->is_downloading()) {
         return $grade;
     }
     if (isset($this->regradedqs[$attempt->usageid][$slot])) {
         $gradefromdb = $grade;
         $newgrade = quiz_rescale_grade($this->regradedqs[$attempt->usageid][$slot]->newfraction * $question->maxmark, $this->quiz, 'question');
         $oldgrade = quiz_rescale_grade($this->regradedqs[$attempt->usageid][$slot]->oldfraction * $question->maxmark, $this->quiz, 'question');
         $grade = html_writer::tag('del', $oldgrade) . '/' . html_writer::empty_tag('br') . $newgrade;
     }
     return $this->make_review_link($grade, $attempt, $slot);
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:43,代码来源:overview_table.php

示例4: slot_state

 /**
  * @param object $attempt the row data
  * @param int $slot
  * @return question_state
  */
 protected function slot_state($attempt, $slot)
 {
     $stepdata = $this->lateststeps[$attempt->usageid][$slot];
     return question_state::get($stepdata->state);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:10,代码来源:attemptsreport_table.php

示例5: load_from_records

    /**
     * Create a question_attempt_step from records loaded from the database.
     * @param Iterator $records Raw records loaded from the database.
     * @param int $stepid The id of the records to extract.
     * @return question_attempt_step The newly constructed question_attempt_step.
     */
    public static function load_from_records($records, $attemptstepid) {
        $currentrec = $records->current();
        while ($currentrec->attemptstepid != $attemptstepid) {
            $records->next();
            if (!$records->valid()) {
                throw new coding_exception('Question attempt step ' . $attemptstepid .
                        ' not found in the database.');
            }
            $currentrec = $records->current();
        }

        $record = $currentrec;
        $data = array();
        while ($currentrec && $currentrec->attemptstepid == $attemptstepid) {
            if ($currentrec->name) {
                $data[$currentrec->name] = $currentrec->value;
            }
            $records->next();
            if ($records->valid()) {
                $currentrec = $records->current();
            } else {
                $currentrec = false;
            }
        }

        $step = new question_attempt_step_read_only($data, $record->timecreated, $record->userid);
        $step->state = question_state::get($record->state);
        $step->id = $record->attemptstepid;
        if (!is_null($record->fraction)) {
            $step->fraction = $record->fraction + 0;
        }
        return $step;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:39,代码来源:questionattemptstep.php


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