MDL-36904 Assignment: Fix all errors and warnings from codechecker

This commit is contained in:
Damyon Wiese
2013-01-04 15:46:15 +08:00
parent 9da506c2a3
commit e5403f8c44
69 changed files with 2789 additions and 1939 deletions
+42 -17
View File
@@ -34,7 +34,9 @@ defined('MOODLE_INTERNAL') || die();
*/
abstract class assign_plugin {
/** @var assign $assignment the assignment record that contains the global settings for this assign instance */
/** @var assign $assignment the assignment record that contains the global
* settings for this assign instance
*/
protected $assignment;
/** @var string $type assignment plugin type */
private $type = '';
@@ -73,7 +75,9 @@ abstract class assign_plugin {
* @return bool
*/
public final function is_last() {
if ((count(get_plugin_list($this->get_subtype()))-1) == get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder')) {
$lastindex = count(get_plugin_list($this->get_subtype()))-1;
$currentindex = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder');
if ($lastindex == $currentindex) {
return true;
}
@@ -123,7 +127,6 @@ abstract class assign_plugin {
/**
* What was the last error?
*
*
* @return string
*/
public final function get_error() {
@@ -184,8 +187,9 @@ abstract class assign_plugin {
/**
* Save any custom data for this form submission
*
* @param stdClass $submissionorgrade - assign_submission or assign_grade
* For submission plugins this is the submission data, for feedback plugins it is the grade data
* @param stdClass $submissionorgrade - assign_submission or assign_grade.
* For submission plugins this is the submission data,
* for feedback plugins it is the grade data
* @param stdClass $data - the data submitted from the form
* @return bool - on error the subtype should call set_error and return false.
*/
@@ -240,7 +244,8 @@ abstract class assign_plugin {
* Get any additional fields for the submission/grading form for this assignment.
* This function is retained for backwards compatibility - new plugins should override {@link get_form_elements_for_user()}.
*
* @param mixed $submissionorgrade submission|grade - For submission plugins this is the submission data, for feedback plugins it is the grade data
* @param mixed $submissionorgrade submission|grade - For submission plugins this is the submission data,
* for feedback plugins it is the grade data
* @param MoodleQuickForm $mform - This is the form
* @param stdClass $data - This is the form data that can be modified for example by a filemanager element
* @return boolean - true if we added anything to the form
@@ -253,7 +258,8 @@ abstract class assign_plugin {
* Should not output anything - return the result as a string so it can be consumed by webservices.
*
* @param stdClass $submissionorgrade assign_submission or assign_grade
* For submission plugins this is the submission data, for feedback plugins it is the grade data
* For submission plugins this is the submission data,
* for feedback plugins it is the grade data
* @return string - return a string representation of the submission in full
*/
public function view(stdClass $submissionorgrade) {
@@ -289,7 +295,9 @@ abstract class assign_plugin {
public final function has_admin_settings() {
global $CFG;
return file_exists($CFG->dirroot . '/mod/assign/' . substr($this->get_subtype(), strlen('assign')) . '/' . $this->get_type() . '/settings.php');
$pluginroot = $CFG->dirroot . '/mod/assign/' . substr($this->get_subtype(), strlen('assign')) . '/' . $this->get_type();
$settingsfile = $pluginroot . '/settings.php';
return file_exists($settingsfile);
}
/**
@@ -302,7 +310,11 @@ abstract class assign_plugin {
public final function set_config($name, $value) {
global $DB;
$current = $DB->get_record('assign_plugin_config', array('assignment'=>$this->assignment->get_instance()->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type(), 'name'=>$name), '*', IGNORE_MISSING);
$dbparams = array('assignment'=>$this->assignment->get_instance()->id,
'subtype'=>$this->get_subtype(),
'plugin'=>$this->get_type(),
'name'=>$name);
$current = $DB->get_record('assign_plugin_config', $dbparams, '*', IGNORE_MISSING);
if ($current) {
$current->value = $value;
@@ -334,14 +346,21 @@ abstract class assign_plugin {
}
$assignment = $this->assignment->get_instance();
if ($assignment) {
$result = $DB->get_record('assign_plugin_config', array('assignment'=>$assignment->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type(), 'name'=>$setting), '*', IGNORE_MISSING);
$dbparams = array('assignment'=>$assignment->id,
'subtype'=>$this->get_subtype(),
'plugin'=>$this->get_type(),
'name'=>$setting);
$result = $DB->get_record('assign_plugin_config', $dbparams, '*', IGNORE_MISSING);
if ($result) {
return $result->value;
}
}
return false;
}
$results = $DB->get_records('assign_plugin_config', array('assignment'=>$this->assignment->get_instance()->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type()));
$dbparams = array('assignment'=>$this->assignment->get_instance()->id,
'subtype'=>$this->get_subtype(),
'plugin'=>$this->get_type());
$results = $DB->get_records('assign_plugin_config', $dbparams);
$config = new stdClass();
if (is_array($results)) {
@@ -454,7 +473,8 @@ abstract class assign_plugin {
* @return bool true or false - false will trigger a rollback
*/
public function upgrade_settings(context $oldcontext, stdClass $oldassignment, & $log) {
$log = $log . ' ' . get_string('upgradenotimplemented', 'mod_assign', array('type'=>$this->type, 'subtype'=>$this->get_subtype()));
$params = array('type'=>$this->type, 'subtype'=>$this->get_subtype());
$log .= ' ' . get_string('upgradenotimplemented', 'mod_assign', $params);
return false;
}
@@ -468,8 +488,13 @@ abstract class assign_plugin {
* @param string $log Record upgrade messages in the log
* @return boolean true or false - false will trigger a rollback
*/
public function upgrade(context $oldcontext, stdClass $oldassignment, stdClass $oldsubmissionorgrade, stdClass $submissionorgrade, & $log) {
$log = $log . ' ' . get_string('upgradenotimplemented', 'mod_assign', array('type'=>$this->type, 'subtype'=>$this->get_subtype()));
public function upgrade(context $oldcontext,
stdClass $oldassignment,
stdClass $oldsubmissionorgrade,
stdClass $submissionorgrade,
& $log) {
$params = array('type'=>$this->type, 'subtype'=>$this->get_subtype());
$log = $log . ' ' . get_string('upgradenotimplemented', 'mod_assign', $params);
return false;
}
@@ -480,7 +505,7 @@ abstract class assign_plugin {
* @return string
*/
public function format_for_log(stdClass $submissionorgrade) {
// format the info for each submission plugin add_to_log
// Format the info for each submission plugin add_to_log.
return '';
}
@@ -533,7 +558,7 @@ abstract class assign_plugin {
global $CFG, $DB, $USER;
$urlbase = $CFG->wwwroot.'/pluginfile.php';
// permission check on the itemid
// Permission check on the itemid.
if ($this->get_subtype() == 'assignsubmission') {
if ($itemid) {
@@ -546,7 +571,7 @@ abstract class assign_plugin {
}
}
} else {
// not supported for feedback plugins
// Not supported for feedback plugins.
return null;
}