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


PHP grade_scale::fetch方法代码示例

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


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

示例1: validation

 function validation($data)
 {
     global $CFG, $COURSE;
     $errors = array();
     // we can not allow 2 scales with the same exact scale as this creates
     // problems for backup/restore
     $old = grade_scale::fetch(array('id' => $data['id']));
     if (array_key_exists('standard', $data)) {
         if (empty($data['standard'])) {
             $courseid = $COURSE->id;
         } else {
             $courseid = 0;
         }
     } else {
         $courseid = $old->courseid;
     }
     if (array_key_exists('scale', $data)) {
         $count = count_records('scale', 'courseid', $courseid, 'scale', $data['scale']);
         if (empty($old->id) or $old->courseid != $courseid) {
             if ($count) {
                 $errors['scale'] = get_string('duplicatescale', 'grades');
             }
         } else {
             if ($old->scale != $data['scale']) {
                 if ($count) {
                     $errors['scale'] = get_string('duplicatescale', 'grades');
                 }
             }
         }
         $options = explode(',', $data['scale']);
         if (count($options) < 2) {
             $errors['scale'] = get_string('error');
         }
     }
     if (0 == count($errors)) {
         return true;
     } else {
         return $errors;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:40,代码来源:edit_form.php

示例2: sub_test_grade_scale_fetch

 function sub_test_grade_scale_fetch()
 {
     $grade_scale = new grade_scale();
     $this->assertTrue(method_exists($grade_scale, 'fetch'));
     $grade_scale = grade_scale::fetch(array('id' => $this->scale[0]->id));
     $this->assertEqual($this->scale[0]->id, $grade_scale->id);
     $this->assertEqual($this->scale[0]->name, $grade_scale->name);
 }
开发者ID:robadobdob,项目名称:moodle,代码行数:8,代码来源:testgradescale.php

示例3: load_scale

 /**
  * Instantiates a grade_scale object whose data is retrieved from the
  * @return object grade_scale
  */
 function load_scale()
 {
     if (empty($this->scale->id) or $this->scale->id != $this->scaleid) {
         $this->scale = grade_scale::fetch(array('id' => $this->scaleid));
         $this->scale->load_items();
     }
     return $this->scale;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:12,代码来源:grade_outcome.php

示例4: load_scale

 /**
  * Instantiates a grade_scale object whose data is retrieved from the DB,
  * if this item's scaleid variable is set.
  * @return object grade_scale or null if no scale used
  */
 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:r007,项目名称:PMoodle,代码行数:30,代码来源:grade_item.php

示例5: definition

 function definition()
 {
     global $COURSE, $CFG, $DB;
     $mform =& $this->_form;
     $item = $this->_customdata['current'];
     /// visible elements
     $mform->addElement('header', 'general', get_string('gradeitem', 'grades'));
     $mform->addElement('text', 'itemname', get_string('itemname', 'grades'));
     $mform->addElement('text', 'iteminfo', get_string('iteminfo', 'grades'));
     $mform->setHelpButton('iteminfo', array('iteminfo', get_string('iteminfo', 'grades'), 'grade'), true);
     $mform->addElement('text', 'idnumber', get_string('idnumbermod'));
     $mform->setHelpButton('idnumber', array('idnumber', get_string('idnumber', 'grades'), 'grade'), true);
     $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', 'gradetype', get_string('gradetype', 'grades'), $options);
     $mform->setHelpButton('gradetype', array('gradetype', get_string('gradetype', 'grades'), 'grade'), true);
     $mform->setDefault('gradetype', GRADE_TYPE_VALUE);
     //$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 possbile to use custom scale from other courses :-(
     if (!empty($item->scaleid) and !isset($options[$item->scaleid])) {
         if ($scale = grade_scale::fetch(array('id' => $item->scaleid))) {
             $options[$scale->id] = $scale->get_name() . get_string('incorrectcustomscale', 'grades');
         }
     }
     $mform->addElement('select', 'scaleid', get_string('scale'), $options);
     $mform->setHelpButton('scaleid', array('scaleid', get_string('scaleid', 'grades'), 'grade'), true);
     $mform->disabledIf('scaleid', 'gradetype', 'noteq', GRADE_TYPE_SCALE);
     $mform->addElement('text', 'grademax', get_string('grademax', 'grades'));
     $mform->setHelpButton('grademax', array('grademax', get_string('grademax', 'grades'), 'grade'), true);
     $mform->disabledIf('grademax', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
     $mform->addElement('text', 'grademin', get_string('grademin', 'grades'));
     $mform->setHelpButton('grademin', array('grademin', get_string('grademin', 'grades'), 'grade'), true);
     $mform->disabledIf('grademin', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
     $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
     $mform->setHelpButton('gradepass', array('gradepass', get_string('gradepass', 'grades'), 'grade'), true);
     $mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     $mform->addElement('text', 'multfactor', get_string('multfactor', 'grades'));
     $mform->setHelpButton('multfactor', array('multfactor', get_string('multfactor', 'grades'), 'grade'), true);
     $mform->setAdvanced('multfactor');
     $mform->disabledIf('multfactor', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $mform->disabledIf('multfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     $mform->addElement('text', 'plusfactor', get_string('plusfactor', 'grades'));
     $mform->setHelpButton('plusfactor', array('plusfactor', get_string('plusfactor', 'grades'), 'grade'), true);
     $mform->setAdvanced('plusfactor');
     $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     /// grade display prefs
     $default_gradedisplaytype = grade_get_setting($COURSE->id, 'displaytype', $CFG->grade_displaytype);
     $options = array(GRADE_DISPLAY_TYPE_DEFAULT => get_string('default', 'grades'), GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'), GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => get_string('realpercentage', 'grades'), GRADE_DISPLAY_TYPE_REAL_LETTER => get_string('realletter', 'grades'), GRADE_DISPLAY_TYPE_LETTER_REAL => get_string('letterreal', 'grades'), GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => get_string('letterpercentage', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => get_string('percentageletter', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => get_string('percentagereal', 'grades'));
     asort($options);
     foreach ($options as $key => $option) {
         if ($key == $default_gradedisplaytype) {
             $options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
             break;
         }
     }
     $mform->addElement('select', 'display', get_string('gradedisplaytype', 'grades'), $options);
     $mform->setHelpButton('display', array('gradedisplaytype', get_string('gradedisplaytype', 'grades'), 'grade'), true);
     $default_gradedecimals = grade_get_setting($COURSE->id, 'decimalpoints', $CFG->grade_decimalpoints);
     $options = array(-1 => get_string('defaultprev', 'grades', $default_gradedecimals), 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5);
     $mform->addElement('select', 'decimals', get_string('decimalpoints', 'grades'), $options);
     $mform->setHelpButton('decimals', array('decimalpoints', get_string('decimalpoints', 'grades'), 'grade'), true);
     $mform->setDefault('decimals', -1);
     $mform->disabledIf('decimals', 'display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
     if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
         $mform->disabledIf('decimals', 'display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
     }
     /// hiding
     // advcheckbox is not compatible with disabledIf!
     $mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
     $mform->setHelpButton('hidden', array('hidden', get_string('hidden', 'grades'), 'grade'));
     $mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional' => true));
     $mform->setHelpButton('hiddenuntil', array('hiddenuntil', get_string('hiddenuntil', 'grades'), 'grade'));
     $mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
     /// locking
     $mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'));
     $mform->setHelpButton('locked', array('locked', get_string('locked', 'grades'), 'grade'));
     $mform->addElement('date_time_selector', 'locktime', get_string('locktime', 'grades'), array('optional' => true));
     $mform->setHelpButton('locktime', array('lockedafter', get_string('locktime', 'grades'), 'grade'));
     $mform->disabledIf('locktime', 'gradetype', 'eq', GRADE_TYPE_NONE);
     /// parent category related settings
     $mform->addElement('header', 'headerparent', get_string('parentcategory', 'grades'));
     $options = array();
     $coefstring = '';
     $categories = grade_category::fetch_all(array('courseid' => $COURSE->id));
     foreach ($categories as $cat) {
         $cat->apply_forced_settings();
//.........这里部分代码省略.........
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:item_form.php

示例6: validation

 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if ($data['scaleid'] < 1) {
         $errors['scaleid'] = get_string('required');
     }
     if (!empty($data['standard']) and $scale = grade_scale::fetch(array('id' => $data['scaleid']))) {
         if (!empty($scale->courseid)) {
             //TODO: localize
             $errors['scaleid'] = 'Can not use custom scale in global outcome!';
         }
     }
     return $errors;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:14,代码来源:edit_form.php

示例7: get_string

$strscale = get_string('scale');
$strstandardscale = get_string('scalesstandard');
$strcustomscales = get_string('scalescustom');
$strname = get_string('name');
$strdelete = get_string('delete');
$stredit = get_string('edit');
$srtcreatenewscale = get_string('scalescustomcreate');
$strused = get_string('used');
$stredit = get_string('edit');
switch ($action) {
    case 'delete':
        if (!confirm_sesskey()) {
            break;
        }
        $scaleid = required_param('scaleid', PARAM_INT);
        if (!($scale = grade_scale::fetch(array('id' => $scaleid)))) {
            break;
        }
        if (empty($scale->courseid)) {
            require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM));
        } else {
            if ($scale->courseid != $courseid) {
                print_error('invalidcourseid');
            }
        }
        if (!$scale->can_delete()) {
            break;
        }
        $deleteconfirmed = optional_param('deleteconfirmed', 0, PARAM_BOOL);
        if (!$deleteconfirmed) {
            $strdeletescale = get_string('delete') . ' ' . get_string('scale');
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:index.php

示例8: create_framework

 /**
  * Create a new framework.
  *
  * @param array|stdClass $record
  * @return competency_framework
  */
 public function create_framework($record = null)
 {
     $generator = phpunit_util::get_data_generator();
     $this->frameworkcount++;
     $i = $this->frameworkcount;
     $record = (object) $record;
     if (!isset($record->shortname)) {
         $record->shortname = "Framework shortname {$i}";
     }
     if (!isset($record->idnumber)) {
         $record->idnumber = "frm{$i}";
     }
     if (!isset($record->description)) {
         $record->description = "Framework {$i} description ";
     }
     if (!isset($record->descriptionformat)) {
         $record->descriptionformat = FORMAT_HTML;
     }
     if (!isset($record->visible)) {
         $record->visible = 1;
     }
     if (!isset($record->scaleid)) {
         if (isset($record->scaleconfiguration)) {
             throw new coding_exception('Scale configuration must be provided with a scale.');
         }
         if (!$this->scale) {
             $this->scale = $generator->create_scale(array('scale' => 'A,B,C,D'));
         }
         $record->scaleid = $this->scale->id;
     }
     if (!isset($record->scaleconfiguration)) {
         $scale = grade_scale::fetch(array('id' => $record->scaleid));
         $values = $scale->load_items();
         foreach ($values as $key => $value) {
             // Add a key (make the first value 1).
             $values[$key] = array('id' => $key + 1, 'name' => $value);
         }
         if (count($values) < 2) {
             throw new coding_exception('Please provide the scale configuration for one-item scales.');
         }
         $scaleconfig = array();
         // Last item is proficient.
         $item = array_pop($values);
         array_unshift($scaleconfig, array('id' => $item['id'], 'proficient' => 1));
         // Second-last item is default and proficient.
         $item = array_pop($values);
         array_unshift($scaleconfig, array('id' => $item['id'], 'scaledefault' => 1, 'proficient' => 1));
         array_unshift($scaleconfig, array('scaleid' => $record->scaleid));
         $record->scaleconfiguration = json_encode($scaleconfig);
     }
     if (is_array($record->scaleconfiguration) || is_object($record->scaleconfiguration)) {
         // Conveniently encode the config.
         $record->scaleconfiguration = json_encode($record->scaleconfiguration);
     }
     if (!isset($record->contextid)) {
         $record->contextid = context_system::instance()->id;
     }
     $framework = new competency_framework(0, $record);
     $framework->create();
     return $framework;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:lib.php

示例9: get_scale

 /**
  * Return the scale.
  *
  * @return \grade_scale
  */
 public function get_scale()
 {
     $scale = \grade_scale::fetch(array('id' => $this->get_scaleid()));
     $scale->load_items();
     return $scale;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:competency_framework.php

示例10: validation

 function validation($data, $files)
 {
     global $CFG, $COURSE, $DB;
     $errors = parent::validation($data, $files);
     // we can not allow 2 scales with the same exact scale as this creates
     // problems for backup/restore
     $old = grade_scale::fetch(array('id' => $data['id']));
     if (array_key_exists('standard', $data)) {
         if (empty($data['standard'])) {
             $courseid = $COURSE->id;
         } else {
             $courseid = 0;
         }
     } else {
         $courseid = $old->courseid;
     }
     if (array_key_exists('scale', $data)) {
         $scalearray = explode(',', $data['scale']);
         $scalearray = array_map('trim', $scalearray);
         $scaleoptioncount = count($scalearray);
         if (count($scalearray) < 2) {
             $errors['scale'] = get_string('badlyformattedscale', 'grades');
         } else {
             $thescale = implode(',', $scalearray);
             //this check strips out whitespace from the scale we're validating but not from those already in the DB
             $count = $DB->count_records_select('scale', "courseid=:courseid AND " . $DB->sql_compare_text('scale', core_text::strlen($thescale)) . '=:scale', array('courseid' => $courseid, 'scale' => $thescale));
             if ($count) {
                 //if this is a new scale but we found a duplice in the DB
                 //or we found a duplicate in another course report the error
                 if (empty($old->id) or $old->courseid != $courseid) {
                     $errors['scale'] = get_string('duplicatescale', 'grades');
                 } else {
                     if ($old->scale !== $thescale and $old->scale !== $data['scale']) {
                         //if the old scale from DB is different but we found a duplicate then we're trying to modify a scale to be a duplicate
                         $errors['scale'] = get_string('duplicatescale', 'grades');
                     }
                 }
             }
         }
     }
     return $errors;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:42,代码来源:edit_form.php

示例11: 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

示例12: definition

 function definition()
 {
     global $CFG, $COURSE, $DB;
     $mform =& $this->_form;
     $category = $this->_customdata['current'];
     $this->aggregation_options = array(GRADE_AGGREGATE_MEAN => get_string('aggregatemean', 'grades'), GRADE_AGGREGATE_WEIGHTED_MEAN => get_string('aggregateweightedmean', 'grades'), GRADE_AGGREGATE_WEIGHTED_MEAN2 => get_string('aggregateweightedmean2', 'grades'), GRADE_AGGREGATE_EXTRACREDIT_MEAN => get_string('aggregateextracreditmean', 'grades'), GRADE_AGGREGATE_MEDIAN => get_string('aggregatemedian', 'grades'), GRADE_AGGREGATE_MIN => get_string('aggregatemin', 'grades'), GRADE_AGGREGATE_MAX => get_string('aggregatemax', 'grades'), GRADE_AGGREGATE_MODE => get_string('aggregatemode', 'grades'), GRADE_AGGREGATE_SUM => get_string('aggregatesum', 'grades'));
     // visible elements
     $mform->addElement('header', 'headercategory', get_string('gradecategory', 'grades'));
     $mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
     $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');
     $mform->disabledIf('aggregateonlygraded', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
     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('advcheckbox', 'aggregatesubcats', get_string('aggregatesubcats', 'grades'));
     $mform->addHelpButton('aggregatesubcats', 'aggregatesubcats', 'grades');
     if ((int) $CFG->grade_aggregatesubcats_flag & 2) {
         $mform->setAdvanced('aggregatesubcats');
     }
     $options = array(0 => get_string('none'));
     for ($i = 1; $i <= 20; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'keephigh', get_string('keephigh', 'grades'), $options);
     $mform->addHelpButton('keephigh', 'keephigh', 'grades');
     if ((int) $CFG->grade_keephigh_flag & 2) {
         $mform->setAdvanced('keephigh');
     }
     $mform->addElement('select', 'droplow', get_string('droplow', 'grades'), $options);
     $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->setAdvanced('grade_item_itemname');
     $mform->addElement('text', 'grade_item_iteminfo', get_string('iteminfo', 'grades'));
     $mform->addHelpButton('grade_item_iteminfo', 'iteminfo', 'grades');
     $mform->addElement('text', 'grade_item_idnumber', get_string('idnumbermod'));
     $mform->addHelpButton('grade_item_idnumber', 'idnumbermod');
     $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');
         }
     }
     $mform->addElement('select', 'grade_item_scaleid', get_string('scale'), $options);
     $mform->addHelpButton('grade_item_scaleid', 'typescale', 'grades');
     $mform->disabledIf('grade_item_scaleid', 'grade_item_gradetype', 'noteq', GRADE_TYPE_SCALE);
     $mform->disabledIf('grade_item_scaleid', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
     $mform->addElement('text', 'grade_item_grademax', get_string('grademax', 'grades'));
     $mform->addHelpButton('grade_item_grademax', 'grademax', 'grades');
     $mform->disabledIf('grade_item_grademax', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
     $mform->disabledIf('grade_item_grademax', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
     $mform->addElement('text', 'grade_item_grademin', get_string('grademin', 'grades'));
     $mform->addHelpButton('grade_item_grademin', 'grademin', 'grades');
     $mform->disabledIf('grade_item_grademin', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
     $mform->disabledIf('grade_item_grademin', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
     $mform->addElement('text', 'grade_item_gradepass', get_string('gradepass', 'grades'));
//.........这里部分代码省略.........
开发者ID:nmicha,项目名称:moodle,代码行数:101,代码来源:category_form.php

示例13: get_scale

 /**
  * Return the scale.
  *
  * @return \grade_scale
  */
 public function get_scale()
 {
     $scaleid = $this->get_scaleid();
     if ($scaleid === null) {
         return $this->get_framework()->get_scale();
     }
     $scale = \grade_scale::fetch(array('id' => $scaleid));
     $scale->load_items();
     return $scale;
 }
开发者ID:reconnectmedia,项目名称:moodle,代码行数:15,代码来源:competency.php

示例14: get_data

 /**
  *
  */
 public function get_data()
 {
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (empty($data->timeavailable)) {
         unset($data->timeinterval);
         $data->intervalcount = 1;
     }
     if (empty($data->timeinterval)) {
         $data->intervalcount = 1;
     }
     // Turn off completion settings if the checkboxes aren't ticked.
     if (!empty($data->completionunlocked)) {
         $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
         if (empty($data->completionentriesenabled) or !$autocompletion) {
             $data->completionentries = 0;
         }
         if (empty($data->completionspecificgradeenabled) or !$autocompletion) {
             $data->completionspecificgrade = 0;
         }
         if (empty($data->grade) and !empty($data->completionspecificgradeenabled)) {
             unset($data->completionspecificgradeenabled);
             $data->completionspecificgrade = 0;
         }
         if (!empty($data->grade) and !empty($data->completionspecificgrade)) {
             if ($data->grade > 0) {
                 if ($data->completionspecificgrade > $data->grade) {
                     $data->completionspecificgrade = $data->grade;
                 }
             } else {
                 // Custom scale.
                 $scale = grade_scale::fetch(array('id' => -$data->grade));
                 $numitems = count($scale->load_items());
                 if ($data->completionspecificgrade > $numitems) {
                     $data->completionspecificgrade = $numitems;
                 }
             }
         }
     }
     // Grade items.
     $gradeitems = array();
     if ($this->_instance) {
         $gradeitems = \mod_dataform_dataform::instance($this->_instance)->grade_items;
     }
     $gradeitems[0] = empty($gradeitems[0]) ? array() : $gradeitems[0];
     $updategradeitems = false;
     // Check grade calc change.
     $thiscalc = !empty($gradeitems[0]['ca']) ? $gradeitems[0]['ca'] : null;
     $gradecalc = !empty($data->gradecalc) ? $data->gradecalc : null;
     if ($thiscalc != $gradecalc) {
         if (!$gradecalc) {
             unset($gradeitems[0]['ca']);
         } else {
             $gradeitems[0]['ca'] = $gradecalc;
         }
         $updategradeitems = true;
     }
     // Check grade guide change.
     $thisguide = !empty($gradeitems[0]['ru']) ? $gradeitems[0]['ru'] : null;
     $gradeguide = !empty($data->gradeguide) ? $data->gradeguide : null;
     if ($thisguide != $gradeguide) {
         if (!$gradeguide) {
             unset($gradeitems[0]['ru']);
         } else {
             $gradeitems[0]['ru'] = $gradeguide;
         }
         $updategradeitems = true;
     }
     if ($updategradeitems) {
         $data->gradeitems = $gradeitems[0] ? serialize($gradeitems) : null;
     }
     return $data;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:78,代码来源:mod_form.php

示例15: definition

 function definition()
 {
     global $COURSE, $CFG, $DB;
     $mform =& $this->_form;
     $item = $this->_customdata['current'];
     /// visible elements
     $mform->addElement('header', 'general', get_string('gradeitem', 'grades'));
     $mform->addElement('text', 'itemname', get_string('itemname', 'grades'));
     $mform->setType('itemname', PARAM_TEXT);
     $mform->addElement('text', 'iteminfo', get_string('iteminfo', 'grades'));
     $mform->addHelpButton('iteminfo', 'iteminfo', 'grades');
     $mform->setType('iteminfo', PARAM_TEXT);
     $mform->addElement('text', 'idnumber', get_string('idnumbermod'));
     $mform->addHelpButton('idnumber', 'idnumbermod');
     $mform->setType('idnumber', PARAM_RAW);
     if (!empty($item->id)) {
         $gradeitem = new grade_item(array('id' => $item->id, 'courseid' => $item->courseid));
         // 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_grades() && !$gradeitem->is_external_item()) {
             // Set a message so the user knows why they can not alter the grade type or scale.
             if ($gradeitem->gradetype == GRADE_TYPE_SCALE) {
                 $gradesexistmsg = get_string('modgradecantchangegradetyporscalemsg', 'grades');
             } else {
                 $gradesexistmsg = get_string('modgradecantchangegradetypemsg', 'grades');
             }
             $gradesexisthtml = '<div class=\'alert\'>' . $gradesexistmsg . '</div>';
             $mform->addElement('static', 'gradesexistmsg', '', $gradesexisthtml);
         }
     }
     // Manual grade items cannot have grade type GRADE_TYPE_NONE.
     $options = array(GRADE_TYPE_VALUE => get_string('typevalue', 'grades'), GRADE_TYPE_SCALE => get_string('typescale', 'grades'), GRADE_TYPE_TEXT => get_string('typetext', 'grades'));
     $mform->addElement('select', 'gradetype', get_string('gradetype', 'grades'), $options);
     $mform->addHelpButton('gradetype', 'gradetype', 'grades');
     $mform->setDefault('gradetype', GRADE_TYPE_VALUE);
     //$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($item->scaleid) and !isset($options[$item->scaleid])) {
         if ($scale = grade_scale::fetch(array('id' => $item->scaleid))) {
             $options[$scale->id] = $scale->get_name() . get_string('incorrectcustomscale', 'grades');
         }
     }
     $mform->addElement('select', 'scaleid', get_string('scale'), $options);
     $mform->addHelpButton('scaleid', 'typescale', 'grades');
     $mform->disabledIf('scaleid', 'gradetype', 'noteq', GRADE_TYPE_SCALE);
     $choices = array();
     $choices[''] = get_string('choose');
     $choices['no'] = get_string('no');
     $choices['yes'] = get_string('yes');
     $mform->addElement('select', 'rescalegrades', get_string('modgraderescalegrades', 'grades'), $choices);
     $mform->addHelpButton('rescalegrades', 'modgraderescalegrades', 'grades');
     $mform->disabledIf('rescalegrades', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
     $mform->addElement('text', 'grademax', get_string('grademax', 'grades'));
     $mform->addHelpButton('grademax', 'grademax', 'grades');
     $mform->disabledIf('grademax', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
     $mform->setType('grademax', PARAM_RAW);
     if ((bool) get_config('moodle', 'grade_report_showmin')) {
         $mform->addElement('text', 'grademin', get_string('grademin', 'grades'));
         $mform->addHelpButton('grademin', 'grademin', 'grades');
         $mform->disabledIf('grademin', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
         $mform->setType('grademin', PARAM_RAW);
     }
     $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
     $mform->addHelpButton('gradepass', 'gradepass', 'grades');
     $mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $mform->disabledIf('gradepass', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     $mform->setType('gradepass', PARAM_RAW);
     $mform->addElement('text', 'multfactor', get_string('multfactor', 'grades'));
     $mform->addHelpButton('multfactor', 'multfactor', 'grades');
     $mform->setAdvanced('multfactor');
     $mform->disabledIf('multfactor', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $mform->disabledIf('multfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     $mform->setType('multfactor', PARAM_RAW);
     $mform->addElement('text', 'plusfactor', get_string('plusfactor', 'grades'));
     $mform->addHelpButton('plusfactor', 'plusfactor', 'grades');
     $mform->setAdvanced('plusfactor');
     $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_NONE);
     $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT);
     $mform->setType('plusfactor', PARAM_RAW);
     /// grade display prefs
     $default_gradedisplaytype = grade_get_setting($COURSE->id, 'displaytype', $CFG->grade_displaytype);
     $options = array(GRADE_DISPLAY_TYPE_DEFAULT => get_string('default', 'grades'), GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'), GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => get_string('realpercentage', 'grades'), GRADE_DISPLAY_TYPE_REAL_LETTER => get_string('realletter', 'grades'), GRADE_DISPLAY_TYPE_LETTER_REAL => get_string('letterreal', 'grades'), GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => get_string('letterpercentage', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => get_string('percentageletter', 'grades'), GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => get_string('percentagereal', 'grades'));
     asort($options);
     foreach ($options as $key => $option) {
         if ($key == $default_gradedisplaytype) {
             $options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
             break;
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:item_form.php


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