# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/course/moodleform_mod.php
--- moodle/course/moodleform_mod.php Base (1.53)
+++ moodle/course/moodleform_mod.php Locally Modified (Based On 1.53)
@@ -49,6 +49,9 @@
     /** current context, course or module depends if already exists*/
     protected $context;
 
+    /** a flag indicating whether outcomes are being used*/
+    protected $_outcomesused;
+
     function moodleform_mod($current, $section, $cm, $course) {
         $this->current   = $current;
         $this->_instance = $current->instance;
@@ -93,8 +96,20 @@
      * @param array $default_values passed by reference
      */
     function data_preprocessing(&$default_values){
+        if (empty($default_values['scale'])) {
+            $default_values['assessed'] = 0;
     }
 
+        if (empty($default_values['assessed'])){
+            //$default_values['userating'] = 0;//this was used by glossary to check/uncheck a 'use ratings' checkbox
+            $default_values['ratingtime'] = 0;
+        } else {
+            //$default_values['userating'] = 1;
+            $default_values['ratingtime']=
+                ($default_values['assesstimestart'] && $default_values['assesstimefinish']) ? 1 : 0;
+        }
+    }
+
     /**
      * Each module which defines definition_after_data() must call this method using parent::definition_after_data();
      */
@@ -316,10 +331,10 @@
         global $COURSE, $CFG, $DB;
         $mform =& $this->_form;
 
-        $outcomesused = false;
+        $this->_outcomesused = false;
         if ($this->_features->outcomes) {
             if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
-                $outcomesused = true;
+                $this->_outcomesused = true;
                 $mform->addElement('header', 'modoutcomes', get_string('outcomes', 'grades'));
                 foreach($outcomes as $outcome) {
                     $mform->addElement('advcheckbox', 'outcome_'.$outcome->id, $outcome->get_name());
@@ -327,6 +342,30 @@
             }
         }
 
+        if (plugin_supports('mod', $this->_modname, FEATURE_RATINGS, false)) {
+            $mform->addElement('header', 'modstandardratings', get_string('ratings', 'ratings'));
+
+            //$mform->addElement('checkbox', 'assessed', get_string('allowratings', 'ratings') , get_string('ratingsuse', 'ratings'));
+
+            $mform->addElement('select', 'assessed', get_string('aggregatetype', 'ratings') , forum_get_aggregate_types());
+            $mform->setDefault('assessed', 0);
+            $mform->setHelpButton('assessed', array('assessaggregate', get_string('aggregatetype', 'ratings'), 'forum'));
+
+            $mform->addElement('modgrade', 'scale', get_string('grade'), false);
+            $mform->disabledIf('scale', 'assessed', 'eq', 0);
+
+            $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum'));
+            $mform->disabledIf('ratingtime', 'assessed', 'eq', 0);
+
+            $mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
+            $mform->disabledIf('assesstimestart', 'assessed', 'eq', 0);
+            $mform->disabledIf('assesstimestart', 'ratingtime');
+
+            $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
+            $mform->disabledIf('assesstimefinish', 'assessed', 'eq', 0);
+            $mform->disabledIf('assesstimefinish', 'ratingtime');
+        }
+
         $mform->addElement('header', 'modstandardelshdr', get_string('modstandardels', 'form'));
         if ($this->_features->groups) {
             $options = array(NOGROUPS       => get_string('groupsnone'),
@@ -365,11 +404,6 @@
             $mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true);
         }
 
-        if ($this->_features->gradecat) {
-            $categories = grade_get_categories_menu($COURSE->id, $outcomesused);
-            $mform->addElement('select', 'gradecat', get_string('gradecategory', 'grades'), $categories);
-        }
-
         if (!empty($CFG->enableavailability)) {
             // Conditional availability
             $mform->addElement('header', '', get_string('availabilityconditions', 'condition'));
@@ -584,6 +618,43 @@
         $mform->setType('return', PARAM_BOOL);
     }
 
+    public function coursemodule_grading_elements() {
+        global $COURSE;
+        $mform =& $this->_form;
+        
+        if (plugin_supports('mod', $this->_modname, FEATURE_GRADE_HAS_GRADE, false)) {
+            $mform->addElement('header', 'modstandardgrade', get_string('grade'));
+
+            $mform->addElement('modgrade', 'grade', get_string('grade'));
+            $mform->setDefault('grade', 100);
+
+            if ($this->_features->gradecat) {
+                $categories = grade_get_categories_menu($COURSE->id, $this->_outcomesused);
+                $mform->addElement('select', 'gradecat', get_string('gradecategory', 'grades'), $categories);
+            }
+
+            //$mform->addElement('checkbox', 'assessed', get_string('allowratings', 'ratings') , get_string('ratingsuse', 'ratings'));
+
+            /*$mform->addElement('select', 'assessed', get_string('aggregatetype', 'ratings') , forum_get_aggregate_types());
+            $mform->setDefault('assessed', 0);
+            $mform->setHelpButton('assessed', array('assessaggregate', get_string('aggregatetype', 'ratings'), 'forum'));
+
+            $mform->addElement('modgrade', 'scale', get_string('grade'), false);
+            $mform->disabledIf('scale', 'assessed', 'eq', 0);
+
+            $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum'));
+            $mform->disabledIf('ratingtime', 'assessed', 'eq', 0);
+
+            $mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
+            $mform->disabledIf('assesstimestart', 'assessed', 'eq', 0);
+            $mform->disabledIf('assesstimestart', 'ratingtime');
+
+            $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
+            $mform->disabledIf('assesstimefinish', 'assessed', 'eq', 0);
+            $mform->disabledIf('assesstimefinish', 'ratingtime');*/
+        }
+    }
+
     function add_intro_editor($required=false, $customlabel=null) {
         if (!$this->_features->introeditor) {
             // intro editor not supported in this module
Index: moodle/mod/assignment/lib.php
--- moodle/mod/assignment/lib.php Base (1.434)
+++ moodle/mod/assignment/lib.php Locally Modified (Based On 1.434)
@@ -3340,6 +3340,7 @@
         case FEATURE_GRADE_HAS_GRADE:         return true;
         case FEATURE_GRADE_OUTCOMES:          return true;
         case FEATURE_MOD_SUBPLUGINS:          return array('assignment'=>'mod/assignment/type'); // to be hopefully removed in 2.0
+        case FEATURE_GRADE_HAS_GRADE:         return true;
 
         default: return null;
     }
Index: moodle/mod/assignment/mod_form.php
--- moodle/mod/assignment/mod_form.php Base (1.17)
+++ moodle/mod/assignment/mod_form.php Locally Modified (Based On 1.17)
@@ -43,9 +43,6 @@
 
         $this->add_intro_editor(true, get_string('description', 'assignment'));
 
-        $mform->addElement('modgrade', 'grade', get_string('grade'));
-        $mform->setDefault('grade', 100);
-
         $mform->addElement('date_time_selector', 'timeavailable', get_string('availabledate', 'assignment'), array('optional'=>true));
         $mform->setDefault('timeavailable', time());
         $mform->addElement('date_time_selector', 'timedue', get_string('duedate', 'assignment'), array('optional'=>true));
@@ -56,8 +53,8 @@
         $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions);
         $mform->setDefault('preventlate', 0);
 
+        $this->coursemodule_grading_elements();
 
-
         $typetitle = get_string('type'.$type, 'assignment');
 
         // hack to support pluggable assignment type titles
