Ejemplo n.º 1
0
 /**
  * Define the elements to be displayed at the form
  *
  * Called by the parent::definition()
  *
  * @return void
  */
 protected function definition_inner(&$mform)
 {
     $norepeats = $this->_customdata['norepeats'];
     // number of dimensions to display
     $descriptionopts = $this->_customdata['descriptionopts'];
     // wysiwyg fields options
     $current = $this->_customdata['current'];
     // current data to be set
     $mform->addElement('hidden', 'norepeats', $norepeats);
     $mform->setType('norepeats', PARAM_INT);
     // value not to be overridden by submitted value
     $mform->setConstants(array('norepeats' => $norepeats));
     for ($i = 0; $i < $norepeats; $i++) {
         $mform->addElement('header', 'dimension' . $i, get_string('dimensionnumber', 'teamworkform_accumulative', $i + 1));
         $mform->addElement('hidden', 'dimensionid__idx_' . $i);
         $mform->setType('dimensionid__idx_' . $i, PARAM_INT);
         $mform->addElement('editor', 'description__idx_' . $i . '_editor', get_string('dimensiondescription', 'teamworkform_accumulative'), '', $descriptionopts);
         // todo replace modgrade with an advanced element (usability issue discussed with Olli)
         $mform->addElement('modgrade', 'grade__idx_' . $i, get_string('dimensionmaxgrade', 'teamworkform_accumulative'), null, true);
         $mform->setDefault('grade__idx_' . $i, 10);
         $mform->addElement('select', 'weight__idx_' . $i, get_string('dimensionweight', 'teamworkform_accumulative'), teamwork::available_dimension_weights_list());
         $mform->setDefault('weight__idx_' . $i, 1);
     }
     $mform->registerNoSubmitButton('noadddims');
     $mform->addElement('submit', 'noadddims', get_string('addmoredimensions', 'teamworkform_accumulative', teamwork_accumulative_strategy::ADDDIMS));
     $mform->closeHeaderBefore('noadddims');
     $this->set_data($current);
 }
Ejemplo n.º 2
0
 /**
  * Define the elements to be displayed at the form
  *
  * Called by the parent::definition()
  *
  * @return void
  */
 protected function definition_inner(&$mform)
 {
     $plugindefaults = get_config('teamworkform_numerrors');
     $nodimensions = $this->_customdata['nodimensions'];
     // number of currently filled dimensions
     $norepeats = $this->_customdata['norepeats'];
     // number of dimensions to display
     $descriptionopts = $this->_customdata['descriptionopts'];
     // wysiwyg fields options
     $current = $this->_customdata['current'];
     // current data to be set
     $mform->addElement('hidden', 'norepeats', $norepeats);
     $mform->setType('norepeats', PARAM_INT);
     // value not to be overridden by submitted value
     $mform->setConstants(array('norepeats' => $norepeats));
     for ($i = 0; $i < $norepeats; $i++) {
         $mform->addElement('header', 'dimension' . $i, get_string('dimensionnumber', 'teamworkform_numerrors', $i + 1));
         $mform->addElement('hidden', 'dimensionid__idx_' . $i);
         // the id in teamwork_forms
         $mform->setType('dimensionid__idx_' . $i, PARAM_INT);
         $mform->addElement('editor', 'description__idx_' . $i . '_editor', get_string('dimensiondescription', 'teamworkform_numerrors'), '', $descriptionopts);
         $mform->addElement('text', 'grade0__idx_' . $i, get_string('grade0', 'teamworkform_numerrors'), array('size' => '15'));
         $mform->setDefault('grade0__idx_' . $i, $plugindefaults->grade0);
         $mform->setType('grade0__idx_' . $i, PARAM_TEXT);
         $mform->addElement('text', 'grade1__idx_' . $i, get_string('grade1', 'teamworkform_numerrors'), array('size' => '15'));
         $mform->setDefault('grade1__idx_' . $i, $plugindefaults->grade1);
         $mform->setType('grade1__idx_' . $i, PARAM_TEXT);
         $mform->addElement('select', 'weight__idx_' . $i, get_string('dimensionweight', 'teamworkform_numerrors'), teamwork::available_dimension_weights_list());
         $mform->setDefault('weight__idx_' . $i, 1);
     }
     $mform->addElement('header', 'mappingheader', get_string('grademapping', 'teamworkform_numerrors'));
     $mform->addElement('static', 'mappinginfo', get_string('maperror', 'teamworkform_numerrors'), get_string('mapgrade', 'teamworkform_numerrors'));
     // get the total weight of all items == maximum weighted number of errors
     $totalweight = 0;
     for ($i = 0; $i < $norepeats; $i++) {
         if (!empty($current->{'weight__idx_' . $i})) {
             $totalweight += $current->{'weight__idx_' . $i};
         }
     }
     $totalweight = max($totalweight, $nodimensions);
     $percents = array();
     $percents[''] = '';
     for ($i = 100; $i >= 0; $i--) {
         $percents[$i] = get_string('percents', 'teamworkform_numerrors', $i);
     }
     $mform->addElement('static', 'mappingzero', 0, get_string('percents', 'teamworkform_numerrors', 100));
     for ($i = 1; $i <= $totalweight; $i++) {
         $selects = array();
         $selects[] = $mform->createElement('select', 'map__idx_' . $i, $i, $percents);
         $selects[] = $mform->createElement('static', 'mapdefault__idx_' . $i, '', get_string('percents', 'teamworkform_numerrors', floor(100 - $i * 100 / $totalweight)));
         $mform->addGroup($selects, 'grademapping' . $i, $i, array(' '), false);
         $mform->setDefault('map__idx_' . $i, '');
     }
     $mform->registerNoSubmitButton('noadddims');
     $mform->addElement('submit', 'noadddims', get_string('addmoredimensions', 'teamworkform_numerrors', teamwork_numerrors_strategy::ADDDIMS));
     $mform->closeHeaderBefore('noadddims');
     $this->set_data($current);
 }