|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00030 defined('MOODLE_INTERNAL') || die(); 00031 00032 require_once(dirname(dirname(__FILE__)).'/assessment_form.php'); // parent class definition 00033 00037 abstract class workshop_rubric_assessment_form extends workshop_assessment_form { 00038 00039 public function validation($data, $files) { 00040 00041 $errors = parent::validation($data, $files); 00042 for ($i = 0; isset($data['dimensionid__idx_'.$i]); $i++) { 00043 if (empty($data['chosenlevelid__idx_'.$i])) { 00044 $errors['chosenlevelid__idx_'.$i] = get_string('mustchooseone', 'workshopform_rubric'); // used in grid 00045 $errors['levelgrp__idx_'.$i] = get_string('mustchooseone', 'workshopform_rubric'); // used in list 00046 } 00047 } 00048 return $errors; 00049 } 00050 } 00051 00055 class workshop_rubric_list_assessment_form extends workshop_rubric_assessment_form { 00056 00064 protected function definition_inner(&$mform) { 00065 $workshop = $this->_customdata['workshop']; 00066 $fields = $this->_customdata['fields']; 00067 $current = $this->_customdata['current']; 00068 $nodims = $this->_customdata['nodims']; // number of assessment dimensions 00069 00070 for ($i = 0; $i < $nodims; $i++) { 00071 // dimension header 00072 $dimtitle = get_string('dimensionnumber', 'workshopform_rubric', $i+1); 00073 $mform->addElement('header', 'dimensionhdr__idx_'.$i, $dimtitle); 00074 00075 // dimension id 00076 $mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields->{'dimensionid__idx_'.$i}); 00077 $mform->setType('dimensionid__idx_'.$i, PARAM_INT); 00078 00079 // grade id 00080 $mform->addElement('hidden', 'gradeid__idx_'.$i); // value set by set_data() later 00081 $mform->setType('gradeid__idx_'.$i, PARAM_INT); 00082 00083 // dimension description 00084 $desc = '<div id="id_dim_'.$fields->{'dimensionid__idx_'.$i}.'_desc" class="fitem description rubric">'."\n"; 00085 $desc .= format_text($fields->{'description__idx_'.$i}, $fields->{'description__idx_'.$i.'format'}); 00086 $desc .= "\n</div>"; 00087 $mform->addElement('html', $desc); 00088 00089 $numoflevels = $fields->{'numoflevels__idx_'.$i}; 00090 $levelgrp = array(); 00091 for ($j = 0; $j < $numoflevels; $j++) { 00092 $levelid = $fields->{'levelid__idx_'.$i.'__idy_'.$j}; 00093 $definition = $fields->{'definition__idx_'.$i.'__idy_'.$j}; 00094 $definitionformat = $fields->{'definition__idx_'.$i.'__idy_'.$j.'format'}; 00095 $levelgrp[] = $mform->createElement('radio', 'chosenlevelid__idx_'.$i, '', 00096 format_text($definition, $definitionformat, null, $workshop->course->id), $levelid); 00097 } 00098 $mform->addGroup($levelgrp, 'levelgrp__idx_'.$i, '', "<br />\n", false); 00099 } 00100 $this->set_data($current); 00101 } 00102 } 00103 00107 class workshop_rubric_grid_assessment_form extends workshop_rubric_assessment_form { 00108 00116 protected function definition_inner(&$mform) { 00117 $workshop = $this->_customdata['workshop']; 00118 $fields = $this->_customdata['fields']; 00119 $current = $this->_customdata['current']; 00120 $nodims = $this->_customdata['nodims']; // number of assessment dimensions 00121 00122 // get the number of required grid columns 00123 $levelcounts = array(); 00124 for ($i = 0; $i < $nodims; $i++) { 00125 if ($fields->{'numoflevels__idx_'.$i} > 0) { 00126 $levelcounts[] = $fields->{'numoflevels__idx_'.$i}; 00127 } 00128 } 00129 $numofcolumns = array_reduce($levelcounts, 'workshop::lcm', 1); 00130 00131 $mform->addElement('header', 'rubric-grid-wrapper', get_string('layoutgrid', 'workshopform_rubric')); 00132 00133 $mform->addElement('html', '<table class="rubric-grid">' . "\n"); 00134 $mform->addElement('html', '<th class="header">' . get_string('criteria', 'workshopform_rubric') . '</th>'); 00135 $mform->addElement('html', '<th class="header" colspan="'.$numofcolumns.'">'.get_string('levels', 'workshopform_rubric').'</th>'); 00136 00137 for ($i = 0; $i < $nodims; $i++) { 00138 00139 $mform->addElement('html', '<tr class="r'. $i % 2 .'"><td class="criterion">' . "\n"); 00140 00141 // dimension id 00142 $mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields->{'dimensionid__idx_'.$i}); 00143 $mform->setType('dimensionid__idx_'.$i, PARAM_INT); 00144 00145 // given grade id 00146 $mform->addElement('hidden', 'gradeid__idx_'.$i); // value set by set_data() later 00147 $mform->setType('gradeid__idx_'.$i, PARAM_INT); 00148 00149 // dimension description 00150 $desc = format_text($fields->{'description__idx_'.$i}, $fields->{'description__idx_'.$i.'format'}); 00151 $desc .= "</td>\n"; 00152 $mform->addElement('html', $desc); 00153 00154 $numoflevels = $fields->{'numoflevels__idx_'.$i}; 00155 for ($j = 0; $j < $numoflevels; $j++) { 00156 $colspan = $numofcolumns / $numoflevels; 00157 $mform->addElement('html', '<td class="level c' . $j % 2 . '" colspan="' . $colspan . '">' . "\n"); 00158 $levelid = $fields->{'levelid__idx_'.$i.'__idy_'.$j}; 00159 $definition = $fields->{'definition__idx_'.$i.'__idy_'.$j}; 00160 $definitionformat = $fields->{'definition__idx_'.$i.'__idy_'.$j.'format'}; 00161 $mform->addElement('radio', 'chosenlevelid__idx_'.$i, '', 00162 format_text($definition, $definitionformat, null, $workshop->course->id), $levelid); 00163 $mform->addElement('html', '</td>' . "\n"); 00164 } 00165 $mform->addElement('html', '</tr>' . "\n"); 00166 } 00167 $mform->addElement('html', '</table>' . "\n"); 00168 00169 $this->set_data($current); 00170 } 00171 }