本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}