當前位置: 首頁>>代碼示例>>PHP>>正文


PHP workshop::lcm方法代碼示例

本文整理匯總了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);
//.........這裏部分代碼省略.........
開發者ID:vuchannguyen,項目名稱:web,代碼行數:101,代碼來源:renderer.php

示例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);
 }
開發者ID:abhilash1994,項目名稱:moodle,代碼行數:10,代碼來源:locallib_test.php


注:本文中的workshop::lcm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。