コード例 #1
0
ファイル: lib.php プロジェクト: nicusX/moodle
 /**
  * Returns html for form element of type 'grading'.
  *
  * @param moodle_page $page
  * @param MoodleQuickForm_grading $gradingformelement
  * @return string
  */
 public function render_grading_element($page, $gradingformelement)
 {
     if (!$gradingformelement->_flagFrozen) {
         $module = array('name' => 'gradingform_guide', 'fullpath' => '/grade/grading/form/guide/js/guide.js');
         $page->requires->js_init_call('M.gradingform_guide.init', array(array('name' => $gradingformelement->getName())), true, $module);
         $mode = gradingform_guide_controller::DISPLAY_EVAL;
     } else {
         if ($gradingformelement->_persistantFreeze) {
             $mode = gradingform_guide_controller::DISPLAY_EVAL_FROZEN;
         } else {
             $mode = gradingform_guide_controller::DISPLAY_REVIEW;
         }
     }
     $criteria = $this->get_controller()->get_definition()->guide_criteria;
     $comments = $this->get_controller()->get_definition()->guide_comment;
     $options = $this->get_controller()->get_options();
     $value = $gradingformelement->getValue();
     $html = '';
     if ($value === null) {
         $value = $this->get_guide_filling();
     } else {
         if (!$this->validate_grading_element($value)) {
             $html .= html_writer::tag('div', get_string('guidenotcompleted', 'gradingform_guide'), array('class' => 'gradingform_guide-error'));
             if (!empty($this->validationerrors)) {
                 foreach ($this->validationerrors as $id => $err) {
                     $a = new stdClass();
                     $a->criterianame = $criteria[$id]['shortname'];
                     $a->maxscore = $criteria[$id]['maxscore'];
                     $html .= html_writer::tag('div', get_string('err_scoreinvalid', 'gradingform_guide', $a), array('class' => 'gradingform_guide-error'));
                 }
             }
         }
     }
     $currentinstance = $this->get_current_instance();
     if ($currentinstance && $currentinstance->get_status() == gradingform_instance::INSTANCE_STATUS_NEEDUPDATE) {
         $html .= html_writer::tag('div', get_string('needregrademessage', 'gradingform_guide'), array('class' => 'gradingform_guide-regrade'));
     }
     $haschanges = false;
     if ($currentinstance) {
         $curfilling = $currentinstance->get_guide_filling();
         foreach ($curfilling['criteria'] as $criterionid => $curvalues) {
             $value['criteria'][$criterionid]['score'] = $curvalues['score'];
             $newremark = null;
             $newscore = null;
             if (isset($value['criteria'][$criterionid]['remark'])) {
                 $newremark = $value['criteria'][$criterionid]['remark'];
             }
             if (isset($value['criteria'][$criterionid]['score'])) {
                 $newscore = $value['criteria'][$criterionid]['score'];
             }
             if ($newscore != $curvalues['score'] || $newremark != $curvalues['remark']) {
                 $haschanges = true;
             }
         }
     }
     if ($this->get_data('isrestored') && $haschanges) {
         $html .= html_writer::tag('div', get_string('restoredfromdraft', 'gradingform_guide'), array('class' => 'gradingform_guide-restored'));
     }
     if (!empty($options['showdescriptionteacher'])) {
         $html .= html_writer::tag('div', $this->get_controller()->get_formatted_description(), array('class' => 'gradingform_guide-description'));
     }
     $html .= $this->get_controller()->get_renderer($page)->display_guide($criteria, $comments, $options, $mode, $gradingformelement->getName(), $value, $this->validationerrors);
     return $html;
 }
