本文整理汇总了PHP中workshop::lcm方法的典型用法代码示例。如果您正苦于以下问题:PHP workshop::lcm方法的具体用法?PHP workshop::lcm怎么用?PHP workshop::lcm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类workshop
的用法示例。
在下文中一共展示了workshop::lcm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_workshop_grading_report
/**
* Renders the workshop grading report
*
* @param workshop_grading_report $gradingreport
* @return string html code
*/
protected function render_workshop_grading_report(workshop_grading_report $gradingreport)
{
$data = $gradingreport->get_data();
$options = $gradingreport->get_options();
$grades = $data->grades;
$userinfo = $data->userinfo;
if (empty($grades)) {
return '';
}
$table = new html_table();
$table->attributes['class'] = 'grading-report';
$sortbyfirstname = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options->sortby, $options->sorthow);
$sortbylastname = $this->helper_sortable_heading(get_string('lastname'), 'lastname', $options->sortby, $options->sorthow);
if (self::fullname_format() == 'lf') {
$sortbyname = $sortbylastname . ' / ' . $sortbyfirstname;
} else {
$sortbyname = $sortbyfirstname . ' / ' . $sortbylastname;
}
$table->head = array();
$table->head[] = $sortbyname;
$table->head[] = $this->helper_sortable_heading(get_string('submission', 'workshop'), 'submissiontitle', $options->sortby, $options->sorthow);
$table->head[] = $this->helper_sortable_heading(get_string('receivedgrades', 'workshop'));
if ($options->showsubmissiongrade) {
$table->head[] = $this->helper_sortable_heading(get_string('submissiongradeof', 'workshop', $data->maxgrade), 'submissiongrade', $options->sortby, $options->sorthow);
}
$table->head[] = $this->helper_sortable_heading(get_string('givengrades', 'workshop'));
if ($options->showgradinggrade) {
$table->head[] = $this->helper_sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade), 'gradinggrade', $options->sortby, $options->sorthow);
}
$table->rowclasses = array();
$table->colclasses = array();
$table->data = array();
foreach ($grades as $participant) {
$numofreceived = count($participant->reviewedby);
$numofgiven = count($participant->reviewerof);
$published = $participant->submissionpublished;
// compute the number of <tr> table rows needed to display this participant
if ($numofreceived > 0 and $numofgiven > 0) {
$numoftrs = workshop::lcm($numofreceived, $numofgiven);
$spanreceived = $numoftrs / $numofreceived;
$spangiven = $numoftrs / $numofgiven;
} elseif ($numofreceived == 0 and $numofgiven > 0) {
$numoftrs = $numofgiven;
$spanreceived = $numoftrs;
$spangiven = $numoftrs / $numofgiven;
} elseif ($numofreceived > 0 and $numofgiven == 0) {
$numoftrs = $numofreceived;
$spanreceived = $numoftrs / $numofreceived;
$spangiven = $numoftrs;
} else {
$numoftrs = 1;
$spanreceived = 1;
$spangiven = 1;
}
for ($tr = 0; $tr < $numoftrs; $tr++) {
$row = new html_table_row();
if ($published) {
$row->attributes['class'] = 'published';
}
// column #1 - participant - spans over all rows
if ($tr == 0) {
$cell = new html_table_cell();
$cell->text = $this->helper_grading_report_participant($participant, $userinfo);
$cell->rowspan = $numoftrs;
$cell->attributes['class'] = 'participant';
$row->cells[] = $cell;
}
// column #2 - submission - spans over all rows
if ($tr == 0) {
$cell = new html_table_cell();
$cell->text = $this->helper_grading_report_submission($participant);
$cell->rowspan = $numoftrs;
$cell->attributes['class'] = 'submission';
$row->cells[] = $cell;
}
// column #3 - received grades
if ($tr % $spanreceived == 0) {
$idx = intval($tr / $spanreceived);
$assessment = self::array_nth($participant->reviewedby, $idx);
$cell = new html_table_cell();
$cell->text = $this->helper_grading_report_assessment($assessment, $options->showreviewernames, $userinfo, get_string('gradereceivedfrom', 'workshop'));
$cell->rowspan = $spanreceived;
$cell->attributes['class'] = 'receivedgrade';
if (is_null($assessment) or is_null($assessment->grade)) {
$cell->attributes['class'] .= ' null';
} else {
$cell->attributes['class'] .= ' notnull';
}
$row->cells[] = $cell;
}
// column #4 - total grade for submission
if ($options->showsubmissiongrade and $tr == 0) {
$cell = new html_table_cell();
$cell->text = $this->helper_grading_report_grade($participant->submissiongrade, $participant->submissiongradeover);
//.........这里部分代码省略.........
示例2: test_lcm
public function test_lcm()
{
$this->resetAfterTest(true);
// fixture setup + exercise SUT + verify in one step
$this->assertEquals(workshop::lcm(1, 4), 4);
$this->assertEquals(workshop::lcm(2, 4), 4);
$this->assertEquals(workshop::lcm(4, 2), 4);
$this->assertEquals(workshop::lcm(2, 3), 6);
$this->assertEquals(workshop::lcm(6, 4), 12);
}