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


PHP grade_grade::load_grade_item方法代码示例

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


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

示例1: test_task_timefilter

 public function test_task_timefilter()
 {
     $task = new \local_gradelock\task\lock_grades();
     $grade_grade = new grade_grade();
     $grade_grade->itemid = $this->grade_items[0]->id;
     $grade_grade->userid = 10;
     $grade_grade->rawgrade = 88;
     $grade_grade->rawgrademax = 110;
     $grade_grade->rawgrademin = 18;
     $grade_grade->load_grade_item();
     $grade_grade->insert();
     $grade_grade->grade_item->update_final_grade($this->user[0]->id, 100, 'gradebook', '', FORMAT_MOODLE);
     $grade_grade->update();
     $task->execute();
     $grade_grade = grade_grade::fetch(array('userid' => $this->user[0]->id, 'itemid' => $this->grade_items[0]->id));
     $this->assertFalse($grade_grade->is_locked());
 }
开发者ID:ispedals,项目名称:moodle-local_gradelock,代码行数:17,代码来源:task_test.php

示例2: fill_table_recursive

 private function fill_table_recursive(&$element)
 {
     global $DB, $CFG;
     $type = $element['type'];
     $depth = $element['depth'];
     $grade_object = $element['object'];
     $eid = $grade_object->id;
     $element['userid'] = $this->user->id;
     $fullname = $this->gtree->get_element_header($element, true, true, true);
     $data = array();
     $hidden = '';
     $excluded = '';
     $class = '';
     $classfeedback = '';
     // If this is a hidden grade category, hide it completely from the user
     if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_object->is_hiddenuntil())) {
         return false;
     }
     if ($type == 'category') {
         $this->evenodd[$depth] = ($this->evenodd[$depth] + 1) % 2;
     }
     $alter = $this->evenodd[$depth] == 0 ? 'even' : 'odd';
     /// Process those items that have scores associated
     if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
         $header_row = "row_{$eid}_{$this->user->id}";
         $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";
         if (!($grade_grade = grade_grade::fetch(array('itemid' => $grade_object->id, 'userid' => $this->user->id)))) {
             $grade_grade = new grade_grade();
             $grade_grade->userid = $this->user->id;
             $grade_grade->itemid = $grade_object->id;
         }
         $grade_grade->load_grade_item();
         /// Hidden Items
         if ($grade_grade->grade_item->is_hidden()) {
             $hidden = ' dimmed_text';
         }
         $hide = false;
         // If this is a hidden grade item, hide it completely from the user.
         if ($grade_grade->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil())) {
             $hide = true;
         } else {
             if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
                 // The grade object can be marked visible but still be hidden if
                 // the student cannot see the activity due to conditional access
                 // and it's set to be hidden entirely.
                 $instances = $this->modinfo->get_instances_of($grade_object->itemmodule);
                 if (!empty($instances[$grade_object->iteminstance])) {
                     $cm = $instances[$grade_object->iteminstance];
                     if (!$cm->uservisible) {
                         // If there is 'availableinfo' text then it is only greyed
                         // out and not entirely hidden.
                         if (!$cm->availableinfo) {
                             $hide = true;
                         }
                     }
                 }
             }
         }
         if (!$hide) {
             /// Excluded Item
             if ($grade_grade->is_excluded()) {
                 $fullname .= ' [' . get_string('excluded', 'grades') . ']';
                 $excluded = ' excluded';
             }
             /// Other class information
             $class = "{$hidden} {$excluded}";
             if ($this->switch) {
                 // alter style based on whether aggregation is first or last
                 $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggt b2b" : " item b1b";
             } else {
                 $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggb" : " item b1b";
             }
             if ($type == 'categoryitem' or $type == 'courseitem') {
                 $header_cat = "cat_{$grade_object->iteminstance}_{$this->user->id}";
             }
             /// Name
             $data['itemname']['content'] = $fullname;
             $data['itemname']['class'] = $class;
             $data['itemname']['colspan'] = $this->maxdepth - $depth;
             $data['itemname']['celltype'] = 'th';
             $data['itemname']['id'] = $header_row;
             /// Actual Grade
             $gradeval = $grade_grade->finalgrade;
             if (!$this->canviewhidden) {
                 /// Virtual Grade (may be calculated excluding hidden items etc).
                 $adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid, $grade_grade->grade_item, $gradeval);
                 $gradeval = $adjustedgrade['grade'];
                 // We temporarily adjust the view of this grade item - because the min and
                 // max are affected by the hidden values in the aggregation.
                 $grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
                 $grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
             }
             if ($this->showfeedback) {
                 // Copy $class before appending itemcenter as feedback should not be centered
                 $classfeedback = $class;
             }
             $class .= " itemcenter ";
             if ($this->showweight) {
                 $data['weight']['class'] = $class;
                 $data['weight']['content'] = '-';
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:lib.php

示例3: regrade_final_grades

 /**
  * Performs the necessary calculations on the grades_final referenced by this grade_item.
  * Also resets the needsupdate flag once successfully performed.
  *
  * This function must be used ONLY from lib/gradeslib.php/grade_regrade_final_grades(),
  * because the regrading must be done in correct order!!
  *
  * @param int $userid Supply a user ID to limit the regrading to a single user
  * @return bool true if ok, error string otherwise
  */
 public function regrade_final_grades($userid = null)
 {
     global $CFG, $DB;
     // locked grade items already have correct final grades
     if ($this->is_locked()) {
         return true;
     }
     // calculation produces final value using formula from other final values
     if ($this->is_calculated()) {
         if ($this->compute($userid)) {
             return true;
         } else {
             return "Could not calculate grades for grade item";
             // TODO: improve and localize
         }
         // noncalculated outcomes already have final values - raw grades not used
     } else {
         if ($this->is_outcome_item()) {
             return true;
             // aggregate the category grade
         } else {
             if ($this->is_category_item() or $this->is_course_item()) {
                 // aggregate category grade item
                 $category = $this->get_item_category();
                 $category->grade_item =& $this;
                 if ($category->generate_grades($userid)) {
                     return true;
                 } else {
                     return "Could not aggregate final grades for category:" . $this->id;
                     // TODO: improve and localize
                 }
             } else {
                 if ($this->is_manual_item()) {
                     // manual items track only final grades, no raw grades
                     return true;
                 } else {
                     if (!$this->is_raw_used()) {
                         // hmm - raw grades are not used- nothing to regrade
                         return true;
                     }
                 }
             }
         }
     }
     // normal grade item - just new final grades
     $result = true;
     $grade_inst = new grade_grade();
     $fields = implode(',', $grade_inst->required_fields);
     if ($userid) {
         $params = array($this->id, $userid);
         $rs = $DB->get_recordset_select('grade_grades', "itemid=? AND userid=?", $params, '', $fields);
     } else {
         $rs = $DB->get_recordset('grade_grades', array('itemid' => $this->id), '', $fields);
     }
     if ($rs) {
         foreach ($rs as $grade_record) {
             $grade = new grade_grade($grade_record, false);
             if (!empty($grade_record->locked) or !empty($grade_record->overridden)) {
                 // this grade is locked - final grade must be ok
                 continue;
             }
             $grade->finalgrade = $this->adjust_raw_grade($grade->rawgrade, $grade->rawgrademin, $grade->rawgrademax);
             if (grade_floats_different($grade_record->finalgrade, $grade->finalgrade)) {
                 $success = $grade->update('system');
                 // If successful trigger a user_graded event.
                 if ($success) {
                     $grade->load_grade_item();
                     \core\event\user_graded::create_from_grade($grade)->trigger();
                 } else {
                     $result = "Internal error updating final grade";
                 }
             }
         }
         $rs->close();
     }
     return $result;
 }
开发者ID:mongo0se,项目名称:moodle,代码行数:87,代码来源:grade_item.php

示例4: strtolower

 /**
  * Returns latest grades 
  * 
  * @param string $user Username
  * @param int $cid Course identifier
  */
 function get_last_user_grades($username, $limit)
 {
     global $CFG, $DB;
     $username = utf8_decode($username);
     $username = strtolower($username);
     $user = get_complete_user_data('username', $username);
     $uid = $user->id;
     if (!$limit) {
         $limit = 1000;
     }
     $SQL = "SELECT distinct(g.itemid), g.finalgrade,gi.courseid,gi.itemname,gi.id, g.timemodified as tm\n                      FROM {$CFG->prefix}grade_items gi\n                           JOIN {$CFG->prefix}grade_grades g      ON g.itemid = gi.id\n                           JOIN {$CFG->prefix}user u              ON u.id = g.userid\n                           JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id\n                     WHERE g.finalgrade IS NOT NULL \n\t\t     \tand gi.itemname IS NOT NULL\n\t\t\t   AND u.id = ?\n                  \tORDER BY tm\n\t\t\tLIMIT {$limit}";
     $sum_array = array();
     $params = array($uid);
     if ($sums = $DB->get_records_sql($SQL, $params)) {
         $i = 0;
         foreach ($sums as $sum) {
             if (!($grade_grade = grade_grade::fetch(array('itemid' => $sum->id, 'userid' => $uid)))) {
                 $grade_grade = new grade_grade();
                 $grade_grade->userid = $this->user->id;
                 $grade_grade->itemid = $grade_object->id;
             }
             $grade_item = $grade_grade->load_grade_item();
             $scale = $grade_item->load_scale();
             $formatted_grade = grade_format_gradevalue($sum->finalgrade, $grade_item, true, GRADE_DISPLAY_TYPE_REAL);
             $t['itemname'] = $sum->itemname;
             $t['finalgrade'] = $formatted_grade;
             $t['average'] = $this->get_average_grade($grade_grade->itemid);
             $tareas[] = $t;
             $i++;
         }
         return $tareas;
     }
     return array();
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:40,代码来源:auth.php

示例5: fill_table_recursive

 private function fill_table_recursive(&$element)
 {
     global $CFG, $DB;
     $type = $element['type'];
     $depth = $element['depth'];
     $grade_object = $element['object'];
     $eid = $grade_object->id;
     $fullname = $this->gtree->get_element_header($element, true, true, true);
     $data = array();
     $hidden = '';
     $excluded = '';
     $class = '';
     // If this is a hidden grade category, hide it completely from the user
     if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_object->is_hiddenuntil())) {
         return false;
     }
     if ($type == 'category') {
         $this->evenodd[$depth] = ($this->evenodd[$depth] + 1) % 2;
     }
     $alter = $this->evenodd[$depth] == 0 ? 'even' : 'odd';
     /// Process those items that have scores associated
     if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
         if (!($grade_grade = grade_grade::fetch(array('itemid' => $grade_object->id, 'userid' => $this->user->id)))) {
             $grade_grade = new grade_grade();
             $grade_grade->userid = $this->user->id;
             $grade_grade->itemid = $grade_object->id;
         }
         $grade_grade->load_grade_item();
         /// Hidden Items
         if ($grade_grade->grade_item->is_hidden()) {
             $hidden = ' hidden';
         }
         // If this is a hidden grade item, hide it completely from the user.
         if ($grade_grade->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil())) {
             // return false;
         } else {
             /// Excluded Item
             if ($grade_grade->is_excluded()) {
                 $fullname .= ' [' . get_string('excluded', 'grades') . ']';
                 $excluded = ' excluded';
             }
             /// Other class information
             $class = "{$hidden} {$excluded}";
             if ($this->switch) {
                 // alter style based on whether aggregation is first or last
                 $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggt b2b" : " item b1b";
             } else {
                 $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggb" : " item b1b";
             }
             /// Name
             $data['itemname']['content'] = $fullname;
             $data['itemname']['class'] = $class;
             $data['itemname']['colspan'] = $this->maxdepth - $depth;
             /// Actual Grade
             $gradeval = $grade_grade->finalgrade;
             if ($grade_grade->grade_item->needsupdate) {
                 $data['grade']['class'] = $class . ' gradingerror';
                 $data['grade']['content'] = get_string('error');
             } else {
                 if (!empty($CFG->grade_hiddenasdate) and $grade_grade->get_datesubmitted() and !$this->canviewhidden and $grade_grade->is_hidden() and !$grade_grade->grade_item->is_category_item() and !$grade_grade->grade_item->is_course_item()) {
                     // the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
                     $class .= ' datesubmitted';
                     $data['grade']['class'] = $class;
                     $data['grade']['content'] = get_string('submittedon', 'grades', userdate($grade_grade->get_datesubmitted(), get_string('strftimedatetimeshort')));
                 } elseif ($grade_grade->is_hidden()) {
                     $data['grade']['class'] = $class . ' hidden';
                     $data['grade']['content'] = '-';
                 } else {
                     $data['grade']['class'] = $class;
                     $gradeval = $this->blank_hidden_total($this->courseid, $grade_grade->grade_item, $gradeval);
                     $data['grade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true);
                 }
             }
             /// Percentage
             if ($this->showpercentage) {
                 if ($grade_grade->grade_item->needsupdate) {
                     $data['percentage']['class'] = $class . ' gradingerror';
                     $data['percentage']['content'] = get_string('error');
                 } elseif ($grade_grade->is_hidden()) {
                     $data['percentage']['class'] = $class . ' hidden';
                     $data['percentage']['content'] = '-';
                 } else {
                     $data['percentage']['class'] = $class;
                     $data['percentage']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE);
                 }
             }
             /// Rank
             if ($this->showrank) {
                 // TODO: this is broken if hidden grades present!!
                 if ($grade_grade->grade_item->needsupdate) {
                     $data['rank']['class'] = $class . ' gradingerror';
                     $data['rank']['content'] = get_string('error');
                 } elseif ($grade_grade->is_hidden()) {
                     $data['rank']['class'] = $class . ' hidden';
                     $data['rank']['content'] = '-';
                 } else {
                     if (is_null($gradeval)) {
                         // no grade, no rank
                         $data['rank']['class'] = $class;
                         $data['rank']['content'] = '-';
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:lib.php

示例6: fill_table_recursive

 private function fill_table_recursive(&$element)
 {
     global $DB, $CFG;
     $type = $element['type'];
     $depth = $element['depth'];
     $grade_object = $element['object'];
     $eid = $grade_object->id;
     $element['userid'] = $this->user->id;
     $fullname = $this->gtree->get_element_header($element, true, false, true);
     $data = array();
     $hidden = '';
     $excluded = '';
     $class = '';
     $classfeedback = '';
     $row_class = '';
     $activity_start_date = '';
     // If this is a hidden grade category, hide it completely from the user
     if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_MARKSHEET_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_MARKSHEET_HIDE_UNTIL && !$grade_object->is_hiddenuntil())) {
         return false;
     }
     if ($type == 'category') {
         $this->evenodd[$depth] = ($this->evenodd[$depth] + 1) % 2;
     }
     $alter = $this->evenodd[$depth] == 0 ? 'even' : 'odd';
     if ($type == 'item') {
         $cat_id = $grade_object->categoryid;
     } else {
         $cat_id = ' ';
     }
     /// Process those items that have scores associated
     if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
         //&& ($depth == 2)) {
         $header_row = "row_{$eid}_{$this->user->id}";
         $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";
         if (!($grade_grade = grade_grade::fetch(array('itemid' => $grade_object->id, 'userid' => $this->user->id)))) {
             $grade_grade = new grade_grade();
             $grade_grade->userid = $this->user->id;
             $grade_grade->itemid = $grade_object->id;
         }
         $grade_grade->load_grade_item();
         $hide = false;
         // If this is a hidden grade item, hide it completely from the user.
         if ($grade_grade->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_MARKSHEET_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_MARKSHEET_HIDE_UNTIL && !$grade_grade->is_hiddenuntil())) {
             $hide = true;
         } else {
             if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
                 // The grade object can be marked visible but still be hidden if...
                 //  1) "enablegroupmembersonly" is on and the activity is assigned to a grouping the user is not in.
                 //  2) the student cannot see the activity due to conditional access and its set to be hidden entirely.
                 $instances = $this->gtree->modinfo->get_instances_of($grade_object->itemmodule);
                 if (!empty($instances[$grade_object->iteminstance])) {
                     $cm = $instances[$grade_object->iteminstance];
                     if (!$cm->uservisible) {
                         // Further checks are required to determine whether the activity is entirely hidden or just greyed out.
                         if ($cm->is_user_access_restricted_by_group() || $cm->is_user_access_restricted_by_conditional_access() || $cm->is_user_access_restricted_by_capability()) {
                             $hide = true;
                         }
                     }
                 }
             }
         }
         if ($grade_grade->grade_item->is_hidden() && !$this->showhiddenactivity) {
             $hide = true;
         }
         //set start dates by category
         $categoryid = $grade_grade->grade_item->categoryid;
         if ($type == 'item' && isset($cm)) {
             $this->grade_category_modids[$categoryid][] = $cm->id;
         }
         /// Hidden Items
         if ($grade_grade->grade_item->is_hidden()) {
             $hidden = ' hidden';
         }
         if (!$hide) {
             /// Excluded Item
             if ($grade_grade->is_excluded()) {
                 $fullname .= ' [' . get_string('excluded', 'grades') . ']';
                 $excluded = ' excluded';
             }
             if (isset($grade_grade->grade_item->itemmodule)) {
                 $modname = $grade_grade->grade_item->itemmodule;
             }
             if (isset($cm)) {
                 $modid = $cm->id;
             }
             if ($type == "categoryitem") {
                 // print_r($grade_grade);
                 // $timemodified = $grade_grade->grade_item->timemodified;
                 // $activity_start_date = new DateTime('@'.$timemodified);
                 // print_r($activity_start_date);
                 echo "<br>";
             }
             /// Other class information
             if (isset($modname) && isset($modid)) {
                 $modaction = "view";
                 $course = $this->course;
                 $user = $this->user->id;
                 $activity_start_date = get_activity_start_date($course, $user, $modname, $modaction, $modid);
             }
             if ($type == 'item') {
//.........这里部分代码省略.........
开发者ID:abhiahirwar,项目名称:moodle_plugin,代码行数:101,代码来源:lib.php

示例7: array

         die;
     } else {
         $json_object->gradevalue = $finalvalue;
         $old_grade_grade = new grade_grade(array('userid' => $userid, 'itemid' => $grade_item->id), true);
         if ($grade_item->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE)) {
             $json_object->result = 'success';
             $json_object->message = false;
         } else {
             $json_object->result = 'error';
             $json_object->message = "TO BE LOCALISED: Failure to update final grade!";
             echo json_encode($json_object);
             die;
         }
         $grade_grade = new grade_grade(array('userid' => $userid, 'itemid' => $grade_item->id), true);
         if ($old_grade_grade->finalgrade != $grade_grade->finalgrade or empty($old_grade_grade->overridden) != empty($grade_grade->overridden)) {
             $grade_grade->load_grade_item();
             \core\event\user_graded::create_from_grade($grade_grade)->trigger();
         }
         // Get row data
         $sql = "SELECT gg.id, gi.id AS itemid, gi.scaleid AS scale, gg.userid AS userid, finalgrade, gg.overridden AS overridden " . "FROM {grade_grades} gg, {grade_items} gi WHERE " . "gi.courseid = ? AND gg.itemid = gi.id AND gg.userid = ?";
         $records = $DB->get_records_sql($sql, array($courseid, $userid));
         $json_object->row = $records;
         echo json_encode($json_object);
         die;
     }
 } else {
     $json_object = new stdClass();
     $json_object->result = "error";
     $json_object->message = "Missing parameter to ajax UPDATE callback: \n" . "  userid: {$userid},\n  itemid: {$itemid}\n,  type: {$type}\n,  newvalue: {$newvalue}";
     echo json_encode($json_object);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:ajax_callbacks.php

示例8: fill_table_recursive

    /**
     * Fill the table with data.
     *
     * @param $element - An array containing the table data for the current row.
     */
    private function fill_table_recursive(&$element) {
        global $DB, $CFG;

        $type = $element['type'];
        $depth = $element['depth'];
        $grade_object = $element['object'];
        $eid = $grade_object->id;
        $element['userid'] = $this->user->id;
        $fullname = $this->gtree->get_element_header($element, true, true, true, true, true);
        $data = array();
        $hidden = '';
        $excluded = '';
        $itemlevel = ($type == 'categoryitem' || $type == 'category' || $type == 'courseitem') ? $depth : ($depth + 1);
        $class = 'level' . $itemlevel . ' level' . ($itemlevel % 2 ? 'odd' : 'even');
        $classfeedback = '';

        // If this is a hidden grade category, hide it completely from the user
        if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && (
                $this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN ||
                ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_object->is_hiddenuntil()))) {
            return false;
        }

        if ($type == 'category') {
            $this->evenodd[$depth] = (($this->evenodd[$depth] + 1) % 2);
        }
        $alter = ($this->evenodd[$depth] == 0) ? 'even' : 'odd';

        /// Process those items that have scores associated
        if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
            $header_row = "row_{$eid}_{$this->user->id}";
            $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";

            if (! $grade_grade = grade_grade::fetch(array('itemid'=>$grade_object->id,'userid'=>$this->user->id))) {
                $grade_grade = new grade_grade();
                $grade_grade->userid = $this->user->id;
                $grade_grade->itemid = $grade_object->id;
            }

            $grade_grade->load_grade_item();

            /// Hidden Items
            if ($grade_grade->grade_item->is_hidden()) {
                $hidden = ' dimmed_text';
            }

            $hide = false;
            // If this is a hidden grade item, hide it completely from the user.
            if ($grade_grade->is_hidden() && !$this->canviewhidden && (
                    $this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN ||
                    ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil()))) {
                $hide = true;
            } else if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
                // The grade object can be marked visible but still be hidden if
                // the student cannot see the activity due to conditional access
                // and it's set to be hidden entirely.
                $instances = $this->modinfo->get_instances_of($grade_object->itemmodule);
                if (!empty($instances[$grade_object->iteminstance])) {
                    $cm = $instances[$grade_object->iteminstance];
                    if (!$cm->uservisible) {
                        // If there is 'availableinfo' text then it is only greyed
                        // out and not entirely hidden.
                        if (!$cm->availableinfo) {
                            $hide = true;
                        }
                    }
                }
            }

            // Actual Grade - We need to calculate this whether the row is hidden or not.
            $gradeval = $grade_grade->finalgrade;
            $hint = $grade_grade->get_aggregation_hint();
            if (!$this->canviewhidden) {
                /// Virtual Grade (may be calculated excluding hidden items etc).
                $adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid,
                                                                             $grade_grade->grade_item,
                                                                             $gradeval);

                $gradeval = $adjustedgrade['grade'];

                // We temporarily adjust the view of this grade item - because the min and
                // max are affected by the hidden values in the aggregation.
                $grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
                $grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
                $hint['status'] = $adjustedgrade['aggregationstatus'];
                $hint['weight'] = $adjustedgrade['aggregationweight'];
            } else {
                // The max and min for an aggregation may be different to the grade_item.
                if (!is_null($gradeval)) {
                    $grade_grade->grade_item->grademax = $grade_grade->rawgrademax;
                    $grade_grade->grade_item->grademin = $grade_grade->rawgrademin;
                }
            }


//.........这里部分代码省略.........
开发者ID:anilch,项目名称:Personel,代码行数:101,代码来源:lib.php


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