コード例 #2
0
 /**
  * Returns html for form element of type 'grading'.
  *
  * @param moodle_page $page
  * @param MoodleQuickForm_grading $gradingformelement
  * @return string
  */
 public function render_grading_element($page, $gradingformelement)
 {
     global $USER;
     if (!$gradingformelement->_flagFrozen) {
         $module = array('name' => 'gradingform_erubric', 'fullpath' => '/grade/grading/form/erubric/js/erubric.js');
         $page->requires->js_init_call('M.gradingform_erubric.init', array(array('name' => $gradingformelement->getName())), true, $module);
         $mode = gradingform_erubric_controller::DISPLAY_EVAL;
     } else {
         if ($gradingformelement->_persistantFreeze) {
             $mode = gradingform_erubric_controller::DISPLAY_EVAL_FROZEN;
         } else {
             $mode = gradingform_erubric_controller::DISPLAY_REVIEW;
         }
     }
     $criteria = $this->get_controller()->get_definition()->erubric_criteria;
     $options = $this->get_controller()->get_options();
     $value = $gradingformelement->getValue();
     $html = '';
     if ($value === null) {
         $value = $this->get_erubric_filling();
     } else {
         if (!$this->validate_grading_element($value)) {
             $html .= html_writer::tag('div', get_string('rubricnotcompleted', 'gradingform_erubric'), array('class' => 'gradingform_erubric-error'));
         }
     }
     $currentinstance = $this->get_current_instance();
     if ($currentinstance && $currentinstance->get_status() == gradingform_instance::INSTANCE_STATUS_NEEDUPDATE) {
         $html .= html_writer::tag('div', get_string('needregrademessage', 'gradingform_erubric'), array('class' => 'gradingform_erubric-regrade'));
     }
     $haschanges = false;
     if ($currentinstance) {
         $curfilling = $currentinstance->get_erubric_filling();
         foreach ($curfilling['criteria'] as $criterionid => $curvalues) {
             $value['criteria'][$criterionid]['savedlevelid'] = $curvalues['levelid'];
             $newremark = null;
             $newlevelid = null;
             $newenrichedbenchmark = null;
             $newenrichedbenchmarkstudent = null;
             $newenrichedbenchmarkstudents = null;
             if (isset($value['criteria'][$criterionid]['remark'])) {
                 $newremark = $value['criteria'][$criterionid]['remark'];
             }
             if (isset($value['criteria'][$criterionid]['levelid'])) {
                 $newlevelid = $value['criteria'][$criterionid]['levelid'];
             }
             if (array_key_exists('enrichedbenchmark', $value['criteria'][$criterionid])) {
                 $newenrichedbenchmark = $value['criteria'][$criterionid]['enrichedbenchmark'];
             }
             if (array_key_exists('enrichedbenchmarkstudent', $value['criteria'][$criterionid])) {
                 $newenrichedbenchmarkstudent = $value['criteria'][$criterionid]['enrichedbenchmarkstudent'];
             }
             if (array_key_exists('enrichedbenchmarkstudents', $value['criteria'][$criterionid])) {
                 $newenrichedbenchmarkstudents = $value['criteria'][$criterionid]['enrichedbenchmarkstudents'];
             }
             if ($newlevelid != $curvalues['levelid'] || $newremark != $curvalues['remark'] || (string) $newenrichedbenchmark != (string) $curvalues['enrichedbenchmark'] || (string) $newenrichedbenchmarkstudent != (string) $curvalues['enrichedbenchmarkstudent'] || (string) $newenrichedbenchmarkstudents != (string) $curvalues['enrichedbenchmarkstudents']) {
                 $haschanges = true;
             }
         }
     }
     if ($this->get_data('isrestored') && $haschanges) {
         $html .= html_writer::tag('div', get_string('restoredfromdraft', 'gradingform_erubric'), array('class' => 'gradingform_erubric-restored'));
     }
     if (!empty($options['showdescriptionteacher'])) {
         $html .= html_writer::tag('div', $this->get_controller()->get_formatted_description(), array('class' => 'gradingform_erubric-description'));
     }
     $html .= $this->get_controller()->get_renderer($page)->display_erubric($criteria, $options, $mode, $gradingformelement->getName(), $value);
     return $html;
 }