Пример #1
0
 /**
  * Returns the form definition suitable for cloning into another area
  *
  * @see parent::get_definition_copy()
  * @param gradingform_controller $target the controller of the new copy
  * @return stdClass definition structure to pass to the target's {@link update_definition()}
  */
 public function get_definition_copy(gradingform_controller $target)
 {
     $new = parent::get_definition_copy($target);
     $old = $this->get_definition_for_editing();
     $new->description_editor = $old->description_editor;
     $new->guide = array('criteria' => array(), 'options' => $old->guide['options'], 'comments' => array());
     $newcritid = 1;
     foreach ($old->guide['criteria'] as $oldcritid => $oldcrit) {
         unset($oldcrit['id']);
         $new->guide['criteria']['NEWID' . $newcritid] = $oldcrit;
         $newcritid++;
     }
     $newcomid = 1;
     foreach ($old->guide['comments'] as $oldcritid => $oldcom) {
         unset($oldcom['id']);
         $new->guide['comments']['NEWID' . $newcomid] = $oldcom;
         $newcomid++;
     }
     return $new;
 }
Пример #2
0
 /**
  * Returns the form definition suitable for cloning into another area
  *
  * @see parent::get_definition_copy()
  * @param gradingform_controller $target the controller of the new copy
  * @return stdClass definition structure to pass to the target's {@link update_definition()}
  */
 public function get_definition_copy(gradingform_controller $target)
 {
     $new = parent::get_definition_copy($target);
     $old = $this->get_definition_for_editing();
     $new->description_editor = $old->description_editor;
     $new->rubric = array('criteria' => array(), 'options' => $old->rubric['options']);
     $newcritid = 1;
     $newlevid = 1;
     foreach ($old->rubric['criteria'] as $oldcritid => $oldcrit) {
         unset($oldcrit['id']);
         if (isset($oldcrit['levels'])) {
             foreach ($oldcrit['levels'] as $oldlevid => $oldlev) {
                 unset($oldlev['id']);
                 $oldcrit['levels']['NEWID' . $newlevid] = $oldlev;
                 unset($oldcrit['levels'][$oldlevid]);
                 $newlevid++;
             }
         } else {
             $oldcrit['levels'] = array();
         }
         $new->rubric['criteria']['NEWID' . $newcritid] = $oldcrit;
         $newcritid++;
     }
     return $new;
 }
 /**
  * Returns the form definition suitable for cloning into another area.
  *
  * @see parent::get_definition_copy()
  * @param gradingform_controller $target the controller of the new copy
  * @return stdClass definition structure to pass to the target's {@link update_definition()}
  */
 public function get_definition_copy(gradingform_controller $target)
 {
     // Consider the required action as confirmed.
     $enrichedconfirmed = optional_param('enrichedconfirmed', false, PARAM_BOOL);
     // Publish the given form definition as a new template in the forms bank.
     $shareform = optional_param('shareform', null, PARAM_INT);
     global $PAGE;
     $output = $PAGE->get_renderer('core_grading');
     if (!$enrichedconfirmed && $shareform) {
         // Let the user confirm they understand the risk of setting an enriched rubric as template.
         echo $output->header();
         echo $output->confirm(get_string('enrichshareconfirm', 'gradingform_erubric'), new moodle_url($PAGE->url, array('shareform' => $shareform, 'enrichedconfirmed' => 1, 'confirmed' => 1)), $PAGE->url);
         echo $output->footer();
         die;
     } else {
         // Got confirmation or just using another template to create a new enriched rubric.
         $new = parent::get_definition_copy($target);
         $old = $this->get_definition_for_editing();
         $new->description_editor = $old->description_editor;
         $new->erubric = array('criteria' => array(), 'options' => $old->erubric['options']);
         $newcritid = 1;
         $newlevid = 1;
         foreach ($old->erubric['criteria'] as $oldcritid => $oldcrit) {
             unset($oldcrit['id']);
             if (isset($oldcrit['levels'])) {
                 foreach ($oldcrit['levels'] as $oldlevid => $oldlev) {
                     unset($oldlev['id']);
                     $oldcrit['levels']['NEWID' . $newlevid] = $oldlev;
                     unset($oldcrit['levels'][$oldlevid]);
                     $newlevid++;
                 }
             } else {
                 $oldcrit['levels'] = array();
             }
             $new->erubric['criteria']['NEWID' . $newcritid] = $oldcrit;
             $newcritid++;
         }
         return $new;
     }
 }