Commit 4eab2e7f authored by David Mudrak's avatar David Mudrak
Browse files

MDL-17827 workshop: initial check in of the files

Exported from David's git repository
parent de811c0c
This diff is collapsed.
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit grading form in for a particular instance of workshop
*
* @package mod-workshop
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
$a = optional_param('a', 0, PARAM_INT); // workshop instance ID
if ($id) {
if (! $cm = get_coursemodule_from_id('workshop', $id)) {
error('Course Module ID was incorrect');
}
if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
error('Course is misconfigured');
}
if (! $workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
error('Course module is incorrect');
}
} else if ($a) {
if (! $workshop = $DB->get_record('workshop', array('id' => $a))) {
error('Course module is incorrect');
}
if (! $course = $DB->get_record('course', array('id' => $workshop->course))) {
error('Course is misconfigured');
}
if (! $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id)) {
error('Course Module ID was incorrect');
}
} else {
error('You must specify a course_module ID or an instance ID');
}
require_login($course, true, $cm);
add_to_log($course->id, "workshop", "editgradingform", "editgradingform.php?id=$cm->id", "$workshop->id");
// where should the user be sent in case of error of canceling
$returnurl = "{$CFG->wwwroot}/mod/workshop/view.php?id={$cm->id}";
$selfurl = "{$CFG->wwwroot}/mod/workshop/editgradingform.php?id={$cm->id}";
// todo
$dimensions = $DB->get_records('workshop_forms_accumulative', array('workshopid' => $workshop->id), 'sort');
// load the form to edit the grading strategy dimensions
$strategylib = dirname(__FILE__) . '/grading/' . $workshop->strategy . '/edit_' . $workshop->strategy . '_strategy_form.php';
if (file_exists($strategylib)) {
require_once($strategylib);
} else {
print_error('errloadingstrategylib', 'workshop', $returnurl);
}
$classname = 'workshop_edit_' . $workshop->strategy . '_strategy_form';
$mform = new $classname($selfurl, true, count($dimensions));
// initialize form data
$formdata = new stdClass;
$formdata->workshopid = $workshop->id;
$formdata->strategy = $workshop->strategy;
$formdata->dimensions = $dimensions;
$mform->set_data($formdata);
if ($mform->is_cancelled()) {
redirect($returnurl);
} elseif ($data = $mform->get_data()) {
print_object($data); die();
}
// build the navigation and the header
$navlinks = array();
$navlinks[] = array('name' => get_string('modulenameplural', 'workshop'),
'link' => "index.php?id=$course->id",
'type' => 'activity');
$navlinks[] = array('name' => format_string($workshop->name),
'link' => "view.php?id=$cm->id",
'type' => 'activityinstance');
$navlinks[] = array('name' => get_string('editinggradingform', 'workshop'),
'link' => '',
'type' => 'title');
$navigation = build_navigation($navlinks);
// OUTPUT STARTS HERE
print_header_simple(format_string($workshop->name), '', $navigation, '', '', true,
update_module_button($cm->id, $course->id, get_string('modulename', 'workshop')), navmenu($course, $cm));
print_heading(get_string('strategy' . $workshop->strategy, 'workshop'));
$mform->display();
/// Finish the page
print_footer($course);
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file defines an mform to edit accumulative grading strategy forms.
*
* @package mod-workshop
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
}
require_once(dirname(dirname(__FILE__)).'/edit_strategy_form.php'); // parent class definition
/**
* Class for editing accumulative grading strategy forms.
*
* @uses moodleform
*/
class workshop_edit_accumulative_strategy_form extends workshop_edit_strategy_form {
/**
* Define the elements to be displayed at the form
*
* 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();
$repeated = array();
$repeated[] =& $mform->createElement('hidden', 'dimensionid', 0);
$repeated[] =& $mform->createElement('header', 'dimension', get_string('dimension', 'workshop'));
$repeated[] =& $mform->createElement('textarea', 'description',
get_string('dimensiondescription', 'workshop'), array('cols'=>60));
$repeated[] =& $mform->createElement('select', 'grade', get_string('grade'), $gradeoptions);
$repeated[] =& $mform->createElement('select', 'weight', get_string('dimensionweight', 'workshop'), $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;
$numofdimensionstoadd = 2;
$numofinitialdimensions = 3;
$numofdisplaydimensions = max($this->numofdimensions + $numofdimensionstoadd, $numofinitialdimensions);
$this->repeat_elements($repeated, $numofdisplaydimensions, $repeatedoptions, 'numofdimensions', 'adddimensions', $numofdimensionstoadd, get_string('addmoredimensionblanks', 'workshop', $numofdimensionstoadd));
}
/**
* Return the mapping of the db fields to the form fields for every dimension of assessment
*
* @access protected
* @return array Array ['field_db_name' => 'field_form_name']
*/
protected function get_dimension_fieldnames() {
return array(
'id' => 'dimensionid',
'description' => 'description',
'descriptionformat' => 'descriptionformat',
'grade' => 'grade',
'weight' => 'weight',
);
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file defines a base class for all grading strategy editing forms.
*
* @package mod-workshop
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page
}
require_once($CFG->libdir . '/formslib.php'); // parent class definition
/**
* Base class for editing all the strategy grading forms.
*
* This defines the common fields that all strategy grading forms need.
* Strategies should define their own class that inherits from this one, and
* implements the definition_inner() method.
*
* @uses moodleform
*/
class workshop_edit_strategy_form extends moodleform {
/**
* Number of dimensions that are populated from DB
*
* @var mixed
* @access protected
*/
protected $numofdimensions;
/**
* Constructor
*
* @param str $actionurl URL to handle data
* @param bool $editable Should the form be editable?
* @param int $initialdimensions Number of assessment dimensions that are already filled
* @access public
* @return void
*/
public function __construct($actionurl, $editable=true, $initialdimensions=0) {
$this->numofdimensions = $initialdimensions;
parent::moodleform($actionurl, null, 'post', '', array('class' => 'editstrategyform'), $editable);
}
/**
* Add the fields that are common for all grading strategies.
*
* If the strategy does not support all these fields, then you can override
* this method and remove the ones you don't want with
* $mform->removeElement().
* Stretegy subclassess should define their own fields in definition_inner()
*
* @access public
* @return void
*/
public function definition() {
global $CFG;
$mform = $this->_form;
$mform->addElement('hidden', 'workshopid');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'strategy');
$mform->setType('id', PARAM_ALPHA);
$this->definition_inner($mform);
if (!empty($CFG->usetags)) {
$mform->addElement('header', 'tagsheader', get_string('tags'));
$mform->addElement('tags', 'tags', get_string('tags'));
}
$buttonarray = array();
$buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');
}
/**
* Add any strategy specific form fields.
*
* @param object $mform the form being built.
*/
protected function definition_inner(&$mform) {
// By default, do nothing.
}
/**
* Set the form data before it is displayed
*
* Strategy plugins should provide the list of fields to be mapped from
* DB record to the form fields in their get_dimension_fieldnames() method
*
* @param object $formdata Should contain the array $formdata->dimensions
* @access public
* @return void
*/
public function set_data($formdata) {
if (is_array($formdata->dimensions) && !empty($formdata->dimensions)) {
// $formdata->dimensions must be array of dimension records loaded from database
$key = 0;
$default_values = array();
foreach ($formdata->dimensions as $dimension) {
foreach ($this->get_dimension_fieldnames() as $fielddbname => $fieldformname) {
$default_values[$fieldformname . '[' . $key . ']'] = $dimension->$fielddbname;
}
$key++;
}
$formdata = (object)((array)$formdata + $default_values);
}
parent::set_data($formdata);
}
/**
* Return the mapping of the db fields to the form fields for every assessment dimension
*
* @access protected
* @return array Array ['field_db_name' => 'field_form_name']
*/
protected function get_dimension_fieldnames() {
return array();
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This is a one-line short description of the file
*
* You can have a rather longer description of the file as well,
* if you like, and it can span multiple lines.
*
* @package mod-workshop
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/// Replace workshop with the name of your module and remove this line
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
$id = required_param('id', PARAM_INT); // course
if (! $course = $DB->get_record('course', array('id' => $id))) {
error('Course ID is incorrect');
}
require_course_login($course);
add_to_log($course->id, 'workshop', 'view all', "index.php?id=$course->id", '');
/// Get all required stringsworkshop
$strworkshops = get_string('modulenameplural', 'workshop');
$strworkshop = get_string('modulename', 'workshop');
/// Print the header
$navlinks = array();
$navlinks[] = array('name' => $strworkshops, 'link' => '', 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple($strworkshops, '', $navigation, '', '', true, '', navmenu($course));
/// Get all the appropriate data
if (! $workshops = get_all_instances_in_course('workshop', $course)) {
notice('There are no workshops', "../../course/view.php?id=$course->id");
die;
}
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string('name');
$strweek = get_string('week');
$strtopic = get_string('topic');
if ($course->format == 'weeks') {
$table->head = array ($strweek, $strname);
$table->align = array ('center', 'left');
} else if ($course->format == 'topics') {
$table->head = array ($strtopic, $strname);
$table->align = array ('center', 'left', 'left', 'left');
} else {
$table->head = array ($strname);
$table->align = array ('left', 'left', 'left');
}
foreach ($workshops as $workshop) {
if (!$workshop->visible) {
//Show dimmed if the mod is hidden
$link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">$workshop->name</a>";
} else {
//Show normal if the mod is visible
$link = "<a href=\"view.php?id=$workshop->coursemodule\">$workshop->name</a>";
}
if ($course->format == 'weeks' or $course->format == 'topics') {
$table->data[] = array ($workshop->section, $link);
} else {
$table->data[] = array ($link);
}
}
print_heading($strworkshops);
print_table($table);
/// Finish the page
print_footer($course);
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* English strings for Workshop module
*
* @package mod-workshop
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['accesscontrol'] = 'Access control';
$string['addmoredimensionblanks'] = 'Blanks for $a more dimensions';
$string['agreeassessments'] = 'Assessments must be agreed';
$string['agreeassessmentsdesc'] = 'Authors may comment assessments of their work and agree/disagree with it';
$string['anonymity'] = 'Anonymity mode';
$string['anonymityauthors'] = 'Reviewers can\'t see authors\' names';
$string['anonymityboth'] = 'Fully anonymous';
$string['anonymitynone'] = 'Not anonymous';
$string['anonymityreviewers'] = 'Authors can\'t see reviewers\' names';
$string['assessallexamples'] = 'Assess all examples';
$string['assessmentcomps'] = 'Required level of assessments similarity';
$string['assessmentend'] = 'End of assessment phase';
$string['assessmentsettings'] = 'Assessment settings';
$string['assessmentstart'] = 'Start of assessment phase';
$string['assesswosubmission'] = 'Assess without submission';
$string['assesswosubmissiondesc'] = 'Users can assess peers even without their own submission';
$string['comparisonhigh'] = 'High';
$string['comparisonlow'] = 'Low';
$string['comparisonnormal'] = 'Normal';
$string['comparisonveryhigh'] = 'Very high';
$string['comparisonverylow'] = 'Very low';
$string['configanonymity'] = 'Default anonymity mode in workshops';
$string['configassessmentcomps'] = 'Default value of the setting that influences the calculation of the grade for assessment.';
$string['configexamplesmode'] = 'Default mode of examples assessment in workshops';
$string['configgrade'] = 'Default maximum grade for submission in workshops';
$string['configgradinggrade'] = 'Default maximum grade for assessment in workshops';
$string['configmaxbytes'] = 'Default maximum submission file size for all workshops on the site (subject to course limits and other local settings)';
$string['confignexassessments'] = 'Default number of examples to be reviewed by a user in the example assessment phase';
$string['confignsassessments'] = 'Default number of allocated submissions to be reviewed by a user in the assessment phase';
$string['configstrategy'] = 'Default grading strategy for workshops';
$string['editgradingform'] = 'Edit grading form';
$string['editinggradingform'] = 'Editing grading form';
$string['dimensiondescription'] = 'Dimension description';
$string['dimensionweight'] = 'Dimension weight';
$string['dimension'] = 'Dimension of assessment';
$string['examplesbeforeassessment'] = 'Examples are available after own submission and must be assessed before peer/self assessment phase';
$string['examplesbeforesubmission'] = 'Examples must be assessed before own submission';
$string['examplesmode'] = 'Mode of examples assessment';
$string['examplesvoluntary'] = 'Assessment of example submission is voluntary';
$string['gradeforassessment'] = 'Grade for assessment';
$string['gradeforsubmission'] = 'Grade for submission';
$string['gradingsettings'] = 'Grading settings';
$string['hidegradesdesc'] = 'If assessments must be agreed, should the grades be hidden from the author? If grades are hidden, authors can see only comments';
$string['hidegrades'] = 'Hide grades before agreement';
$string['introduction'] = 'Introduction';
$string['latesubmissionsdesc'] = 'Allow submitting the work after the deadline';
$string['latesubmissions'] = 'Late submissions';
$string['maxbytes'] = 'Maximum file size';
$string['modulenameplural'] = 'Workshops';
$string['modulename'] = 'Workshop';
$string['nattachments'] = 'Number of required submission attachments';
$string['nexassessments'] = 'Number of required assessments of examples';
$string['nsassessments'] = 'Number of required assessments of other users\' work';
$string['releasegrades'] = 'Push final grades into the gradebook';
$string['requirepassword'] = 'Require password';
$string['strategyaccumulative'] = 'Accumulative grading';
$string['strategyerrorbanded'] = 'Error banded grading';
$string['strategy'] = 'Grading strategy';
$string['strategynograding'] = 'No grading';
$string['strategyrubric'] = 'Rubric grading';
$string['submissionend'] = 'End of submission phase';
$string['submissionsettings'] = 'Submission settings';
$string['submissionstart'] = 'Start of submission phase';
$string['teacherweight'] = 'Weight of the teacher\'s assessments';
$string['useexamplesdesc'] = 'Users practise evaluating on example submissions';
$string['useexamples'] = 'Use examples';
$string['usepeerassessmentdesc'] = 'Users perform peer assessment of others\' work';
$string['usepeerassessment'] = 'Use peer assessment';
$string['useselfassessmentdesc'] = 'Users perform self assessment of their own work';
$string['useselfassessment'] = 'Use self assessment';
$string['workshopfeatures'] = 'Workshop features';
$string['workshopname'] = 'Workshop name';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
$string[''] = '';
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Library of interface functions and constants for module workshop
*
* All the core Moodle functions, neeeded to allow the module to work