mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
Added validation to grading form, implemented methods in advanced grading to return form contents and process and return the final grade
This commit is contained in:
parent
6abcb0c21f
commit
18e6298c7b
4 changed files with 133 additions and 7 deletions
|
@ -264,6 +264,16 @@ abstract class gradingform_controller {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves non-js data and returns the gradebook grade
|
||||
*/
|
||||
abstract public function save_and_get_grade($itemid, $formdata);
|
||||
|
||||
/**
|
||||
* Returns html for form element
|
||||
*/
|
||||
abstract public function to_html($elementname, $itemid);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -226,6 +226,38 @@ class gradingform_rubric_controller extends gradingform_controller {
|
|||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves non-js data and returns the gradebook grade
|
||||
*/
|
||||
public function save_and_get_grade($itemid, $formdata) {
|
||||
// TODO: this function is a patch at the moment!
|
||||
if (is_array($formdata) && array_key_exists('grade', $formdata)) {
|
||||
return $formdata['grade'];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html for form element
|
||||
*/
|
||||
public function to_html($elementname, $submissionid) {
|
||||
// TODO: this function is a patch at the moment!
|
||||
|
||||
//global $PAGE, $USER;
|
||||
//$gradingrenderer = $this->prepare_renderer($PAGE);
|
||||
$output = '';
|
||||
$output .= "assessing submission $submissionid<br />";
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'text', 'name' => $elementname.'[grade]', 'size' => '20'));
|
||||
//$output .= "assessing user $userid on assignment $assignmentid<br>";
|
||||
//TODO find $submissionid from $userid & $assignmentid (may not exist yet, actually)
|
||||
/*$submissionid = null;
|
||||
$gradingwidget = $this->make_grading_widget($USER->id, $submissionid);
|
||||
if ($gradingwidget instanceof renderable) {
|
||||
return $output. $gradingrenderer->render($gradingwidget);
|
||||
}*/
|
||||
return $output;
|
||||
}
|
||||
|
||||
// TODO the following functions may be moved to parent:
|
||||
|
||||
/**
|
||||
|
@ -273,4 +305,9 @@ class gradingform_rubric_controller extends gradingform_controller {
|
|||
// TODO change filearea for embedded files in grading_definition.description
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function is_form_available($foruserid = null) {
|
||||
return true;
|
||||
// TODO this is temporary for testing!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,6 +374,19 @@ class grading_manager {
|
|||
return new $classname($this->context, $this->component, $this->area, $this->areacache->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the controller for the active method if it is available
|
||||
*/
|
||||
public function get_active_controller() {
|
||||
if ($gradingmethod = $this->get_active_method()) {
|
||||
$controller = $this->get_controller($gradingmethod);
|
||||
if ($controller->is_form_available()) {
|
||||
return $controller;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue