本文整理汇总了PHP中grade_scale::fetch_all_global方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_scale::fetch_all_global方法的具体用法?PHP grade_scale::fetch_all_global怎么用?PHP grade_scale::fetch_all_global使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_scale
的用法示例。
在下文中一共展示了grade_scale::fetch_all_global方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition_after_data
function definition_after_data()
{
global $CFG;
$mform =& $this->_form;
// first load proper scales
if ($courseid = $mform->getElementValue('courseid')) {
$options = array();
if ($scales = grade_scale::fetch_all_local($courseid)) {
$options[-1] = '--' . get_string('scalescustom');
foreach ($scales as $scale) {
$options[$scale->id] = $scale->get_name();
}
}
if ($scales = grade_scale::fetch_all_global()) {
$options[-2] = '--' . get_string('scalesstandard');
foreach ($scales as $scale) {
$options[$scale->id] = $scale->get_name();
}
}
$scale_el =& $mform->getElement('scaleid');
$scale_el->load($options);
} else {
$options = array();
if ($scales = grade_scale::fetch_all_global()) {
foreach ($scales as $scale) {
$options[$scale->id] = $scale->get_name();
}
}
$scale_el =& $mform->getElement('scaleid');
$scale_el->load($options);
}
if ($id = $mform->getElementValue('id')) {
$outcome = grade_outcome::fetch(array('id' => $id));
$itemcount = $outcome->get_item_uses_count();
$coursecount = $outcome->get_course_uses_count();
if ($itemcount) {
$mform->hardFreeze('scaleid');
}
if (empty($courseid)) {
$mform->hardFreeze('standard');
} else {
if (empty($outcome->courseid) and !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
$mform->hardFreeze('standard');
} else {
if ($coursecount and empty($outcome->courseid)) {
$mform->hardFreeze('standard');
}
}
}
} else {
if (empty($courseid) or !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
$mform->hardFreeze('standard');
}
}
}
示例2: 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();
//.........这里部分代码省略.........
示例3: referentiel_print_scales
function referentiel_print_scales($course, $cm, $context, $roles)
{
global $DB;
global $OUTPUT;
global $CFG;
$strscale = get_string('scale');
$strstandardscale = get_string('scalesstandard');
$strcustomscales = get_string('scalescustom');
$srtcreatenewscale = get_string('scalescustomcreate');
$strname = get_string('name');
$strselect = get_string('select');
$strused = get_string('scaleused', 'referentiel');
$table = new html_table();
$table2 = new html_table();
$heading = '';
if ($course->id and $scales = grade_scale::fetch_all_local($course->id)) {
$heading = $strcustomscales;
$data = array();
foreach ($scales as $scale) {
$line = array();
$line[] = format_string($scale->name) . '<div class="scale_options">' . str_replace(",", ", ", $scale->scale) . '</div>';
$used = $scale->is_used();
$line[] = $used ? get_string('yes') : get_string('no');
$menu = "";
if (has_capability('mod/referentiel:writereferentiel', $context)) {
$menu .= '<a href="' . $CFG->wwwroot . '/mod/referentiel/bareme.php?id=' . $cm->id . '&scaleid=' . $scale->id . '&mode=editbareme&sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('square_small', 'referentiel') . '" alt="' . get_string('select') . '" title="' . get_string('select') . '" /></a>';
}
$line[] = $menu;
$data[] = $line;
}
$table->head = array($strscale, $strused, $strselect);
$table->size = array('60%', '30%', '10%');
$table->align = array('left', 'center', 'center');
$table->attributes['class'] = 'scaletable localscales generaltable';
$table->data = $data;
//print_grade_page_head($courseid, 'scale', 'scale', get_string('coursescales', 'grades'));
echo $OUTPUT->heading($strcustomscales . ' ' . $OUTPUT->help_icon('scalelocalh', 'referentiel'), 3, 'main');
echo html_writer::table($table);
} else {
echo '<div align="center">' . get_string('no_custom_scale', 'referentiel') . '<br />' . "\n";
if ($roles->is_admin) {
$link = new moodle_url('/grade/edit/scale/index.php', NULL);
} else {
if ($roles->is_teacher) {
$link = new moodle_url('/grade/edit/scale/index.php?id=' . $course->id, NULL);
} else {
$link = '';
}
}
if ($link) {
echo '<a href="' . $link . '">' . get_string('create_a_scale', 'referentiel') . '</a>' . "\n";
}
echo '</div>' . "\n";
}
if ($scales = grade_scale::fetch_all_global()) {
$heading = $strstandardscale;
$data = array();
foreach ($scales as $scale) {
$line = array();
$line[] = format_string($scale->name) . '<div class="scale_options">' . str_replace(",", ", ", $scale->scale) . '</div>';
$used = $scale->is_used();
$line[] = $used ? get_string('yes') : get_string('no');
$menu = "";
/*
if (has_capability('mod/referentiel:writereferentiel', $context)) {
$menu.= '<a href="'.$CFG->wwwroot.'/mod/referentiel/bareme.php?id='.$cm->id.'&scaleid='.$scale->id.'&mode=editbareme&sesskey='.sesskey().'"><img src="'.$OUTPUT->pix_url('square_small','referentiel').'" alt="'.get_string('select').'" title="'.get_string('select').'" /></a>';
}
*/
$line[] = $menu;
$data[] = $line;
}
$table2->head = array($strscale, $strused, $strselect);
$table->attributes['class'] = 'scaletable globalscales generaltable';
$table2->size = array('60%', '30%', '10%');
$table2->align = array('left', 'center', 'center');
$table2->data = $data;
echo $OUTPUT->heading($strstandardscale . ' ' . $OUTPUT->help_icon('scaleglobalh', 'referentiel'), 3, 'main');
echo html_writer::table($table2);
} else {
echo '<div align="center">' . get_string('no_global_scale', 'referentiel') . "\n";
if ($roles->is_admin) {
$link = new moodle_url('/grade/edit/scale/index.php', NULL);
echo '<br /><a href="' . $link . '">' . get_string('create_global_scale', 'referentiel') . '</a>' . "\n";
}
echo '</div>' . "\n";
}
}
示例4: get_string
$line[] = $used ? get_string('yes') : get_string('no');
$buttons = "";
$buttons .= grade_button('edit', $courseid, $scale);
if (!$used) {
$buttons .= grade_button('delete', $courseid, $scale);
}
$line[] = $buttons;
$data[] = $line;
}
$table->head = array($strscale, $strused, $stredit);
$table->size = array('70%', '20%', '10%');
$table->align = array('left', 'center', 'center');
$table->attributes['class'] = 'scaletable localscales generaltable';
$table->data = $data;
}
if ($scales = grade_scale::fetch_all_global()) {
$heading = $strstandardscale;
$data = array();
foreach ($scales as $scale) {
$line = array();
$line[] = format_string($scale->name) . '<div class="scale_options">' . str_replace(",", ", ", $scale->scale) . '</div>';
$used = $scale->is_used();
$line[] = $used ? get_string('yes') : get_string('no');
$buttons = "";
if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
$buttons .= grade_button('edit', $courseid, $scale);
}
if (!$used and has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
$buttons .= grade_button('delete', $courseid, $scale);
}
$line[] = $buttons;
示例5: 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');
}
}
//.........这里部分代码省略.........
示例6: 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'));
//.........这里部分代码省略.........
示例7: unset
$outcome->insert();
} else {
if (isset($data->standard)) {
$outcome->courseid = !empty($data->standard) ? null : $courseid;
} else {
unset($outcome->courseid);
// keep previous
}
$outcome->update();
}
redirect($returnurl);
}
}
if ($courseid) {
print_grade_page_head($courseid, 'outcome', 'edit', $heading);
} else {
require_once $CFG->libdir . '/adminlib.php';
admin_externalpage_setup('outcomes');
admin_externalpage_print_header();
}
if (!grade_scale::fetch_all_local($courseid) && !grade_scale::fetch_all_global()) {
notice_yesno(get_string('noscales', 'grades'), $CFG->wwwroot . '/grade/edit/scale/edit.php?courseid=' . $courseid, $returnurl);
print_footer($course);
die;
}
$mform->display();
if ($courseid) {
print_footer($course);
} else {
admin_externalpage_print_footer();
}
示例8: 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;
//.........这里部分代码省略.........