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


PHP grade_helper::get_aggregation_strings方法代码示例

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


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

示例1: get_element_icon

 /**
  * Returns icon of element
  *
  * @param array &$element An array representing an element in the grade_tree
  * @param bool  $spacerifnone return spacer if no icon found
  *
  * @return string icon or spacer
  */
 public function get_element_icon(&$element, $spacerifnone = false)
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/filelib.php';
     switch ($element['type']) {
         case 'item':
         case 'courseitem':
         case 'categoryitem':
             $is_course = $element['object']->is_course_item();
             $is_category = $element['object']->is_category_item();
             $is_scale = $element['object']->gradetype == GRADE_TYPE_SCALE;
             $is_value = $element['object']->gradetype == GRADE_TYPE_VALUE;
             $is_outcome = !empty($element['object']->outcomeid);
             if ($element['object']->is_calculated()) {
                 $strcalc = get_string('calculatedgrade', 'grades');
                 return '<img src="' . $OUTPUT->pix_url('i/calc') . '" class="icon itemicon" title="' . s($strcalc) . '" alt="' . s($strcalc) . '"/>';
             } else {
                 if (($is_course or $is_category) and ($is_scale or $is_value)) {
                     if ($category = $element['object']->get_item_category()) {
                         $aggrstrings = grade_helper::get_aggregation_strings();
                         $stragg = $aggrstrings[$category->aggregation];
                         switch ($category->aggregation) {
                             case GRADE_AGGREGATE_MEAN:
                             case GRADE_AGGREGATE_MEDIAN:
                             case GRADE_AGGREGATE_WEIGHTED_MEAN:
                             case GRADE_AGGREGATE_WEIGHTED_MEAN2:
                             case GRADE_AGGREGATE_EXTRACREDIT_MEAN:
                                 return '<img src="' . $OUTPUT->pix_url('i/agg_mean') . '" ' . 'class="icon itemicon" title="' . s($stragg) . '" alt="' . s($stragg) . '"/>';
                             case GRADE_AGGREGATE_SUM:
                                 return '<img src="' . $OUTPUT->pix_url('i/agg_sum') . '" ' . 'class="icon itemicon" title="' . s($stragg) . '" alt="' . s($stragg) . '"/>';
                             default:
                                 return '<img src="' . $OUTPUT->pix_url('i/calc') . '" ' . 'class="icon itemicon" title="' . s($stragg) . '" alt="' . s($stragg) . '"/>';
                         }
                     }
                 } else {
                     if ($element['object']->itemtype == 'mod') {
                         //prevent outcomes being displaying the same icon as the activity they are attached to
                         if ($is_outcome) {
                             $stroutcome = s(get_string('outcome', 'grades'));
                             return '<img src="' . $OUTPUT->pix_url('i/outcomes') . '" ' . 'class="icon itemicon" title="' . $stroutcome . '" alt="' . $stroutcome . '"/>';
                         } else {
                             $strmodname = get_string('modulename', $element['object']->itemmodule);
                             return '<img src="' . $OUTPUT->pix_url('icon', $element['object']->itemmodule) . '" ' . 'class="icon itemicon" title="' . s($strmodname) . '" alt="' . s($strmodname) . '"/>';
                         }
                     } else {
                         if ($element['object']->itemtype == 'manual') {
                             if ($element['object']->is_outcome_item()) {
                                 $stroutcome = get_string('outcome', 'grades');
                                 return '<img src="' . $OUTPUT->pix_url('i/outcomes') . '" ' . 'class="icon itemicon" title="' . s($stroutcome) . '" alt="' . s($stroutcome) . '"/>';
                             } else {
                                 $strmanual = get_string('manualitem', 'grades');
                                 return '<img src="' . $OUTPUT->pix_url('i/manual_item') . '" ' . 'class="icon itemicon" title="' . s($strmanual) . '" alt="' . s($strmanual) . '"/>';
                             }
                         }
                     }
                 }
             }
             break;
         case 'category':
             $strcat = get_string('category', 'grades');
             return '<img src="' . $OUTPUT->pix_url('i/folder') . '" class="icon itemicon" ' . 'title="' . s($strcat) . '" alt="' . s($strcat) . '" />';
     }
     if ($spacerifnone) {
         return $OUTPUT->spacer() . ' ';
     } else {
         return '';
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:76,代码来源:lib.php

示例2: get_description

 /**
  * Describe the aggregation settings for this category so the reports make more sense.
  *
  * @return string description
  */
 public function get_description()
 {
     $allhelp = array();
     if ($this->aggregation != GRADE_AGGREGATE_SUM) {
         $aggrstrings = grade_helper::get_aggregation_strings();
         $allhelp[] = $aggrstrings[$this->aggregation];
     }
     if ($this->droplow && $this->can_apply_limit_rules()) {
         $allhelp[] = get_string('droplowestvalues', 'grades', $this->droplow);
     }
     if ($this->keephigh && $this->can_apply_limit_rules()) {
         $allhelp[] = get_string('keephighestvalues', 'grades', $this->keephigh);
     }
     if (!$this->aggregateonlygraded) {
         $allhelp[] = get_string('aggregatenotonlygraded', 'grades');
     }
     if ($this->aggregatesubcats) {
         $allhelp[] = get_string('aggregatesubcatsshort', 'grades');
     }
     if ($allhelp) {
         return implode('. ', $allhelp) . '.';
     }
     return '';
 }
开发者ID:jtibbetts,项目名称:moodle,代码行数:29,代码来源:grade_category.php

示例3: get_element_icon

 /**
  * Returns icon of element
  *
  * @param array &$element An array representing an element in the grade_tree
  * @param bool  $spacerifnone return spacer if no icon found
  *
  * @return string icon or spacer
  */
 public function get_element_icon(&$element, $spacerifnone = false)
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/filelib.php';
     $outputstr = '';
     // Object holding pix_icon information before instantiation.
     $icon = new stdClass();
     $icon->attributes = array('class' => 'icon itemicon');
     $icon->component = 'moodle';
     $none = true;
     switch ($element['type']) {
         case 'item':
         case 'courseitem':
         case 'categoryitem':
             $none = false;
             $is_course = $element['object']->is_course_item();
             $is_category = $element['object']->is_category_item();
             $is_scale = $element['object']->gradetype == GRADE_TYPE_SCALE;
             $is_value = $element['object']->gradetype == GRADE_TYPE_VALUE;
             $is_outcome = !empty($element['object']->outcomeid);
             if ($element['object']->is_calculated()) {
                 $icon->pix = 'i/calc';
                 $icon->title = s(get_string('calculatedgrade', 'grades'));
             } else {
                 if (($is_course or $is_category) and ($is_scale or $is_value)) {
                     if ($category = $element['object']->get_item_category()) {
                         $aggrstrings = grade_helper::get_aggregation_strings();
                         $stragg = $aggrstrings[$category->aggregation];
                         $icon->pix = 'i/calc';
                         $icon->title = s($stragg);
                         switch ($category->aggregation) {
                             case GRADE_AGGREGATE_MEAN:
                             case GRADE_AGGREGATE_MEDIAN:
                             case GRADE_AGGREGATE_WEIGHTED_MEAN:
                             case GRADE_AGGREGATE_WEIGHTED_MEAN2:
                             case GRADE_AGGREGATE_EXTRACREDIT_MEAN:
                                 $icon->pix = 'i/agg_mean';
                                 break;
                             case GRADE_AGGREGATE_SUM:
                                 $icon->pix = 'i/agg_sum';
                                 break;
                         }
                     }
                 } else {
                     if ($element['object']->itemtype == 'mod') {
                         // Prevent outcomes displaying the same icon as the activity they are attached to.
                         if ($is_outcome) {
                             $icon->pix = 'i/outcomes';
                             $icon->title = s(get_string('outcome', 'grades'));
                         } else {
                             $icon->pix = 'icon';
                             $icon->component = $element['object']->itemmodule;
                             $icon->title = s(get_string('modulename', $element['object']->itemmodule));
                         }
                     } else {
                         if ($element['object']->itemtype == 'manual') {
                             if ($element['object']->is_outcome_item()) {
                                 $icon->pix = 'i/outcomes';
                                 $icon->title = s(get_string('outcome', 'grades'));
                             } else {
                                 $icon->pix = 'i/manual_item';
                                 $icon->title = s(get_string('manualitem', 'grades'));
                             }
                         }
                     }
                 }
             }
             break;
         case 'category':
             $none = false;
             $icon->pix = 'i/folder';
             $icon->title = s(get_string('category', 'grades'));
             break;
     }
     if ($none) {
         if ($spacerifnone) {
             $outputstr = $OUTPUT->spacer() . ' ';
         }
     } else {
         $outputstr = $OUTPUT->pix_icon($icon->pix, $icon->title, $icon->component, $icon->attributes);
     }
     return $outputstr;
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:91,代码来源:lib.php

示例4: definition

 function definition()
 {
     global $CFG, $COURSE, $DB, $OUTPUT;
     $mform =& $this->_form;
     $category = $this->_customdata['current'];
     $this->aggregation_options = grade_helper::get_aggregation_strings();
     // visible elements
     $mform->addElement('header', 'headercategory', get_string('gradecategory', 'grades'));
     $mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
     $mform->setType('fullname', PARAM_TEXT);
     $mform->addRule('fullname', null, 'required', null, 'client');
     $mform->addElement('select', 'aggregation', get_string('aggregation', 'grades'), $this->aggregation_options);
     $mform->addHelpButton('aggregation', 'aggregation', 'grades');
     if ((int) $CFG->grade_aggregation_flag & 2) {
         $mform->setAdvanced('aggregation');
     }
     $mform->addElement('checkbox', 'aggregateonlygraded', get_string('aggregateonlygraded', 'grades'));
     $mform->addHelpButton('aggregateonlygraded', 'aggregateonlygraded', 'grades');
     if ((int) $CFG->grade_aggregateonlygraded_flag & 2) {
         $mform->setAdvanced('aggregateonlygraded');
     }
     if (empty($CFG->enableoutcomes)) {
         $mform->addElement('hidden', 'aggregateoutcomes');
         $mform->setType('aggregateoutcomes', PARAM_INT);
     } else {
         $mform->addElement('checkbox', 'aggregateoutcomes', get_string('aggregateoutcomes', 'grades'));
         $mform->addHelpButton('aggregateoutcomes', 'aggregateoutcomes', 'grades');
         if ((int) $CFG->grade_aggregateoutcomes_flag & 2) {
             $mform->setAdvanced('aggregateoutcomes');
         }
     }
     $mform->addElement('text', 'keephigh', get_string('keephigh', 'grades'), 'size="3"');
     $mform->setType('keephigh', PARAM_INT);
     $mform->addHelpButton('keephigh', 'keephigh', 'grades');
     if ((int) $CFG->grade_keephigh_flag & 2) {
         $mform->setAdvanced('keephigh');
     }
     $mform->addElement('text', 'droplow', get_string('droplow', 'grades'), 'size="3"');
     $mform->setType('droplow', PARAM_INT);
     $mform->addHelpButton('droplow', 'droplow', 'grades');
     $mform->disabledIf('droplow', 'keephigh', 'noteq', 0);
     if ((int) $CFG->grade_droplow_flag & 2) {
         $mform->setAdvanced('droplow');
     }
     $mform->disabledIf('keephigh', 'droplow', 'noteq', 0);
     $mform->disabledIf('droplow', 'keephigh', 'noteq', 0);
     // Grade item settings
     // Displayed as Category total to avoid confusion between grade items requiring marking and category totals
     $mform->addElement('header', 'general', get_string('categorytotal', 'grades'));
     $mform->addElement('text', 'grade_item_itemname', get_string('categorytotalname', 'grades'));
     $mform->setType('grade_item_itemname', PARAM_TEXT);
     $mform->setAdvanced('grade_item_itemname');
     $mform->addElement('text', 'grade_item_iteminfo', get_string('iteminfo', 'grades'));
     $mform->addHelpButton('grade_item_iteminfo', 'iteminfo', 'grades');
     $mform->setType('grade_item_iteminfo', PARAM_TEXT);
     $mform->addElement('text', 'grade_item_idnumber', get_string('idnumbermod'));
     $mform->addHelpButton('grade_item_idnumber', 'idnumbermod');
     $mform->setType('grade_item_idnumber', PARAM_RAW);
     if (!empty($category->id)) {
         $gradecategory = grade_category::fetch(array('id' => $category->id));
         $gradeitem = $gradecategory->load_grade_item();
         // If grades exist set a message so the user knows why they can not alter the grade type or scale.
         // We could never change the grade type for external items, so only need to show this for manual grade items.
         if ($gradeitem->has_overridden_grades()) {
             // Set a message so the user knows why the can not alter the grade type or scale.
             if ($gradeitem->gradetype == GRADE_TYPE_SCALE) {
                 $gradesexistmsg = get_string('modgradecategorycantchangegradetyporscalemsg', 'grades');
             } else {
                 $gradesexistmsg = get_string('modgradecategorycantchangegradetypemsg', 'grades');
             }
             $notification = new \core\output\notification($gradesexistmsg, \core\output\notification::NOTIFY_INFO);
             $notification->set_show_closebutton(false);
             $mform->addElement('static', 'gradesexistmsg', '', $OUTPUT->render($notification));
         }
     }
     $options = array(GRADE_TYPE_NONE => get_string('typenone', 'grades'), GRADE_TYPE_VALUE => get_string('typevalue', 'grades'), GRADE_TYPE_SCALE => get_string('typescale', 'grades'), GRADE_TYPE_TEXT => get_string('typetext', 'grades'));
     $mform->addElement('select', 'grade_item_gradetype', get_string('gradetype', 'grades'), $options);
     $mform->addHelpButton('grade_item_gradetype', 'gradetype', 'grades');
     $mform->setDefault('grade_item_gradetype', GRADE_TYPE_VALUE);
     $mform->disabledIf('grade_item_gradetype', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
     //$mform->addElement('text', 'calculation', get_string('calculation', 'grades'));
     //$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     //$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $options = array(0 => get_string('usenoscale', 'grades'));
     if ($scales = grade_scale::fetch_all_local($COURSE->id)) {
         foreach ($scales as $scale) {
             $options[$scale->id] = $scale->get_name();
         }
     }
     if ($scales = grade_scale::fetch_all_global()) {
         foreach ($scales as $scale) {
             $options[$scale->id] = $scale->get_name();
         }
     }
     // ugly BC hack - it was possible to use custom scale from other courses :-(
     if (!empty($category->grade_item_scaleid) and !isset($options[$category->grade_item_scaleid])) {
         if ($scale = grade_scale::fetch(array('id' => $category->grade_item_scaleid))) {
             $options[$scale->id] = $scale->get_name() . ' ' . get_string('incorrectcustomscale', 'grades');
         }
     }
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:category_form.php


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