当前位置: 首页>>代码示例>>PHP>>正文


PHP grade_scale::load_items方法代码示例

本文整理汇总了PHP中grade_scale::load_items方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_scale::load_items方法的具体用法?PHP grade_scale::load_items怎么用?PHP grade_scale::load_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grade_scale的用法示例。


在下文中一共展示了grade_scale::load_items方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_moodle_grades

 private function get_moodle_grades()
 {
     global $DB, $CFG;
     $grades = $DB->get_records('grade_grades', array('itemid' => $this->course_grade_item->id), 'userid', 'userid, finalgrade');
     if (!is_array($grades)) {
         $grades = array();
     }
     $this->moodle_grades = array();
     if ($this->course_grade_item->gradetype == GRADE_TYPE_SCALE) {
         $pg_scale = new grade_scale(array('id' => $CFG->grade_report_newgradereport_scale));
         $scale_items = $pg_scale->load_items();
         foreach ($this->moodle_students as $st) {
             if (isset($grades[$st->id])) {
                 $fg = (int) $grades[$st->id]->finalgrade;
                 if (isset($scale_items[$fg - 1])) {
                     $this->moodle_grades[$st->id] = $scale_items[$fg - 1];
                 } else {
                     $this->moodle_grades[$st->id] = null;
                 }
             } else {
                 $this->moodle_grades[$st->id] = null;
             }
         }
     } else {
         foreach ($this->moodle_students as $st) {
             if (isset($grades[$st->id])) {
                 $this->moodle_grades[$st->id] = grade_format_gradevalue($grades[$st->id]->finalgrade, $this->course_grade_item, true, $this->course_grade_item->get_displaytype(), null);
             } else {
                 $this->moodle_grades[$st->id] = null;
             }
         }
     }
 }
开发者ID:danielneis,项目名称:moodle-gradereport_newgradereport,代码行数:33,代码来源:lib.php

示例2: load_scale

 /**
  * Instantiates a grade_scale object from the DB if this item's scaleid variable is set
  *
  * @return grade_scale Returns a grade_scale object or null if no scale used
  */
 public function load_scale()
 {
     if ($this->gradetype != GRADE_TYPE_SCALE) {
         $this->scaleid = null;
     }
     if (!empty($this->scaleid)) {
         //do not load scale if already present
         if (empty($this->scale->id) or $this->scale->id != $this->scaleid) {
             $this->scale = grade_scale::fetch(array('id' => $this->scaleid));
             if (!$this->scale) {
                 debugging('Incorrect scale id: ' . $this->scaleid);
                 $this->scale = null;
                 return null;
             }
             $this->scale->load_items();
         }
         // Until scales are uniformly set to min=0 max=count(scaleitems)-1 throughout Moodle, we
         // stay with the current min=1 max=count(scaleitems)
         $this->grademax = count($this->scale->scale_items);
         $this->grademin = 1;
     } else {
         $this->scale = null;
     }
     return $this->scale;
 }
开发者ID:mongo0se,项目名称:moodle,代码行数:30,代码来源:grade_item.php

示例3: sub_test_scale_one_item

 protected function sub_test_scale_one_item()
 {
     $params = new stdClass();
     $params->name = 'unittestscale1i';
     $params->courseid = $this->course->id;
     $params->userid = $this->userid;
     $params->scale = 'Like';
     $params->description = 'This scale is used to like something.';
     $params->timemodified = time();
     $scale = new grade_scale($params, false);
     $scale->load_items();
     $this->assertCount(1, $scale->scale_items);
     $this->assertSame(array('Like'), $scale->scale_items);
     $this->assertSame('Like', $scale->compact_items());
     $scale->insert();
     // Manual grade item with 1 item scale.
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->categoryid = $this->grade_categories[0]->id;
     $grade_item->itemname = 'manual grade_item scale_1';
     $grade_item->itemtype = 'manual';
     $grade_item->itemnumber = 0;
     $grade_item->needsupdate = false;
     $grade_item->gradetype = GRADE_TYPE_SCALE;
     $grade_item->scaleid = $scale->id;
     $grade_item->iteminfo = 'Manual grade item used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item = new grade_item($grade_item);
     $grade_item->insert();
     $this->assertNotEmpty($grade_item->id);
     $this->assertEquals(1, $grade_item->grademin);
     $this->assertEquals(1, $grade_item->grademax);
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:34,代码来源:grade_scale_test.php


注:本文中的grade_scale::load_items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。