MDL-31276: Phpdocs cleanup for offline grading feature

This commit is contained in:
Damyon Wiese 2012-09-11 15:48:19 +08:00
parent d0d4796b4a
commit 7a2b911c6b
17 changed files with 79 additions and 65 deletions

View File

@ -349,7 +349,7 @@ abstract class assign_plugin {
}
/**
* Given a field name and value should update this plugins submission or grade
* Given a field name and value should update the text for this field in the plugins submission or grade
*
* @param string $name Name of the field.
* @param string $value Updated text
@ -361,14 +361,14 @@ abstract class assign_plugin {
}
/**
* Given a field name and value should update this plugins submission or grade
* Given a field name and value should update the format for this field in the plugins submission or grade
*
* @param string $name Name of the field.
* @param int $format Updated format
* @param int $submissionorgradeid The id of the submission or grade
* @param int $format Updated format.
* @param int $submissionorgradeid The id of the submission or grade.
* @return bool - true if the value was updated
*/
public function set_editor_format($name, $value, $submissionorgradeid) {
public function set_editor_format($name, $format, $submissionorgradeid) {
return false;
}
@ -404,7 +404,7 @@ abstract class assign_plugin {
return array();
}
/**
/**
* Given a field name, should return the format of an editor field that is part of
* this plugin. This is used when exporting to portfolio.
*
@ -416,7 +416,7 @@ abstract class assign_plugin {
return 0;
}
/**
/**
* Return true if this plugin can upgrade an old Moodle 2.2 assignment of this type
* and version.
*
@ -428,7 +428,7 @@ abstract class assign_plugin {
return false;
}
/**
/**
* Upgrade the settings from the old assignment to the new one
*
* @param context $oldcontext The context for the old assignment module

View File

@ -114,7 +114,7 @@ class assign_feedback_comments extends assign_feedback_plugin {
* Get the saved text content from the editor
*
* @param string $name
* @param int $submissionid
* @param int $gradeid
* @return string
*/
public function get_editor_text($name, $gradeid) {
@ -132,7 +132,7 @@ class assign_feedback_comments extends assign_feedback_plugin {
* Get the saved text content from the editor
*
* @param string $name
* @param int $submissionid
* @param int $gradeid
* @return string
*/
public function set_editor_text($name, $value, $gradeid) {

View File

@ -17,7 +17,7 @@
/**
* This file contains the forms to create and edit an instance of this module
*
* @package mod_assign
* @package assignfeedback_file
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/mod/assign/feedback/file/locallib.php');
/**
* Assignment grading options form
*
* @package mod_assign
* @package assignfeedback_file
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -38,7 +38,7 @@ class assignfeedback_file_batch_upload_files_form extends moodleform {
/**
* Define this form - called by the parent constructor
*/
function definition() {
public function definition() {
global $COURSE, $USER;
$mform = $this->_form;
@ -53,7 +53,12 @@ class assignfeedback_file_batch_upload_files_form extends moodleform {
'accepted_types'=>'*',
'return_types'=>FILE_INTERNAL);
$data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $params['context'], 'assignfeedback_file', ASSIGNFEEDBACK_BATCHFILE_FILEAREA, $USER->id);
$data = file_prepare_standard_filemanager($data,
'files',
$fileoptions,
$params['context'],
'assignfeedback_file',
ASSIGNFEEDBACK_BATCHFILE_FILEAREA, $USER->id);
$mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions);

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -28,7 +27,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot.'/mod/assign/feedback/file/importziplib.php');
/*
/**
* Import zip form
*
* @package assignfeedback_file
@ -59,7 +58,6 @@ class assignfeedback_file_import_zip_form extends moodleform implements renderab
return;
}
$files = $importer->get_import_files($contextid);
$mform->addElement('header', 'uploadzip', get_string('confirmuploadzip', 'assignfeedback_file'));
@ -110,7 +108,6 @@ class assignfeedback_file_import_zip_form extends moodleform implements renderab
}
}
if (count($updates)) {
$mform->addElement('html', $renderer->list_block_contents(array(), $updates));
} else {

View File

@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* library class for importing feedback files from a zip
*
* @package asignfeedback_file
* @package assignfeedback_file
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -41,6 +41,7 @@ class assignfeedback_file_zip_importer {
* @param stored_file $fileinfo - The fileinfo
* @param array $participants - A list of valid participants for this module indexed by unique_id
* @param stdClass $user - Set to the user that matches by participant id
* @param assign_plugin $plugin - Set to the plugin that exported the file
* @param string $filename - Set to truncated filename (prefix stripped)
* @return true If the participant Id can be extracted and this is a valid user
*/
@ -270,7 +271,6 @@ class assignfeedback_file_zip_importer {
}
}
require_once($CFG->dirroot . '/mod/assign/feedback/file/renderable.php');
$importsummary = new assignfeedback_file_import_summary($assignment->get_course_module()->id,
count($userswithnewfeedback),

View File

@ -79,14 +79,15 @@ class assign_feedback_file extends assign_feedback_plugin {
/**
* Copy all the files from one file area to another
*
* @param int fromcontextid - The source context id
* @param string fromcomponent - The source component
* @param string fromfilearea - The source filearea
* @param int fromitemid - The source item id
* @param int tocontextid - The destination context id
* @param string tocomponent - The destination component
* @param string tofilearea - The destination filearea
* @param int toitemid - The destination item id
* @param file_storage $fs - The source context id
* @param int $fromcontextid - The source context id
* @param string $fromcomponent - The source component
* @param string $fromfilearea - The source filearea
* @param int $fromitemid - The source item id
* @param int $tocontextid - The destination context id
* @param string $tocomponent - The destination component
* @param string $tofilearea - The destination filearea
* @param int $toitemid - The destination item id
* @return boolean
*/
private function copy_area_files(file_storage $fs,
@ -186,7 +187,13 @@ class assign_feedback_file extends assign_feedback_plugin {
public function save(stdClass $grade, stdClass $data) {
$fileoptions = $this->get_file_options();
$data = file_postupdate_standard_filemanager($data, 'files', $fileoptions, $this->assignment->get_context(), 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $grade->id);
$data = file_postupdate_standard_filemanager($data,
'files',
$fileoptions,
$this->assignment->get_context(),
'assignfeedback_file',
ASSIGNFEEDBACK_FILE_FILEAREA,
$grade->id);
return $this->update_file_count($grade);
}
@ -393,7 +400,6 @@ class assign_feedback_file extends assign_feedback_plugin {
ASSIGNFEEDBACK_FILE_FILEAREA,
$grade->id);
$filefeedback = $this->get_file_feedback($grade->id);
if ($filefeedback) {
$filefeedback->numfiles = $this->count_files($grade->id, ASSIGNFEEDBACK_FILE_FILEAREA);
@ -452,7 +458,7 @@ class assign_feedback_file extends assign_feedback_plugin {
*
* @return string - The html response
*/
function view_upload_zip() {
public function view_upload_zip() {
global $CFG, $USER;
require_capability('mod/assign:grade', $this->assignment->get_context());

View File

@ -45,7 +45,7 @@ class assignfeedback_file_import_summary implements renderable {
* Constructor for this renderable class
*
* @param int $cmid - The course module id for navigation
* @param int $userswithnewfeedbac - The number of users with new feedback
* @param int $userswithnewfeedback - The number of users with new feedback
* @param int $feedbackfilesadded - The number of feedback files added
* @param int $feedbackfilesupdated - The number of feedback files updated
*/

View File

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once ($CFG->libdir.'/formslib.php');
require_once($CFG->libdir.'/formslib.php');
/**
* Upload feedback zip
@ -37,7 +37,7 @@ class assignfeedback_file_upload_zip_form extends moodleform {
/**
* Define this form - called by the parent constructor
*/
function definition() {
public function definition() {
global $COURSE, $USER;
$mform = $this->_form;

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -28,7 +27,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot.'/mod/assign/feedback/offline/importgradeslib.php');
/*
/**
* Import grades form
*
* @package assignfeedback_offline
@ -40,7 +39,7 @@ class assignfeedback_offline_import_grades_form extends moodleform implements re
/**
* Create this grade import form
*/
function definition() {
public function definition() {
global $CFG, $PAGE, $DB;
$mform = $this->_form;

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -25,7 +24,7 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
/*
/**
* CSV Grade importer
*
* @package assignfeedback_offline
@ -34,7 +33,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
*/
class assignfeedback_offline_grade_importer {
/** var string $importid - unique id for this import operation - must be passed between requests */
/** @var string $importid - unique id for this import operation - must be passed between requests */
public $importid;
/** @var csv_import_reader $csvreader - the csv importer class */
@ -61,9 +60,10 @@ class assignfeedback_offline_grade_importer {
/**
* Constructor
*
* @param string importid
* @param string $importid A unique id for this import
* @param assign $assignment The current assignment
*/
function __construct($importid, assign $assignment) {
public function __construct($importid, assign $assignment) {
$this->importid = $importid;
$this->assignment = $assignment;
}
@ -72,9 +72,10 @@ class assignfeedback_offline_grade_importer {
* Parse a csv file and save the content to a temp file
* Should be called before init()
*
* @param string $csvdata The csv data
* @return bool false is a failed import
*/
function parsecsv($csvdata) {
public function parsecsv($csvdata) {
$this->csvreader = new csv_import_reader($this->importid, 'assignfeedback_offline');
$this->csvreader->load_csv_content($csvdata, 'utf-8', 'comma');
}
@ -84,7 +85,7 @@ class assignfeedback_offline_grade_importer {
*
* @return bool false is a failed import
*/
function init() {
public function init() {
if ($this->csvreader == null) {
$this->csvreader = new csv_import_reader($this->importid, 'assignfeedback_offline');
}
@ -142,10 +143,9 @@ class assignfeedback_offline_grade_importer {
/**
* Get the next row of data from the csv file (only the columns we care about)
*
* @global moodle_database $DB
* @return stdClass or false The stdClass is an object containing user, grade and lastmodified
*/
function next() {
public function next() {
global $DB;
$result = new stdClass();
@ -178,7 +178,7 @@ class assignfeedback_offline_grade_importer {
*
* @param bool $delete
*/
function close($delete) {
public function close($delete) {
$this->csvreader->close();
if ($delete) {
$this->csvreader->cleanup();

View File

@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'feedback_file', language 'en'
* Strings for component 'feedback_offline', language 'en'
*
* @package assignfeedback_file
* @package assignfeedback_offline
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -37,7 +37,7 @@ $string['ignoremodified_help'] = 'When the grading worksheet is downloaded from
$string['importgrades'] = 'Confirm changes in grading worksheet';
$string['invalidgradeimport'] = 'Moodle could not read the uploaded worksheet. Make sure it is saved in comma separated value format (.csv) and try again.';
$string['gradesfile'] = 'Grading worksheet (csv format)';
$string['gradesfile_help'] = 'Grading worksheet with modified grades. This file must be a csv file that has been downloaded form this assignment and must contain columns for the student grade, and identifier.';
$string['gradesfile_help'] = 'Grading worksheet with modified grades. This file must be a csv file that has been downloaded from this assignment and must contain columns for the student grade, and identifier. The encoding for the file must be &quot;UTF-8&quot;';
$string['nochanges'] = 'No modified grades found in uploaded worksheet';
$string['offlinegradingworksheet'] = 'Grades';
$string['pluginname'] = 'Offline grading worksheet';

View File

@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/grade/grading/lib.php');
/**
* library class for file feedback plugin extending feedback plugin base class
*
* @package asignfeedback_offline
* @package assignfeedback_offline
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -69,6 +69,7 @@ class assign_feedback_offline extends assign_feedback_plugin {
*
* @param int $draftid - The unique draft item id for this import
* @param int $importid - The unique import ID for this csv import operation
* @param bool $ignoremodified - Ignore the last modified date when checking fields
* @return string - The html response
*/
public function process_import_grades($draftid, $importid, $ignoremodified) {
@ -324,7 +325,7 @@ class assign_feedback_offline extends assign_feedback_plugin {
$this->assignment->get_course()->shortname . '-' .
$this->assignment->get_instance()->name . '-' .
$groupname .
$this->assignment->get_course_module()->id); //name of new zip file.
$this->assignment->get_course_module()->id);
$table = new assign_grading_table($this->assignment, 0, '', 0, false, $filename);

View File

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once ($CFG->libdir.'/formslib.php');
require_once($CFG->libdir.'/formslib.php');
/**
* Upload modified grading worksheet
@ -37,7 +37,7 @@ class assignfeedback_offline_upload_grades_form extends moodleform {
/**
* Define this form - called by the parent constructor
*/
function definition() {
public function definition() {
global $COURSE, $USER;
$mform = $this->_form;

View File

@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the version information for the comments feedback plugin
* This file contains the version information for the offline feedback plugin
*
* @package assignfeedback_file
* @package assignfeedback_offline
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -145,15 +145,18 @@ abstract class assign_feedback_plugin extends assign_plugin {
/**
* Show a grading action form
*
* @param string $gradingaction The action chosen from the grading actions menu
* @return string The page containing the form
*/
public function grading_action($action) {
public function grading_action($gradingaction) {
return '';
}
/**
* Show a batch operations form
*
* @param string $action The action chosen from the batch operations menu
* @param array $users The list of selected userids
* @return string The page containing the form
*/
public function grading_batch_operation($action, $users) {

View File

@ -72,7 +72,7 @@ class assign_grading_table extends table_sql implements renderable {
* @param int $rowoffset For showing a subsequent page of results
* @param bool $quickgrading Is this table wrapped in a quickgrading form?
*/
function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading, $downloadfilename = null) {
public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading, $downloadfilename = null) {
global $CFG, $PAGE, $DB;
parent::__construct('mod_assign_grading');
$this->assignment = $assignment;
@ -339,7 +339,7 @@ class assign_grading_table extends table_sql implements renderable {
* @param stdClass $row - The row of data
* @return string A list of valid options for the current scale
*/
function col_scale($row) {
public function col_scale($row) {
global $DB;
if (empty($this->scale)) {
@ -535,8 +535,8 @@ class assign_grading_table extends table_sql implements renderable {
* @param stdClass $row
* @return string
*/
function col_grademax(stdClass $row) {
return format_float($this->assignment->get_instance()->grade,2);
public function col_grademax(stdClass $row) {
return format_float($this->assignment->get_instance()->grade, 2);
}
/**

View File

@ -423,7 +423,7 @@ class assign {
$o .= $this->view_reveal_identities_confirm($mform);
} else if ($action == 'plugingradingbatchoperation') {
$o .= $this->view_plugin_grading_batch_operation($mform);
} else if ($action == 'viewpluginpage') {
} else if ($action == 'viewpluginpage') {
$o .= $this->view_plugin_page();
} else {
$o .= $this->view_submission_page();
@ -1807,7 +1807,7 @@ class assign {
foreach ($students as $student) {
$userid = $student->id;
if ((groups_is_member($groupid,$userid) or !$groupmode or !$groupid)) {
if ((groups_is_member($groupid, $userid) or !$groupmode or !$groupid)) {
// Get the plugins to add their own files to the zip.
$submissiongroup = false;
@ -1833,7 +1833,9 @@ class assign {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$pluginfiles = $plugin->get_files($submission);
foreach ($pluginfiles as $zipfilename => $file) {
$prefixedfilename = $prefix . $plugin->get_subtype() . '_' . $plugin->get_type() . '_' . $zipfilename;
$subtype = $plugin->get_subtype();
$type = $plugin->get_type();
$prefixedfilename = $prefix . $subtype . '_' . $type . '_' . $zipfilename;
$filesforzipping[$prefixedfilename] = $file;
}
}
@ -2431,9 +2433,9 @@ class assign {
print_error('invalidformdata', '');
}
/**
* Ask the user to confirm they want to perform this batch operation
* @param moodleform $mform Set to a grading batch operations form
* @return string - the page to view after processing these actions
*/
private function process_grading_batch_operation(& $mform) {
@ -4415,6 +4417,7 @@ class assign {
/**
* Lookup this unique id and return the user id for this assignment
*
* @param int $assignid The id of the assignment this user mapping is in
* @param int $uniqueid The uniqueid to lookup
* @return int The user id or false if they don't exist
*/