Commit a39d7d87 authored by David Mudrak's avatar David Mudrak
Browse files

A lot of changes here and there

parent b8ead2e6
- assessment form, dimension description - I want to have a single filearea
for all dimension descriptions within the given workshop. Does not work,
TBD with skodak
......@@ -38,7 +38,7 @@ $PAGE->set_url('mod/workshop/allocation.php', array('cmid' => $cmid, 'method' =>
$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
$workshop = new workshop_api($workshop, $cm, $course);
$workshop = new workshop($workshop, $cm, $course);
require_login($course, false, $cm);
$context = $PAGE->context;
......
......@@ -44,7 +44,7 @@ interface workshop_allocator {
* is generated. Therefore is may process any data submitted and do other tasks.
* It should not generate any output
*
* @throws moodle_workshop_exception
* @throws moodle_exception
* @return mixed void or optional HTML string
*/
public function init();
......
......@@ -64,7 +64,7 @@ class workshop_manual_allocator implements workshop_allocator {
switch ($mode) {
case 'new':
if (!confirm_sesskey()) {
throw new moodle_workshop_exception($this->workshop, 'confirmsesskeybad');
throw new moodle_exception('confirmsesskeybad');
}
$reviewerid = required_param('by', PARAM_INT);
$authorid = required_param('of', PARAM_INT);
......@@ -93,7 +93,7 @@ class workshop_manual_allocator implements workshop_allocator {
break;
case 'del':
if (!confirm_sesskey()) {
throw new moodle_workshop_exception($this->workshop, 'confirmsesskeybad');
throw new moodle_exception('confirmsesskeybad');
}
$assessmentid = required_param('what', PARAM_INT);
$confirmed = optional_param('confirm', 0, PARAM_INT);
......
......@@ -41,7 +41,6 @@ class moodle_mod_workshop_allocation_manual_renderer extends moodle_renderer_bas
*
* @param mixed $page the page we are doing output for
* @param mixed $output lower-level renderer, typically moodle_core_renderer
* @access public
* @return void
*/
public function __construct($page, $output) {
......@@ -52,7 +51,7 @@ class moodle_mod_workshop_allocation_manual_renderer extends moodle_renderer_bas
/**
* Display the table of all current allocations and widgets to modify them
*
* @param workshop $workshop workshop instance object
* @param workshop $workshop workshop API instance
* @param array $peers prepared array of all allocations
* @param int $hlauthorid highlight this author
* @param int $hlreviewerid highlight this reviewer
......@@ -122,11 +121,11 @@ class moodle_mod_workshop_allocation_manual_renderer extends moodle_renderer_bas
* Returns information about the current reviewers of the given participant and a selector do add new one
*
* @param stdClass $user participant data
* @param workshop_api $workshop workshop record
* @param workshop $workshop workshop record
* @param array $peers objects with properties to display picture and fullname
* @return string html code
*/
protected function reviewers_of_participant(stdClass $user, workshop_api $workshop, &$peers) {
protected function reviewers_of_participant(stdClass $user, workshop $workshop, &$peers) {
$o = '';
if (is_null($user->submissionid)) {
$o .= $this->output->output_tag('span', array('class' => 'info'), get_string('nothingtoreview', 'workshop'));
......@@ -161,11 +160,11 @@ class moodle_mod_workshop_allocation_manual_renderer extends moodle_renderer_bas
* Returns information about the current reviewees of the given participant and a selector do add new one
*
* @param stdClass $user participant data
* @param workshop_api $workshop workshop record
* @param workshop $workshop workshop record
* @param array $peers objects with properties to display picture and fullname
* @return string html code
*/
protected function reviewees_of_participant(stdClass $user, workshop_api $workshop, &$peers) {
protected function reviewees_of_participant(stdClass $user, workshop $workshop, &$peers) {
$o = '';
if (is_null($user->submissionid)) {
$o .= $this->output->container(get_string('withoutsubmission', 'workshop'), 'info');
......
......@@ -74,7 +74,7 @@ class workshop_random_allocator implements workshop_allocator {
} else if ($settings = $this->mform->get_data()) {
// process validated data
if (!confirm_sesskey()) {
throw new moodle_workshop_exception($this->workshop, 'confirmsesskeybad');
throw new moodle_exception('confirmsesskeybad');
}
$o = array(); // list of output messages
$numofreviews = required_param('numofreviews', PARAM_INT);
......@@ -177,9 +177,9 @@ class workshop_random_allocator implements workshop_allocator {
* If the submission has already been allocated, it is skipped. If the author is not found among
* reviewers, the submission is not assigned.
*
* @param array $authors as returned by {@see workshop_api::get_peer_authors_by_group()}
* @param array $reviewers as returned by {@see workshop_api::get_peer_reviewers_by_group()}
* @param array $assessments as returned by {@see workshop_api::get_assessments()}
* @param array $authors as returned by {@see workshop::get_peer_authors_by_group()}
* @param array $reviewers as returned by {@see workshop::get_peer_reviewers_by_group()}
* @param array $assessments as returned by {@see workshop::get_assessments()}
* @return array of new allocations to be created, array of array(reviewerid => authorid)
*/
protected function self_allocation($authors=array(), $reviewers=array(), $assessments=array()) {
......@@ -225,7 +225,7 @@ class workshop_random_allocator implements workshop_allocator {
foreach ($newallocations as $newallocation) {
list($reviewerid, $authorid) = each($newallocation);
if (!isset($submissions[$authorid])) {
throw new moodle_workshop_exception($this->workshop, 'unabletoallocateauthorwithoutsubmission');
throw new moodle_exception('unabletoallocateauthorwithoutsubmission', 'workshop');
}
$submission = $submissions[$authorid];
$status = $this->workshop->add_allocation($submission, $reviewerid, true);
......@@ -249,7 +249,7 @@ class workshop_random_allocator implements workshop_allocator {
if (is_array($submissions)) {
foreach ($submissions as $submissionid => $submission) {
if (isset($byauthor[$submission->userid])) {
throw new moodle_workshop_exception($this->workshop, 'moresubmissionsbyauthor');
throw new moodle_exception('moresubmissionsbyauthor', 'workshop');
}
$byauthor[$submission->userid] = $submission;
}
......@@ -354,7 +354,7 @@ class workshop_random_allocator implements workshop_allocator {
// get current workload
list($squarelinks, $circlelinks) = $this->convert_assessments_to_links($assessments);
} else {
throw new moodle_workshop_exception($this->workshop, 'unknown user type passed');
throw new moodle_exception('unknownusertypepassed', 'workshop');
}
$o[] = 'debug::circle links = ' . json_encode($circlelinks);
$o[] = 'debug::square links = ' . json_encode($squarelinks);
......@@ -374,7 +374,7 @@ class workshop_random_allocator implements workshop_allocator {
unset($squaregroupsworkload[0]); // [0] is not real group, it contains all users
$o[] = 'debug::square workload = ' . json_encode($squareworkload);
$o[] = 'debug::square group workload = ' . json_encode($squaregroupsworkload);
$gmode = groups_get_activity_groupmode($this->workshop->cm, $this->workshop->courserecord);
$gmode = groups_get_activity_groupmode($this->workshop->cm, $this->workshop->course);
if (SEPARATEGROUPS == $gmode) {
// shuffle all groups but [0] which means "all users"
$circlegroups = array_keys(array_diff_key($allcircles, array(0 => null)));
......@@ -477,7 +477,7 @@ class workshop_random_allocator implements workshop_allocator {
/**
* Extracts the information about reviews from the authors' and reviewers' perspectives
*
* @param array $assessments array of assessments as returned by {@link workshop_api::get_assessments()}
* @param array $assessments array of assessments as returned by {@link workshop::get_assessments()}
* @return array of two arrays
*/
protected function convert_assessments_to_links($assessments) {
......
......@@ -46,7 +46,7 @@ class workshop_random_allocator_form extends moodleform {
$mform->addElement('header', 'settings', get_string('allocationsettings', 'workshop'));
$gmode = groups_get_activity_groupmode($workshop->cm, $workshop->courserecord);
$gmode = groups_get_activity_groupmode($workshop->cm, $workshop->course);
switch ($gmode) {
case NOGROUPS:
$grouplabel = get_string('groupsnone', 'group');
......
......@@ -67,7 +67,10 @@ class workshop_allocation_random_test extends UnitTestCase {
protected $allocator;
public function setUp() {
$this->workshop = new workshop((object)array('id' => 42), new stdClass(), new stdClass());
$cm = (object)array('id' => 3);
$course = (object)array('id' => 11);
$workshop = (object)array('id' => 42);
$this->workshop = new workshop($workshop, $cm, $course);
$this->allocator = new testable_workshop_random_allocator($this->workshop);
}
......@@ -141,7 +144,7 @@ class workshop_allocation_random_test extends UnitTestCase {
87 => (object)array('id' => 121, 'userid' => 3),
);
// set expectation
$this->expectException('moodle_workshop_exception');
$this->expectException('moodle_exception');
// exercise SUT
$submissions = $this->allocator->index_submissions_by_authors($submissions);
}
......
......@@ -48,20 +48,21 @@ if ($preview = optional_param('preview', 0, PARAM_INT)) {
}
require_login($course, false, $cm);
$workshop = new workshop_api($workshop, $cm, $course);
if (isguestuser()) {
print_error('guestsarenotallowed');
}
$workshop = new workshop($workshop, $cm, $course);
if ('preview' == $mode) {
require_capability('mod/workshop:editdimensions', $PAGE->context);
// TODO logging add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", "$workshop->id");
$PAGE->set_url($workshop->previewform_url());
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
} elseif ('assessment' == $mode) {
if (!(has_capability('mod/workshop:peerassess', $PAGE->context) || has_capability('mod/workshop:peerassess', $PAGE->context))) {
if (!has_any_capability(array('mod/workshop:peerassess', 'mod/workshop:assessallsubmissions'), $PAGE->context)) {
print_error('nopermissions', '', $workshop->view_url());
}
// TODO logging add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", "$workshop->id");
$PAGE->set_url($workshop->assess_url($assessment->id));
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
......@@ -79,22 +80,20 @@ $strategy = $workshop->grading_strategy_instance();
// load the form to edit the grading strategy dimensions
$mform = $strategy->get_assessment_form($PAGE->url, $mode);
// initialize form data
//todo $mform->set_data($formdata);
if ($mform->is_cancelled()) {
redirect($returnurl);
} elseif ($data = $mform->get_data()) {
if (isset($data->backtoeditform)) {
// user wants to return from preview to form editing
redirect($workshop->editform_url());
}
$strategy->save_assessment($data);
$strategy->save_assessment($assessment, $data);
if (isset($data->saveandclose)) {
redirect($workshop->view_url());
} else {
// save and continue - redirect to self to prevent data being re-posted by pressing "Reload"
redirect($PAGE->url->out());
redirect($PAGE->url);
}
}
......@@ -108,7 +107,7 @@ $navlinks[] = array('name' => format_string($workshop->name),
'type' => 'activityinstance');
if ($mode == 'preview') {
$navlinks[] = array('name' => get_string('editingassessmentform', 'workshop'),
'link' => $workshop->editform_url(),
'link' => $workshop->editform_url()->out(),
'type' => 'title');
$navlinks[] = array('name' => get_string('previewassessmentform', 'workshop'),
'link' => '',
......@@ -122,16 +121,20 @@ $navigation = build_navigation($navlinks);
// Output starts here
$wsoutput = $THEME->get_renderer('mod_workshop', $PAGE); // workshop renderer
echo $OUTPUT->header($navigation);
echo $OUTPUT->heading(get_string('assessmentform', 'workshop'), 2);
if (has_capability('mod/workshop:viewauthornames', $PAGE->context)) {
$showname = true;
$author = $workshop->user_info($submission->userid);
} else {
$showname = false;
$author = null;
if ('assessment' === $mode) {
if (has_capability('mod/workshop:viewauthornames', $PAGE->context)) {
$showname = true;
$author = $workshop->user_info($submission->userid);
} else {
$showname = false;
$author = null;
}
$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE); // workshop renderer
echo $wsoutput->submission_full($submission, $showname, $author);
}
echo $wsoutput->submission_full($submission, $showname, $author);
$mform->display();
echo $OUTPUT->footer();
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/workshop/db" VERSION="20090727" COMMENT="XMLDB file for Moodle mod/workshop"
<XMLDB PATH="mod/workshop/db" VERSION="20090731" COMMENT="XMLDB file for Moodle mod/workshop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
......@@ -154,8 +154,9 @@
<FIELD NAME="workshopid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the Workshop instance where this dimension is used as a part of evaluation form." PREVIOUS="id" NEXT="sort"/>
<FIELD NAME="sort" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The order of the dimension in the form" PREVIOUS="workshopid" NEXT="description"/>
<FIELD NAME="description" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="The description of the dimension" PREVIOUS="sort" NEXT="descriptionformat"/>
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description" NEXT="grade"/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="If greater than 0, then the value is maximum grade on a scale 0..grade. If lesser than 0, then its absolute value is the id of a record in scale table. If equals 0, then no grading is possible for this dimension, just commenting." PREVIOUS="descriptionformat" NEXT="weight"/>
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the description field" PREVIOUS="description" NEXT="descriptiontrust"/>
<FIELD NAME="descriptiontrust" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Can the content be trusted" PREVIOUS="descriptionformat" NEXT="grade"/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="If greater than 0, then the value is maximum grade on a scale 0..grade. If lesser than 0, then its absolute value is the id of a record in scale table. If equals 0, then no grading is possible for this dimension, just commenting." PREVIOUS="descriptiontrust" NEXT="weight"/>
<FIELD NAME="weight" TYPE="int" LENGTH="5" NOTNULL="false" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" COMMENT="The weigh of the dimension" PREVIOUS="grade"/>
</FIELDS>
<KEYS>
......@@ -190,4 +191,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
\ No newline at end of file
......@@ -39,7 +39,7 @@ has_capability('moodle/site:config', get_system_context()) || die('You are not a
$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
$workshop = new workshop_api($workshop, $cm, $course); // wrap the record with a full API
$workshop = new workshop($workshop, $cm, $course); // wrap the record with a full API
require_login($course, false, $cm);
......@@ -48,15 +48,18 @@ $PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
$PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'workshop')));
$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);
$navigation = build_navigation('Development tools', $cm);
$menu = navmenu($course, $cm);
// todo $menu = navmenu($course, $cm);
switch ($tool) {
case 'mksubmissions':
$authors = $workshop->get_peer_authors(false);
$authorswithsubmission = $workshop->get_peer_authors(true);
$authors = array_diff_key($authors, $authorswithsubmission);
echo $OUTPUT->header($navigation, $menu);
echo $OUTPUT->header($navigation);
$c = 0; // counter
foreach ($authors as $authorid => $author) {
$timenow = time() - rand(0, 60 * 60 * 24 * 7); // submitted sometimes during last week
$submission = new stdClass();
......@@ -66,18 +69,46 @@ case 'mksubmissions':
$submission->timecreated = $timenow;
$submission->timemodified = $timenow;
$submission->title = $author->firstname . '\'s submission';
$submission->data = '';
$submission->dataformat = FORMAT_HTML;
$submission->datatrust = 0;
$submission->content = "<p>Pellentesque habitant morbi tristique " .
"senectus et netus et malesuada fames ac " .
"turpis egestas. Sed posuere volutpat nunc " .
"semper ultricies! Aenean elementum metus in " .
"lorem volutpat eu volutpat neque vulputate? " .
"Pellentesque sit amet sem leo. In hac " .
"habitasse platea dictumst. Proin quis " .
"accumsan elit. Nulla quis libero ac nunc " .
"elementum commodo at et sem. Vestibulum " .
"eget euismod felis. Lorem ipsum dolor sit " .
"amet, consectetur adipiscing elit. Aliquam " .
"id tellus vel velit aliquet volutpat at " .
"quis arcu. Nulla laoreet tincidunt sodales. " .
"Suspendisse potenti. Curabitur sagittis " .
"arcu nec erat aliquet imperdiet. Aenean at " .
"mi ut est molestie posuere a vitae mauris.</p>";
$submission->contentformat = FORMAT_HTML;
$submission->contenttrust = 0;
$submission->id = $DB->insert_record('workshop_submissions', $submission);
// todo print some info
echo "<pre>Added submission by " . fullname($author) . "</pre>\n";
$c++;
}
if ($c == 0) {
echo "<pre>No submission added</pre>\n";
}
echo $OUTPUT->continue_button($PAGE->url->out());
echo $OUTPUT->footer();
exit;
exit();
case 'menu':
// no break, skip to default
default:
echo $OUTPUT->header($navigation);
echo $OUTPUT->heading('Workshop development tools', 1);
echo '<ul>';
echo '<li><a href="' . $PAGE->url->out(false, array('tool' => 'mksubmissions')) . '">Fake submissions</a></li>';
echo '<li><a href="' . $PAGE->url->out(false, array('tool' => 'rmsubmissions')) . '">Remove all submissions (TODO)</a></li>';
echo '</ul>';
echo $OUTPUT->footer();
}
echo $OUTPUT->header($navigation, $menu);
echo $OUTPUT->heading('Workshop development tools', 1);
echo '<a href="' . $PAGE->url->out(false, array('tool' => 'mksubmissions')) . '">Fake submissions</a>';
echo $OUTPUT->footer();
......@@ -35,7 +35,7 @@ require_login($course, false, $cm);
require_capability('mod/workshop:editdimensions', $PAGE->context);
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
$workshop = new workshop_api($workshop, $cm, $course);
$workshop = new workshop($workshop, $cm, $course);
$PAGE->set_url($workshop->editform_url());
$PAGE->set_title($workshop->name);
......@@ -44,21 +44,13 @@ $PAGE->set_heading($course->fullname);
// load the grading strategy logic
$strategy = $workshop->grading_strategy_instance();
// load the assessment form definition from the database
// this must be called before get_edit_strategy_form() where we have to know
// the number of repeating fieldsets
$formdata = $strategy->load_form();
// load the form to edit the grading strategy dimensions
$mform = $strategy->get_edit_strategy_form($PAGE->url);
// initialize form data
$mform->set_data($formdata);
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($data = $mform->get_data()) {
$strategy->save_form($data);
$strategy->save_edit_strategy_form($data);
if (isset($data->saveandclose)) {
redirect($workshop->view_url());
} elseif (isset($data->saveandpreview)) {
......@@ -83,8 +75,9 @@ $navlinks[] = array('name' => get_string('editingassessmentform', 'workshop'),
$navigation = build_navigation($navlinks);
// OUTPUT STARTS HERE
// todo use outputlib
print_header_simple(format_string($workshop->name), '', $navigation, '', '', true, '', navmenu($course, $cm));
print_header_simple(format_string($workshop->name), '', $navigation, '', '', true, '');
print_heading(get_string('strategy' . $workshop->strategy, 'workshop'));
......
......@@ -26,11 +26,13 @@
defined('MOODLE_INTERNAL') || die();
/**
* Represents the nodes of the virtual directory tree that may be browsed in file manager
* Represents virtual root node for all submissions
*
* Here we create a virtual hierarchy of all submissions, sorted by their author.
* Workshop submission uses two fileareas: workshop_submission_content
* for editor's embeded media and workshop_submission_attachment for attachments.
* In both, the itemid represents the submission id.
*/
class workshop_file_info extends file_info {
class workshop_file_info_submissions_container extends file_info {
protected $course;
protected $cm;
protected $areas;
......@@ -90,7 +92,8 @@ class workshop_file_info extends file_info {
global $DB;
$children = array();
$itemids = $DB->get_records('files', array('contextid' => $this->context->id, 'filearea' => $this->filearea), 'itemid', "DISTINCT itemid");
$itemids = $DB->get_records('files', array('contextid' => $this->context->id, 'filearea' => $this->filearea),
'itemid', "DISTINCT itemid");
foreach ($itemids as $itemid => $unused) {
if ($child = $this->browser->get_file_info($this->context, $this->filearea, $itemid)) {
$children[] = $child;
......
......@@ -25,7 +25,6 @@
defined('MOODLE_INTERNAL') || die();
//require_once(dirname(dirname(dirname(__FILE__))).'/lib.php'); // module library
require_once(dirname(dirname(__FILE__)).'/assessment_form.php'); // parent class definition
/**
......@@ -40,32 +39,38 @@ class workshop_accumulative_assessment_form extends workshop_assessment_form {
*
* Called by the parent::definition()
*
* @access protected
* @return void
*/
protected function definition_inner(&$mform) {
$fields = (array)$this->_customdata['fields'];
$nodims = $this->_customdata['nodims']; // number of assessment dimensions
for ($i = 0; $i < $this->strategy->get_number_of_dimensions(); $i++) {
$mform->addElement('hidden', 'nodims', $nodims);
for ($i = 0; $i < $nodims; $i++) {
// dimension header
$mform->addElement('header', "dimensionhdr[$i]",
str_replace('{no}', $i+1, get_string('dimensionnumberaccumulative', 'workshop', '{no}')));
$dimtitle = get_string('dimensionnumberaccumulative', 'workshop', $i+1);
$mform->addElement('header', "dimensionhdr__idx_$i", $dimtitle);
// dimension id
$mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields['dimensionid__idx_'.$i]);
// dimension description
$desc = '<div id="id_dim_'.$this->fields["dimensionid[$i]"] . '_desc" class="fitem description accumulative">' . "\n";
$desc .= format_text($this->fields["description[$i]"], $this->fields["descriptionformat[$i]"]);
$desc = '<div id="id_dim_'.$fields['dimensionid__idx_'.$i].'_desc" class="fitem description accumulative">'."\n";
$desc .= format_text($fields['description__idx_'.$i], $fields['descriptionformat__idx_'.$i]);
$desc .= "\n</div>";
$mform->addElement('html', $desc);
// grade for this aspect
$label = 'Grade'; // todo
$label = 'Grade'; // todo i18n
$label .= ' / ' . $fields['grade__idx_' . $i];
$options = array(10,9,8,7,6,5,4,3,2,1,0); // todo
$mform->addElement('select', "grade[$i]", $label, $options);
$mform->addElement('select', 'grade__idx_' . $i, $label, $options);
// comment
$label = 'Comment'; //todo
$mform->addElement('htmleditor', "comment[$i]", $label, array());
$label = 'Comment'; //todo i18n
//$mform->addElement('editor', 'peercomment__idx_' . $i, $label, null, array('maxfiles' => 0));
$mform->addElement('textarea', 'peercomment__idx_' . $i, $label, array('cols' => 60, 'rows' => 5));
}
}
......
......@@ -40,34 +40,34 @@ class workshop_edit_accumulative_strategy_form extends workshop_edit_strategy_fo
*
* Called by the parent::definition()
*
* @access protected
* @return void
*/
protected function definition_inner(&$mform) {
$gradeoptions = array(20 => 20, 10 => 10, 5 => 5);
$weights = workshop_get_dimension_weights();
$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);
// value not to be overridden by submitted value
$mform->setConstants(array('norepeats' => $norepeats));
$repeated = array();
$repeated[] =& $mform->createElement('hidden', 'dimensionid', 0);
$repeated[] =& $mform->createElement('header', 'dimension',
get_string('dimensionnumberaccumulative', 'workshop', '{no}'));
$repeated[] =& $mform->createElement('htmleditor', 'description',
get_string('dimensiondescription', 'workshop'), array());
$repeated[] =& $mform->createElement('select', 'grade', get_string('grade'), $gradeoptions);
$repeated[] =& $mform->createElement('select', 'weight', get_string('dimensionweight', 'workshop'), $weights);
$gradeoptions = array(20 => 20, 10 => 10, 8=>8, 5 => 5);
$weights = workshop_get_dimension_weights();
$repeatedoptions = array();
$repeatedoptions['description']['type'] = PARAM_CLEANHTML;
$repeatedoptions['description']['helpbutton'] = array('dimensiondescription',
get_string('dimensiondescription', 'workshop'), 'workshop');
$repeatedoptions['grade']['default'] = 10;
$repeatedoptions['weight']['default'] = 1;
for ($i = 0; $i < $norepeats; $i++) {
$mform->addElement('header', 'dimension'.$i, get_string('dimensionnumberaccumulative', 'workshop', $i+1));
$mform->addElement('hidden', 'dimensionid__idx_'.$i);
$mform->addElement('editor', 'description__idx_'.$i.'_editor', get_string('dimensiondescription', 'workshop'),
array('cols' => 20), $descriptionopts);
$mform->addElement('select', 'grade__idx_'.$i, get_string('grade'), $gradeoptions);
$mform->addElement('select', 'weight__idx_'.$i, get_string('dimensionweight', 'workshop'), $weights);
}
$numofdimensionstoadd = 2;
$numofinitialdimensions = 3;
$numofdisplaydimensions = max($this->strategy->get_number_of_dimensions() + $numofdimensionstoadd, $numofinitialdimensions);
$this->repeat_elements($repeated, $numofdisplaydimensions, $repeatedoptions, 'numofdimensions', 'adddimensions', $numofdimensionstoadd, get_string('addmoredimensionsaccumulative', 'workshop', $numofdimensionstoadd));
$mform->registerNoSubmitButton('noadddims');
$mform->addElement('submit', 'noadddims', get_string('addmoredimensionsaccumulative', 'workshop',
WORKSHOP_STRATEGY_ADDDIMS));
$mform->closeHeaderBefore('noadddims');
$this->set_data($current);
}
}
......@@ -32,15 +32,15 @@ require_once($CFG->dirroot . '/mod/workshop/grading/accumulative/strategy.php');
* Test subclass that makes all the protected methods we want to test public
*/
class testable_workshop_accumulative_strategy extends workshop_accumulative_strategy {
public function _cook_dimension_records(array $raw) {
return parent::_cook_dimension_records($raw);
}
public function _cook_form_data(stdClass $raw) {
return parent::_cook_form_data($raw);
public function _cook_edit_form_data(stdClass $raw) {
return parent::_cook_edit_form_data($raw);
}
public function _cook_assessment_form_data(stdClass $assessment, stdClass $raw) {
return parent::_cook_assessment_form_data($assessment, $raw);
}
}