mirror of
https://github.com/moodle/moodle.git
synced 2025-03-13 20:26:32 +01:00
More work on the strategy API
This commit is contained in:
parent
725d615401
commit
7b5d01a7e8
@ -66,18 +66,21 @@ add_to_log($course->id, "workshop", "editgradingform", "editgradingform.php?id=$
|
||||
$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 grading strategy logic
|
||||
$strategylib = dirname(__FILE__) . '/grading/' . $workshop->strategy . '/strategy.php';
|
||||
if (file_exists($strategylib)) {
|
||||
require_once($strategylib);
|
||||
} else {
|
||||
print_error('errloadingstrategylib', 'workshop', $returnurl);
|
||||
}
|
||||
$classname = 'workshop_' . $workshop->strategy . '_strategy';
|
||||
$strategy = new $classname($workshop);
|
||||
|
||||
// load the dimensions from the database
|
||||
$dimensions = $strategy->load_dimensions();
|
||||
|
||||
// load the form to edit the grading strategy dimensions
|
||||
$strategyform = dirname(__FILE__) . '/grading/' . $workshop->strategy . '/gradingform.php';
|
||||
if (file_exists($strategyform)) {
|
||||
require_once($strategyform);
|
||||
} else {
|
||||
print_error('errloadingstrategyform', 'workshop', $returnurl);
|
||||
}
|
||||
$classname = 'workshop_edit_' . $workshop->strategy . '_strategy_form';
|
||||
$mform = new $classname($selfurl, true, count($dimensions));
|
||||
$mform = $strategy->get_edit_strategy_form($selfurl, true, count($dimensions));
|
||||
|
||||
// initialize form data
|
||||
$formdata = new stdClass;
|
||||
|
@ -53,7 +53,7 @@ class workshop_edit_accumulative_strategy_form extends workshop_edit_strategy_fo
|
||||
|
||||
$repeated = array();
|
||||
$repeated[] =& $mform->createElement('hidden', 'dimensionid', 0);
|
||||
$repeated[] =& $mform->createElement('header', 'dimension', get_string('dimension', 'workshop'));
|
||||
$repeated[] =& $mform->createElement('header', 'dimension', get_string('dimensionnumber', 'workshop', '{no}'));
|
||||
$repeated[] =& $mform->createElement('textarea', 'description',
|
||||
get_string('dimensiondescription', 'workshop'), array('cols'=>60));
|
||||
$repeated[] =& $mform->createElement('select', 'grade', get_string('grade'), $gradeoptions);
|
||||
|
39
mod/workshop/grading/accumulative/strategy.php
Normal file
39
mod/workshop/grading/accumulative/strategy.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?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 class with accumulative grading strategy logic
|
||||
*
|
||||
* @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__)) . '/strategy.php'); // parent class
|
||||
|
||||
|
||||
/**
|
||||
* Accumulative grading strategy logic.
|
||||
*/
|
||||
class workshop_accumulative_strategy extends workshop_strategy {
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* This file defines a base class for all grading strategy editing forms.
|
||||
* This file defines a base class for all grading strategy logic
|
||||
*
|
||||
* @package mod-workshop
|
||||
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
|
||||
@ -34,6 +34,19 @@ if (!defined('MOODLE_INTERNAL')) {
|
||||
*/
|
||||
interface workshop_strategy_interface {
|
||||
|
||||
/**
|
||||
* Load the assessment dimensions from database
|
||||
*
|
||||
* Assessment dimension (also know as assessment element) represents one aspect or criterion
|
||||
* to be evaluated. Each dimension consists of a set of form fields. Strategy-specific information
|
||||
* are saved in workshop_forms_{strategyname} tables.
|
||||
*
|
||||
* @uses $DB
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function load_dimensions();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,4 +54,54 @@ interface workshop_strategy_interface {
|
||||
*/
|
||||
class workshop_strategy implements workshop_strategy_interface {
|
||||
|
||||
/** the name of the strategy */
|
||||
public $name;
|
||||
|
||||
/** the parent workshop instance */
|
||||
protected $_workshop;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $workshop The workshop instance record
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($workshop) {
|
||||
|
||||
$this->name = $workshop->strategy;
|
||||
$this->_workshop = $workshop;
|
||||
}
|
||||
|
||||
|
||||
public function get_edit_strategy_form($actionurl, $edit=true, $nodimensions=0) {
|
||||
global $CFG; // needed because the included files use it
|
||||
|
||||
$strategyform = dirname(__FILE__) . '/' . $this->name . '/gradingform.php';
|
||||
if (file_exists($strategyform)) {
|
||||
require_once($strategyform);
|
||||
} else {
|
||||
throw new moodle_exception('errloadingstrategyform', 'workshop');
|
||||
}
|
||||
$classname = 'workshop_edit_' . $this->name . '_strategy_form';
|
||||
|
||||
return new $classname($actionurl, $edit, $nodimensions);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the assessment dimensions from database
|
||||
*
|
||||
* This base method just fetches all relevant records from the strategy form table.
|
||||
*
|
||||
* @uses $DB
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function load_dimensions() {
|
||||
global $DB;
|
||||
|
||||
return $DB->get_records('workshop_forms_' . $this->name, array('workshopid' => $this->_workshop->id), 'sort');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ $string['editgradingform'] = 'Edit grading form';
|
||||
$string['editinggradingform'] = 'Editing grading form';
|
||||
$string['dimensiondescription'] = 'Dimension description';
|
||||
$string['dimensionweight'] = 'Dimension weight';
|
||||
$string['dimension'] = 'Dimension of assessment';
|
||||
$string['dimension'] = 'Assessment dimension';
|
||||
$string['dimensionnumber'] = 'Dimension $a';
|
||||
$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';
|
||||
|
Loading…
x
Reference in New Issue
Block a user