Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (3 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/course/moodleform_mod.php

    r136 r1331  
    5959    protected $courseformat;
    6060
    61     function moodleform_mod($current, $section, $cm, $course) {
     61    public function __construct($current, $section, $cm, $course) {
    6262        global $CFG;
    6363
     
    8484        $this->_modname = $matches[1];
    8585        $this->init_features();
    86         parent::moodleform('modedit.php');
     86        parent::__construct('modedit.php');
     87    }
     88
     89    /**
     90     * Old syntax of class constructor for backward compatibility.
     91     */
     92    public function moodleform_mod($current, $section, $cm, $course) {
     93        self::__construct($current, $section, $cm, $course);
    8794    }
    8895
     
    143150                }
    144151
     152                $hasgradeitems = false;
    145153                $items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$modulename,'iteminstance'=>$instance, 'courseid'=>$COURSE->id));
    146154                //will be no items if, for example, this activity supports ratings but rating aggregate type == no ratings
     
    152160                                $mform->hardFreeze($elname); // prevent removing of existing outcomes
    153161                            }
     162                        } else {
     163                            $hasgradeitems = true;
    154164                        }
    155165                    }
     
    168178                }
    169179
     180                if (!$hasgradeitems && $mform->elementExists('gradepass')) {
     181                    // Remove form element 'Grade to pass' since there are no grade items (when rating not selected).
     182                    $mform->removeElement('gradepass');
     183                }
     184
    170185                if ($gradecat === false) {
    171186                    // items and outcomes in different categories - remove the option
     
    173188                    if ($mform->elementExists('gradecat')) {
    174189                        $mform->removeElement('gradecat');
    175                         if ($this->_features->rating) {
     190                        if ($this->_features->rating  && !$mform->elementExists('gradepass')) {
    176191                            //if supports ratings then the max grade dropdown wasnt added so the grade box can be removed entirely
    177192                            $mform->removeElement('modstandardgrade');
     
    300315        }
    301316
     317        // Check that the grade pass is a valid number.
     318        $gradepassvalid = false;
     319        if (isset($data['gradepass'])) {
     320            if (unformat_float($data['gradepass'], true) === false) {
     321                $errors['gradepass'] = get_string('err_numeric', 'form');
     322            } else {
     323                $gradepassvalid = true;
     324            }
     325        }
     326
     327        // Grade to pass: ensure that the grade to pass is valid for points and scales.
     328        // If we are working with a scale, convert into a positive number for validation.
     329        if ($gradepassvalid && isset($data['gradepass']) && (!empty($data['grade']) || !empty($data['scale']))) {
     330            $scale = !empty($data['grade']) ? $data['grade'] : $data['scale'];
     331            if ($scale < 0) {
     332                $scalevalues = $DB->get_record('scale', array('id' => -$scale));
     333                $grade = count(explode(',', $scalevalues->scale));
     334            } else {
     335                $grade = $scale;
     336            }
     337            if ($data['gradepass'] > $grade) {
     338                $errors['gradepass'] = get_string('gradepassgreaterthangrade', 'grades', $grade);
     339            }
     340        }
     341
    302342        // Completion: Don't let them choose automatic completion without turning
    303343        // on some conditions. Ignore this check when completion settings are
     
    437477
    438478        if (!empty($CFG->enableavailability)) {
     479            // Add special button to end of previous section if groups/groupings
     480            // are enabled.
     481            if ($this->_features->groups || $this->_features->groupings) {
     482                $mform->addElement('static', 'restrictgroupbutton', '',
     483                        html_writer::tag('button', get_string('restrictbygroup', 'availability'),
     484                        array('id' => 'restrictbygroup', 'disabled' => 'disabled')));
     485            }
     486
    439487            // Availability field. This is just a textarea; the user interface
    440488            // interaction is all implemented in JavaScript.
     
    617665                        get_string('gradingmethod', 'core_grading'), $this->current->_advancedgradingdata['methods']);
    618666                    $mform->addHelpButton('advancedgradingmethod_'.$areaname, 'gradingmethod', 'core_grading');
     667                    if (!$this->_features->rating) {
     668                        $mform->disabledIf('advancedgradingmethod_'.$areaname, 'grade[modgrade_type]', 'eq', 'none');
     669                    }
    619670
    620671                } else {
     
    637688                        grade_get_categories_menu($COURSE->id, $this->_outcomesused));
    638689                $mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades');
    639             }
    640         }
    641     }
    642 
    643     function add_intro_editor($required=false, $customlabel=null) {
    644         if (!$this->_features->introeditor) {
    645             // intro editor not supported in this module
    646             return;
    647         }
     690                if (!$this->_features->rating) {
     691                    $mform->disabledIf('gradecat', 'grade[modgrade_type]', 'eq', 'none');
     692                }
     693            }
     694
     695            // Grade to pass.
     696            $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
     697            $mform->addHelpButton('gradepass', 'gradepass', 'grades');
     698            $mform->setDefault('gradepass', '');
     699            $mform->setType('gradepass', PARAM_RAW);
     700            if (!$this->_features->rating) {
     701                $mform->disabledIf('gradepass', 'grade[modgrade_type]', 'eq', 'none');
     702            } else {
     703                $mform->disabledIf('gradepass', 'assessed', 'eq', '0');
     704            }
     705        }
     706    }
     707
     708    /**
     709     * Add an editor for an activity's introduction field.
     710     * @deprecated since MDL-49101 - use moodleform_mod::standard_intro_elements() instead.
     711     * @param null $required Override system default for requiremodintro
     712     * @param null $customlabel Override default label for editor
     713     * @throws coding_exception
     714     */
     715    protected function add_intro_editor($required=null, $customlabel=null) {
     716        $str = "Function moodleform_mod::add_intro_editor() is deprecated, use moodleform_mod::standard_intro_elements() instead.";
     717        debugging($str, DEBUG_DEVELOPER);
     718
     719        $this->standard_intro_elements($customlabel);
     720    }
     721
     722
     723    /**
     724     * Add an editor for an activity's introduction field.
     725     *
     726     * @param null $customlabel Override default label for editor
     727     * @throws coding_exception
     728     */
     729    protected function standard_intro_elements($customlabel=null) {
     730        global $CFG;
     731
     732        $required = $CFG->requiremodintro;
    648733
    649734        $mform = $this->_form;
Note: See TracChangeset for help on using the changeset viewer.