本文整理汇总了PHP中Question::to_student方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::to_student方法的具体用法?PHP Question::to_student怎么用?PHP Question::to_student使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::to_student方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: to_student
public function to_student($show_level = true, $show_topics = true)
{
$qd = parent::to_student($show_level, $show_topics);
$answers = array_map(function ($a) {
return array('text' => $a['text'], 'hex_id' => $a['hex_id']);
}, $this->answers);
shuffle($answers);
$qd['fields'] = $answers;
return $qd;
}
示例2: to_student
public function to_student($show_level = true, $show_topics = true)
{
$qd = parent::to_student($show_level, $show_topics);
// nothing to add...
return $qd;
}
示例3: to_student
public function to_student($show_level = true, $show_topics = true)
{
$qd = parent::to_student($show_level, $show_topics);
$func = function ($a) {
return array('text' => $a['text'], 'hex_id' => $a['hex_id']);
};
$left_column = array_map($func, $this->left_column);
$right_column = array_map($func, $this->right_column);
if ($this->shuffle_left) {
shuffle($left_column);
}
if ($this->shuffle_right) {
shuffle($right_column);
}
$qd['leftColumn'] = $left_column;
$qd['rightColumn'] = $right_column;
$qd['reorderLeft'] = $this->shuffle_left;
$qd['reorderRight'] = $this->shuffle_right;
return $qd;
}
示例4: to_student
public function to_student($show_level = true, $show_topics = true)
{
$qd = parent::to_student($show_level, $show_topics);
$qd['min_answers'] = $this->min_answers;
$qd['max_answers'] = $this->max_answers;
$n = count($this->answers);
$nonfixed = [];
$shuffled_answers = array_fill(0, $n, null);
foreach ($this->answers as $i => $a) {
$answer = array('hex_id' => $a['hex_id'], 'text' => $a['text']);
if ($a['fixed']) {
$shuffled_answers[$i] = $answer;
} else {
$nonfixed[$i] = $answer;
}
}
shuffle($nonfixed);
for ($i = 0; $i < $n; $i++) {
if ($shuffled_answers[$i] === null) {
$shuffled_answers[$i] = array_shift($nonfixed);
}
}
$qd['answers'] = $shuffled_answers;
return $qd;
}