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


PHP grade_item::load_scale方法代碼示例

本文整理匯總了PHP中grade_item::load_scale方法的典型用法代碼示例。如果您正苦於以下問題:PHP grade_item::load_scale方法的具體用法?PHP grade_item::load_scale怎麽用?PHP grade_item::load_scale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在grade_item的用法示例。


在下文中一共展示了grade_item::load_scale方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: stdClass

 }
 // check if grade item is locked if so, abort
 if ($gradeitem->is_locked()) {
     $status = false;
     import_cleanup($importcode);
     echo $OUTPUT->notification(get_string('gradeitemlocked', 'grades'));
     break 3;
 }
 $newgrade = new stdClass();
 $newgrade->itemid = $gradeitem->id;
 if ($gradeitem->gradetype == GRADE_TYPE_SCALE and $verbosescales) {
     if ($value === '' or $value == '-') {
         $value = null;
         // no grade
     } else {
         $scale = $gradeitem->load_scale();
         $scales = explode(',', $scale->scale);
         $scales = array_map('trim', $scales);
         //hack - trim whitespace around scale options
         array_unshift($scales, '-');
         // scales start at key 1
         $key = array_search($value, $scales);
         if ($key === false) {
             echo "<br/>t0 is {$t0}";
             echo "<br/>grade is {$value}";
             $status = false;
             import_cleanup($importcode);
             echo $OUTPUT->notification(get_string('badgrade', 'grades'));
             break 3;
         }
         $value = $key;
開發者ID:covex-nn,項目名稱:moodle,代碼行數:31,代碼來源:index.php

示例2: update_grade_item

 /**
  * This updates existing grade items.
  *
  * @param int $courseid The course ID.
  * @param array $map Mapping information provided by the user.
  * @param int $key The line that we are currently working on.
  * @param bool $verbosescales Form setting for grading with scales.
  * @param string $value The grade value.
  * @return array grades to be updated.
  */
 protected function update_grade_item($courseid, $map, $key, $verbosescales, $value)
 {
     // Case of an id, only maps id of a grade_item.
     // This was idnumber.
     if (!($gradeitem = new grade_item(array('id' => $map[$key], 'courseid' => $courseid)))) {
         // Supplied bad mapping, should not be possible since user
         // had to pick mapping.
         $this->cleanup_import(get_string('importfailed', 'grades'));
         return null;
     }
     // Check if grade item is locked if so, abort.
     if ($gradeitem->is_locked()) {
         $this->cleanup_import(get_string('gradeitemlocked', 'grades'));
         return null;
     }
     $newgrade = new stdClass();
     $newgrade->itemid = $gradeitem->id;
     if ($gradeitem->gradetype == GRADE_TYPE_SCALE and $verbosescales) {
         if ($value === '' or $value == '-') {
             $value = null;
             // No grade.
         } else {
             $scale = $gradeitem->load_scale();
             $scales = explode(',', $scale->scale);
             $scales = array_map('trim', $scales);
             // Hack - trim whitespace around scale options.
             array_unshift($scales, '-');
             // Scales start at key 1.
             $key = array_search($value, $scales);
             if ($key === false) {
                 $this->cleanup_import(get_string('badgrade', 'grades'));
                 return null;
             }
             $value = $key;
         }
         $newgrade->finalgrade = $value;
     } else {
         if ($value === '' or $value == '-') {
             $value = null;
             // No grade.
         } else {
             // If the value has a local decimal or can correctly be unformatted, do it.
             $validvalue = unformat_float($value, true);
             if ($validvalue !== false) {
                 $value = $validvalue;
             } else {
                 // Non numeric grade value supplied, possibly mapped wrong column.
                 $this->cleanup_import(get_string('badgrade', 'grades'));
                 return null;
             }
         }
         $newgrade->finalgrade = $value;
     }
     $this->newgrades[] = $newgrade;
     return $this->newgrades;
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:66,代碼來源:load_data.php


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