本文整理汇总了PHP中grade_item::has_grades方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_item::has_grades方法的具体用法?PHP grade_item::has_grades怎么用?PHP grade_item::has_grades使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_item
的用法示例。
在下文中一共展示了grade_item::has_grades方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
//.........这里部分代码省略.........