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


PHP grade_scale类代码示例

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


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

示例1: get_moodle_grades

 private function get_moodle_grades()
 {
     global $DB, $CFG;
     $grades = $DB->get_records('grade_grades', array('itemid' => $this->course_grade_item->id), 'userid', 'userid, finalgrade');
     if (!is_array($grades)) {
         $grades = array();
     }
     $this->moodle_grades = array();
     if ($this->course_grade_item->gradetype == GRADE_TYPE_SCALE) {
         $pg_scale = new grade_scale(array('id' => $CFG->grade_report_newgradereport_scale));
         $scale_items = $pg_scale->load_items();
         foreach ($this->moodle_students as $st) {
             if (isset($grades[$st->id])) {
                 $fg = (int) $grades[$st->id]->finalgrade;
                 if (isset($scale_items[$fg - 1])) {
                     $this->moodle_grades[$st->id] = $scale_items[$fg - 1];
                 } else {
                     $this->moodle_grades[$st->id] = null;
                 }
             } else {
                 $this->moodle_grades[$st->id] = null;
             }
         }
     } else {
         foreach ($this->moodle_students as $st) {
             if (isset($grades[$st->id])) {
                 $this->moodle_grades[$st->id] = grade_format_gradevalue($grades[$st->id]->finalgrade, $this->course_grade_item, true, $this->course_grade_item->get_displaytype(), null);
             } else {
                 $this->moodle_grades[$st->id] = null;
             }
         }
     }
 }
开发者ID:danielneis,项目名称:moodle-gradereport_newgradereport,代码行数:33,代码来源:lib.php

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

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

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

示例5: remove_course_grades

/**
 * Remove all grade related course data - history is kept
 * @param int $courseid
 * @param bool @showfeedback print feedback
 */
function remove_course_grades($courseid, $showfeedback)
{
    $strdeleted = get_string('deleted');
    $course_category = grade_category::fetch_course_category($courseid);
    $course_category->delete('coursedelete');
    if ($showfeedback) {
        notify($strdeleted . ' - ' . get_string('grades', 'grades') . ', ' . get_string('items', 'grades') . ', ' . get_string('categories', 'grades'));
    }
    if ($outcomes = grade_outcome::fetch_all(array('courseid' => $courseid))) {
        foreach ($outcomes as $outcome) {
            $outcome->delete('coursedelete');
        }
    }
    delete_records('grade_outcomes_courses', 'courseid', $courseid);
    if ($showfeedback) {
        notify($strdeleted . ' - ' . get_string('outcomes', 'grades'));
    }
    if ($scales = grade_scale::fetch_all(array('courseid' => $courseid))) {
        foreach ($scales as $scale) {
            $scale->delete('coursedelete');
        }
    }
    if ($showfeedback) {
        notify($strdeleted . ' - ' . get_string('scales'));
    }
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:gradelib.php

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

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

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

示例9: grade_scale

    if ($data = $mform->get_data()) {
        $scale = new grade_scale(array('id' => $id));
        $data->userid = $USER->id;
        if (empty($scale->id)) {
            $data->description = $data->description_editor['text'];
            $data->descriptionformat = $data->description_editor['format'];
            grade_scale::set_properties($scale, $data);
            if (!has_capability('moodle/grade:manage', $systemcontext)) {
                $data->standard = 0;
            }
            $scale->courseid = !empty($data->standard) ? 0 : $courseid;
            $scale->insert();
            $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale->id);
            $DB->set_field($scale->table, 'description', $data->description, array('id' => $scale->id));
        } else {
            $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $id);
            grade_scale::set_properties($scale, $data);
            if (isset($data->standard)) {
                $scale->courseid = !empty($data->standard) ? 0 : $courseid;
            } else {
                unset($scale->courseid);
                // keep previous
            }
            $scale->update();
        }
        redirect($returnurl);
    }
}
print_grade_page_head($COURSE->id, 'scale', null, $heading, false, false, false);
$mform->display();
echo $OUTPUT->footer();
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:edit.php

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

示例11: 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();
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:edit.php

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

示例13: sub_test_scale_one_item

 protected function sub_test_scale_one_item()
 {
     $params = new stdClass();
     $params->name = 'unittestscale1i';
     $params->courseid = $this->course->id;
     $params->userid = $this->userid;
     $params->scale = 'Like';
     $params->description = 'This scale is used to like something.';
     $params->timemodified = time();
     $scale = new grade_scale($params, false);
     $scale->load_items();
     $this->assertCount(1, $scale->scale_items);
     $this->assertSame(array('Like'), $scale->scale_items);
     $this->assertSame('Like', $scale->compact_items());
     $scale->insert();
     // Manual grade item with 1 item scale.
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->categoryid = $this->grade_categories[0]->id;
     $grade_item->itemname = 'manual grade_item scale_1';
     $grade_item->itemtype = 'manual';
     $grade_item->itemnumber = 0;
     $grade_item->needsupdate = false;
     $grade_item->gradetype = GRADE_TYPE_SCALE;
     $grade_item->scaleid = $scale->id;
     $grade_item->iteminfo = 'Manual grade item used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item = new grade_item($grade_item);
     $grade_item->insert();
     $this->assertNotEmpty($grade_item->id);
     $this->assertEquals(1, $grade_item->grademin);
     $this->assertEquals(1, $grade_item->grademax);
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:34,代码来源:grade_scale_test.php

示例14: grade_print_scale_link

/**
 * Local shortcut function for creating a link to a scale.
 * @param int $courseid The Course ID
 * @param grade_scale $scale The Scale to link to
 * @param grade_plugin_return $gpr An object used to identify the page we just came from
 * @return string html
 */
function grade_print_scale_link($courseid, $scale, $gpr)
{
    global $CFG, $OUTPUT;
    $url = new moodle_url('/grade/edit/scale/edit.php', array('courseid' => $courseid, 'id' => $scale->id));
    $url = $gpr->add_url_params($url);
    return html_writer::link($url, $scale->get_name());
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:14,代码来源:index.php

示例15: 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_scale类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。