本文整理汇总了PHP中workshop::slice_example_submissions方法的典型用法代码示例。如果您正苦于以下问题:PHP workshop::slice_example_submissions方法的具体用法?PHP workshop::slice_example_submissions怎么用?PHP workshop::slice_example_submissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类workshop
的用法示例。
在下文中一共展示了workshop::slice_example_submissions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param array $examples all the examples in the workshop
* @param int $n the number of examples that will be shown to users ($workshop->numexamples)
*/
public function __construct($examples,$n) {
$slices = workshop::slice_example_submissions($examples,$n);
$this->slices = array();
foreach ($slices as $i => $s) {
$slice = new stdClass;
$slice->min = (float)(reset($s)->grade);
if ($i < count($slices) - 1)
$slice->max = (float)(end($s)->grade);
else
$slice->max = 100;
$slice->colour = $this->get_colour($i,$n,1);
$slice->title = workshop_random_examples_helper::$descriptors[count($slices)][$i];
$slice->width = $slice->max - $slice->min . "%";
$grades = array();
foreach($s as $v) $grades[] = $v->grade;
$slice->mean = array_sum($grades) / count($grades);
$slice->meancolour = $this->get_colour($i,$n,-1);
$slice->submissions = $s;
$slice->subcolour = $this->get_colour($i,$n,0);
//identify warnings
if ($i > 0) {
$prev = $this->slices[$i - 1];
if ($slice->min == $prev->max) {
//overlap
$prev->warnings[] = get_string('randomexamplesoverlapwarning','workshop',array("prev" => $prev->title, "next" => $slice->title));
}
}
$this->slices[$i] = $slice;
}
}