⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
                           JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id                           $groupsql                     WHERE gi.courseid = $this->courseid                           AND ra.roleid in ($this->gradebookroles)                           AND ra.contextid ".get_related_contexts_string($this->context)."                           AND g.finalgrade IS NOT NULL                           $groupwheresql                  GROUP BY g.itemid";            $sum_array = array();            if ($sums = get_records_sql($SQL)) {                foreach ($sums as $itemid => $csum) {                    $sum_array[$itemid] = $csum->sum;                }            }            $columncount=0;            $colspan='';            if ($showuseridnumber) {                $colspan = 'colspan="2" ';            }            $avghtml = '<tr class="' . $avgcssclass . ' r'.$this->rowcount++.'"><th class="header c0" '.$colspan.'scope="row">'.$straverage.'</th>';            if ($showuseridnumber) {                $columncount++;            }            // MDL-10875 Empty grades must be evaluated as grademin, NOT always 0            // This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table)            $SQL = "SELECT gi.id, COUNT(u.id) AS count                      FROM {$CFG->prefix}grade_items gi                           CROSS JOIN {$CFG->prefix}user u                           JOIN {$CFG->prefix}role_assignments ra        ON ra.userid = u.id                           LEFT OUTER JOIN  {$CFG->prefix}grade_grades g ON (g.itemid = gi.id AND g.userid = u.id AND g.finalgrade IS NOT NULL)                           $groupsql                     WHERE gi.courseid = $this->courseid                           AND ra.roleid in ($this->gradebookroles)                           AND ra.contextid ".get_related_contexts_string($this->context)."                           AND g.id IS NULL                           $groupwheresql                  GROUP BY gi.id";            $ungraded_counts = get_records_sql($SQL);            foreach ($this->gtree->items as $itemid=>$unused) {                $item =& $this->gtree->items[$itemid];                if ($item->needsupdate) {                    $avghtml .= '<td class="cell c' . $columncount++.'"><span class="gradingerror">'.get_string('error').'</span></td>';                    continue;                }                if (!isset($sum_array[$item->id])) {                    $sum_array[$item->id] = 0;                }                if (empty($ungraded_counts[$itemid])) {                    $ungraded_count = 0;                } else {                    $ungraded_count = $ungraded_counts[$itemid]->count;                }                if ($meanselection == GRADE_REPORT_MEAN_GRADED) {                    $mean_count = $totalcount - $ungraded_count;                } else { // Bump up the sum by the number of ungraded items * grademin                    $sum_array[$item->id] += $ungraded_count * $item->grademin;                    $mean_count = $totalcount;                }                $decimalpoints = $item->get_decimals();                // Determine which display type to use for this average                if ($USER->gradeediting[$this->courseid]) {                    $displaytype = GRADE_DISPLAY_TYPE_REAL;                } else if ($averagesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // no ==0 here, please resave the report and user preferences                    $displaytype = $item->get_displaytype();                } else {                    $displaytype = $averagesdisplaytype;                }                // Override grade_item setting if a display preference (not inherit) was set for the averages                if ($averagesdecimalpoints == GRADE_REPORT_PREFERENCE_INHERIT) {                    $decimalpoints = $item->get_decimals();                } else {                    $decimalpoints = $averagesdecimalpoints;                }                if (!isset($sum_array[$item->id]) || $mean_count == 0) {                    $avghtml .= '<td class="cell c' . $columncount++.'">-</td>';                } else {                    $sum = $sum_array[$item->id];                    $avgradeval = $sum/$mean_count;                    $gradehtml = grade_format_gradevalue($avgradeval, $item, true, $displaytype, $decimalpoints);                    $numberofgrades = '';                    if ($shownumberofgrades) {                        $numberofgrades = " ($mean_count)";                    }                    $avghtml .= '<td class="cell c' . $columncount++.'">'.$gradehtml.$numberofgrades.'</td>';                }            }            $avghtml .= '</tr>';        }        return $avghtml;    }    /**     * Builds and return the HTML row of ranges for each column (i.e. range).     * @return string HTML     */    function get_rangehtml() {        global $USER;        $showuseridnumber      = $this->get_pref('showuseridnumber');        $scalehtml = '';        if ($this->get_pref('showranges')) {            $rangesdisplaytype   = $this->get_pref('rangesdisplaytype');            $rangesdecimalpoints = $this->get_pref('rangesdecimalpoints');            $columncount=0;            $colspan='';            if ($showuseridnumber) {                $colspan = 'colspan="2" ';            }            $scalehtml = '<tr class="r'.$this->rowcount++.'">'                       . '<th class="header c0 range" '.$colspan.'scope="row">'.$this->get_lang_string('range','grades').'</th>';            if ($showuseridnumber) {                $columncount++;            }            foreach ($this->gtree->items as $itemid=>$unused) {                $item =& $this->gtree->items[$itemid];                $hidden = '';                if ($item->is_hidden()) {                    $hidden = ' hidden ';                }                $formatted_range = $item->get_formatted_range($rangesdisplaytype, $rangesdecimalpoints);                $scalehtml .= '<th class="header c'.$columncount++.' range"><span class="rangevalues'.$hidden.'">'. $formatted_range .'</span></th>';            }            $scalehtml .= '</tr>';        }        return $scalehtml;    }    /**     * Builds and return the HTML row of ranges for each column (i.e. range).     * @return string HTML     */    function get_iconshtml() {        global $USER;        $iconshtml = '';        if ($USER->gradeediting[$this->courseid]) {            $colspan='';            if ($this->get_pref('showuseridnumber')) {                $colspan = 'colspan="2" ';            }            $iconshtml = '<tr class="r'.$this->rowcount++.'">'                       . '<th class="header c0 range" scope="row" '.$colspan.'>'.$this->get_lang_string('controls','grades').'</th>';            $columncount = 1;            foreach ($this->gtree->items as $itemid=>$unused) {                // emulate grade element                $item =& $this->gtree->items[$itemid];                $eid = $this->gtree->get_item_eid($item);                $element = $this->gtree->locate_element($eid);                $iconshtml .= '<td class="cell c'.$columncount++.' icons">' . $this->get_icons($element) . '</td>';            }            $iconshtml .= '</tr>';        }        return $iconshtml;    }    /**     * Given a grade_category, grade_item or grade_grade, this function     * figures out the state of the object and builds then returns a div     * with the icons needed for the grader report.     *     * @param object $object     * @return string HTML     */    function get_icons($element) {        global $CFG, $USER;        if (!$USER->gradeediting[$this->courseid]) {            return '<div class="grade_icons" />';        }        // Init all icons        $edit_icon             = $this->gtree->get_edit_icon($element, $this->gpr);        $edit_calculation_icon = '';        $show_hide_icon        = '';        $lock_unlock_icon      = '';        if (has_capability('moodle/grade:manage', $this->context)) {            if ($this->get_pref('showcalculations')) {                $edit_calculation_icon = $this->gtree->get_calculation_icon($element, $this->gpr);            }            if ($this->get_pref('showeyecons')) {               $show_hide_icon = $this->gtree->get_hiding_icon($element, $this->gpr);            }            if ($this->get_pref('showlocks')) {                $lock_unlock_icon = $this->gtree->get_locking_icon($element, $this->gpr);            }        }        return '<div class="grade_icons">'.$edit_icon.$edit_calculation_icon.$show_hide_icon.$lock_unlock_icon.'</div>';    }    /**     * Given a category element returns collapsing +/- icon if available     * @param object $object     * @return string HTML     */    function get_collapsing_icon($element) {        global $CFG;        $contract_expand_icon = '';        // If object is a category, display expand/contract icon        if ($element['type'] == 'category') {            // Load language strings            $strswitch_minus = $this->get_lang_string('aggregatesonly', 'grades');            $strswitch_plus  = $this->get_lang_string('gradesonly', 'grades');            $strswitch_whole = $this->get_lang_string('fullmode', 'grades');            $expand_contract = 'switch_minus'; // Default: expanded            // $this->get_pref('aggregationview', $element['object']->id) == GRADE_REPORT_AGGREGATION_VIEW_COMPACT            if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) {                $expand_contract = 'switch_plus';            } elseif (in_array($element['object']->id, $this->collapsed['gradesonly'])) {                $expand_contract = 'switch_whole';            }            $url = $this->gpr->get_return_url(null, array('target'=>$element['eid'], 'action'=>$expand_contract, 'sesskey'=>sesskey()));            $contract_expand_icon = '<a href="'.$url.'"><img src="'.$CFG->pixpath.'/t/'.$expand_contract.'.gif" class="iconsmall" alt="'                                    .${'str'.$expand_contract}.'" title="'.${'str'.$expand_contract}.'" /></a>';        }        return $contract_expand_icon;    }    /**     * Processes a single action against a category, grade_item or grade.     * @param string $target eid ({type}{id}, e.g. c4 for category4)     * @param string $action Which action to take (edit, delete etc...)     * @return     */    function process_action($target, $action) {        // TODO: this code should be in some grade_tree static method        $targettype = substr($target, 0, 1);        $targetid = substr($target, 1);        // TODO: end        if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {            $collapsed = unserialize($collapsed);        } else {            $collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());        }        switch ($action) {            case 'switch_minus': // Add category to array of aggregatesonly                if (!in_array($targetid, $collapsed['aggregatesonly'])) {                    $collapsed['aggregatesonly'][] = $targetid;                    set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));                }                break;            case 'switch_plus': // Remove category from array of aggregatesonly, and add it to array of gradesonly                $key = array_search($targetid, $collapsed['aggregatesonly']);                if ($key !== false) {                    unset($collapsed['aggregatesonly'][$key]);                }                if (!in_array($targetid, $collapsed['gradesonly'])) {                    $collapsed['gradesonly'][] = $targetid;                }                set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));                break;            case 'switch_whole': // Remove the category from the array of collapsed cats                $key = array_search($targetid, $collapsed['gradesonly']);                if ($key !== false) {                    unset($collapsed['gradesonly'][$key]);                    set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsed));                }                break;            default:                break;        }        return true;    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -