MDL-30995 Completion Fixedup some more PHP DOC issues

This commit is contained in:
Ankit Agarwal
2012-03-12 16:13:35 +08:00
parent 836375ec8a
commit 95dd54eea3
14 changed files with 122 additions and 244 deletions
+6 -21
View File
@@ -39,10 +39,7 @@ require_once($CFG->libdir.'/completion/data_object.php');
*/
class completion_aggregation extends data_object {
/**
* Database table name that stores completion aggregation information
* @var string
*/
/* @var string Database table name that stores completion aggregation information */
public $table = 'course_completion_aggr_methd';
/**
@@ -52,28 +49,16 @@ class completion_aggregation extends data_object {
*/
public $required_fields = array('id', 'course', 'criteriatype', 'method', 'value');
/**
* Course id
* @var int
*/
/* @var int Course id */
public $course;
/**
* Criteria type this aggregation method applies to, or NULL for overall course aggregation
* @var int
*/
/* @var int Criteria type this aggregation method applies to, or NULL for overall course aggregation */
public $criteriatype;
/**
* Aggregation method (COMPLETION_AGGREGATION_* constant)
* @var int
*/
/* @var int Aggregation method (COMPLETION_AGGREGATION_* constant)*/
public $method;
/**
* Method value
* @var mixed
*/
/* @var mixed Method value */
public $value;
@@ -113,4 +98,4 @@ class completion_aggregation extends data_object {
$this->method = COMPLETION_AGGREGATION_ALL;
}
}
}
}
+12 -39
View File
@@ -38,47 +38,26 @@ require_once($CFG->libdir.'/completion/data_object.php');
*/
class completion_completion extends data_object {
/**
* Database table name that stores completion information
* @var string $table
*/
/* @var string $table Database table name that stores completion information */
public $table = 'course_completions';
/**
* Array of required table fields, must start with 'id'.
* @var array $required_fields
*/
/* @var array $required_fields Array of required table fields, must start with 'id'. */
public $required_fields = array('id', 'userid', 'course', 'deleted', 'timenotified',
'timeenrolled', 'timestarted', 'timecompleted', 'reaggregate');
/**
* User ID
* @var int
*/
/* @var int $userid User ID */
public $userid;
/**
* Course ID
* @var int
*/
/* @var int $course Course ID */
public $course;
/**
* Set to 1 if this record has been deleted
* @var int
*/
/* @var int $deleted set to 1 if this record has been deleted */
public $deleted;
/**
* Timestamp the interested parties were notified of this user's completion.
* @var int
*/
/* @var int Timestamp the interested parties were notified of this user's completion. */
public $timenotified;
/**
* Time of course enrolment {@see completion_completion::mark_enrolled()}
* @var int
*/
/* @var int Time of course enrolment {@see completion_completion::mark_enrolled()} */
public $timeenrolled;
/**
@@ -87,22 +66,16 @@ class completion_completion extends data_object {
*/
public $timestarted;
/**
* Timestamp of course completion {@see completion_completion::mark_complete()}
* @var int
*/
/* @var int Timestamp of course completion {@see completion_completion::mark_complete()} */
public $timecompleted;
/**
* Flag to trigger cron aggregation (timestamp)
* @var int
*/
/* @var int Flag to trigger cron aggregation (timestamp) */
public $reaggregate;
/**
* Finds and returns a data_object instance based on params.
*
*
* @param array $params associative arrays varname = >value
* @return data_object instance of data_object or false if none found.
*/
@@ -114,7 +87,7 @@ class completion_completion extends data_object {
/**
* Return status of this completion
*
* @return boolean
* @return bool
*/
public function is_complete() {
return (bool) $this->timecompleted;
@@ -224,4 +197,4 @@ class completion_completion extends data_object {
$this->insert();
}
}
}
}
+9 -27
View File
@@ -103,10 +103,7 @@ $COMPLETION_CRITERIA_TYPES = array(
*/
abstract class completion_criteria extends data_object {
/**
* Database table name that stores completion criteria information
* @var string
*/
/* @var string Database table name that stores completion criteria information */
public $table = 'course_completion_criteria';
/**
@@ -117,10 +114,7 @@ abstract class completion_criteria extends data_object {
*/
public $required_fields = array('id', 'course', 'criteriatype', 'module', 'moduleinstance', 'courseinstance', 'enrolperiod', 'timeend', 'gradepass', 'role');
/**
* Course id
* @var int
*/
/* @var int Course id */
public $course;
/**
@@ -130,16 +124,10 @@ abstract class completion_criteria extends data_object {
*/
public $criteriatype;
/**
* Module type this criteria relates to (for activity criteria)
* @var string
*/
/* @var string Module type this criteria relates to (for activity criteria) */
public $module;
/**
* Course module instance id this criteria relates to (for activity criteria)
* @var int
*/
/* @var int Course module instance id this criteria relates to (for activity criteria) */
public $moduleinstance;
/**
@@ -156,16 +144,10 @@ abstract class completion_criteria extends data_object {
*/
public $date;
/**
* Passing grade required to complete course (for grade completion)
* @var float
*/
/* @var float Passing grade required to complete course (for grade completion) */
public $gradepass;
/**
* Role ID that has the ability to mark a user as complete (for role completion)
* @var int
*/
/* @var int Role ID that has the ability to mark a user as complete (for role completion) */
public $role;
/**
@@ -197,9 +179,9 @@ abstract class completion_criteria extends data_object {
/**
* Add appropriate form elements to the critieria form
*
*
* @param moodleform $mform Moodle forms object
* @param mixed $data optional
* @param mixed $data optional Any additional data that can be used to set default values in the form
* @return void
*/
abstract public function config_form_display(&$mform, $data = null);
@@ -272,4 +254,4 @@ abstract class completion_criteria extends data_object {
return $review !== $completion->is_complete();
}
}
}
+10 -13
View File
@@ -39,10 +39,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_activity extends completion_criteria {
/**
* Criteria type constant
* @var int [COMPLETION_CRITERIA_TYPE_ACTIVITY]
*/
/* @var int Criteria [COMPLETION_CRITERIA_TYPE_ACTIVITY] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_ACTIVITY;
/**
@@ -58,9 +55,9 @@ class completion_criteria_activity extends completion_criteria {
/**
* Add appropriate form elements to the critieria form
*
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data details of various modules
*/
public function config_form_display(&$mform, $data = null) {
$mform->addElement('checkbox', 'criteria_activity['.$data->id.']', ucfirst(self::get_mod_name($data->module)).' - '.$data->name);
@@ -72,7 +69,7 @@ class completion_criteria_activity extends completion_criteria {
/**
* Update the criteria information stored in the database
*
*
* @param stdClass $data Form data
*/
public function update_config(&$data) {
@@ -95,7 +92,7 @@ class completion_criteria_activity extends completion_criteria {
/**
* Get module instance module type
*
*
* @param int $type Module type id
* @return string
*/
@@ -114,7 +111,7 @@ class completion_criteria_activity extends completion_criteria {
* Gets the module instance from the database and returns it.
* If no module instance exists this function returns false.
*
* @return stdClass|false
* @return stdClass|bool
*/
public function get_mod_instance() {
global $DB;
@@ -137,8 +134,8 @@ class completion_criteria_activity extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @return bool
*/
public function review($completion, $mark = true) {
global $DB;
@@ -193,7 +190,7 @@ class completion_criteria_activity extends completion_criteria {
}
/**
* Find user's who have completed this criteria and mark them accordingly
* Find users who have completed this criteria and mark them accordingly
*/
public function cron() {
global $DB;
@@ -290,4 +287,4 @@ class completion_criteria_activity extends completion_criteria {
return $details;
}
}\
}
@@ -38,70 +38,37 @@ require_once($CFG->libdir.'/completion/data_object.php');
*/
class completion_criteria_completion extends data_object {
/**
* Database table that stores completion type criteria
* @var string
*/
/* @var string Database table that stores completion type criteria */
public $table = 'course_completion_crit_compl';
/**
* Array of required table fields, must start with 'id'.
* @var array
*/
/* @var array Array of required table fields, must start with 'id'. */
public $required_fields = array('id', 'userid', 'course', 'criteriaid', 'gradefinal', 'rpl', 'deleted', 'unenroled', 'timecompleted');
/**
* User ID
* @var int
*/
/* @var int User ID */
public $userid;
/**
* Course ID
* @var int
*/
/* @var int course ID */
public $course;
/**
* The id of the course completion criteria this completion references
* @var int
*/
/* @var int The id of the course completion criteria this completion references */
public $criteriaid;
/**
* The final grade for the user in the course (if completing a grade criteria)
* @var float
*/
/* @var float The final grade for the user in the course (if completing a grade criteria) */
public $gradefinal;
/**
* Record of prior learning, leave blank if none
* @var string
*/
/* @var string Record of prior learning, leave blank if none */
public $rpl;
/**
* Course deleted flag
* @var boolean
*/
/* @var bool Course deleted flag */
public $deleted;
/**
* Timestamp of user unenrolment (if completing a unenrol criteria)
* @var int
*/
/* @var int Timestamp of user unenrolment (if completing a unenrol criteria) */
public $unenroled;
/**
* Timestamp of course criteria completion {@see completion_criteria_completion::mark_complete()}
* @var int
*/
/* @var int Timestamp of course criteria completion {@see completion_criteria_completion::mark_complete()} */
public $timecompleted;
/**
* Associated criteria object
* @var completion_criteria
*/
/* @var completion_criterria Associated criteria object */
private $_criteria;
/**
@@ -125,7 +92,8 @@ class completion_criteria_completion extends data_object {
/**
* Return status of this criteria completion
* @return boolean
*
* @return bool
*/
public function is_complete() {
return (bool) $this->timecompleted;
@@ -158,7 +126,7 @@ class completion_criteria_completion extends data_object {
/**
* Attach a preloaded criteria object to this object
*
*
* @param $criteria object completion_criteria
*/
public function attach_criteria(completion_criteria $criteria) {
@@ -168,12 +136,13 @@ class completion_criteria_completion extends data_object {
/**
* Return the associated criteria with this completion
* If nothing attached, load from the db
*
*
* @return completion_criteria
*/
public function get_criteria() {
if (!$this->_criteria) {
if (!$this->_criteria)
{
global $DB;
$params = array(
@@ -190,6 +159,7 @@ class completion_criteria_completion extends data_object {
/**
* Return criteria status text for display in reports {@see completion_criteria::get_status()}
*
* @return string
*/
public function get_status() {
@@ -40,10 +40,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_course extends completion_criteria {
/**
* Criteria type constant
* @var int
*/
/* @var int Criteria type constant */
public $criteriatype = COMPLETION_CRITERIA_TYPE_COURSE;
/**
@@ -61,7 +58,7 @@ class completion_criteria_course extends completion_criteria {
* Add appropriate form elements to the critieria form
*
* @param moodle_form $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data data used to define default value of the form
*/
public function config_form_display(&$mform, $data = null) {
global $CFG;
@@ -98,8 +95,8 @@ class completion_criteria_course extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @return bool
*/
public function review($completion, $mark = true) {
global $DB;
@@ -131,7 +128,7 @@ class completion_criteria_course extends completion_criteria {
/**
* Return a more detailed criteria title for display in reports
*
*
* @return string
*/
public function get_title_detailed() {
+5 -8
View File
@@ -37,10 +37,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_date extends completion_criteria {
/**
* Criteria type constant [COMPLETION_CRITERIA_TYPE_DATE]
* @var int
*/
/* @var int Criteria type constant [COMPLETION_CRITERIA_TYPE_DATE] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_DATE;
/**
@@ -58,7 +55,7 @@ class completion_criteria_date extends completion_criteria {
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data not used
*/
public function config_form_display(&$mform, $data = null) {
$mform->addElement('checkbox', 'criteria_date', get_string('enable'));
@@ -88,10 +85,10 @@ class completion_criteria_date extends completion_criteria {
/**
* Review this criteria and decide if the user has completed
*
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @return bool
*/
public function review($completion, $mark = true) {
// If current time is past timeend
@@ -37,10 +37,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_duration extends completion_criteria {
/**
* Criteria type constant [COMPLETION_CRITERIA_TYPE_DURATION]
* @var int
*/
/* @var int Criteria type constant [COMPLETION_CRITERIA_TYPE_DURATION] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_DURATION;
/**
@@ -58,7 +55,7 @@ class completion_criteria_duration extends completion_criteria {
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data not used
*/
public function config_form_display(&$mform, $data = null) {
@@ -111,8 +108,8 @@ class completion_criteria_duration extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @return bool
*/
public function review($completion, $mark = true) {
$timeenrolled = $this->get_timeenrolled($completion);
@@ -265,4 +262,4 @@ class completion_criteria_duration extends completion_criteria {
return $details;
}
}
}
+13 -12
View File
@@ -39,16 +39,14 @@ require_once $CFG->dirroot.'/grade/querylib.php';
*/
class completion_criteria_grade extends completion_criteria {
/**
* Criteria type constant [COMPLETION_CRITERIA_TYPE_GRADE]
* @var int
*/
/* @var int Criteria type constant [COMPLETION_CRITERIA_TYPE_GRADE] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_GRADE;
/**
* Finds and returns a data_object instance based on params.
*
* @param array $params associative arrays varname => value
* @param array $params associative array varname => value of various
* parameters used to fetch data_object
* @return data_object data_object instance or false if none found.
*/
public static function fetch($params) {
@@ -60,7 +58,7 @@ class completion_criteria_grade extends completion_criteria {
* Add appropriate form elements to the critieria form
*
* @param moodle_form $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data containing default values to be set in the form
*/
public function config_form_display(&$mform, $data = null) {
$mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
@@ -79,7 +77,10 @@ class completion_criteria_grade extends completion_criteria {
* @param stdClass $data Form data
*/
public function update_config(&$data) {
if (!empty($data->criteria_grade) && is_numeric($data->criteria_grade_value)) {
// TODO validation
if (!empty($data->criteria_grade) && is_numeric($data->criteria_grade_value))
{
$this->course = $data->id;
$this->gradepass = $data->criteria_grade_value;
$this->insert();
@@ -88,8 +89,8 @@ class completion_criteria_grade extends completion_criteria {
/**
* Get user's course grade in this course
*
* @param completion_completion $completion
*
* @param completion_completion $completion an instance of completion_completion class
* @return float
*/
private function get_grade($completion) {
@@ -101,8 +102,8 @@ class completion_criteria_grade extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @return bool
*/
public function review($completion, $mark = true) {
// Get user's course grade
@@ -241,4 +242,4 @@ class completion_criteria_grade extends completion_criteria {
return $details;
}
}
}
+14 -12
View File
@@ -37,10 +37,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_role extends completion_criteria {
/**
* Criteria type constant [COMPLETION_CRITERIA_TYPE_ROLE]
* @var int
*/
/* @var int Criteria type constant [COMPLETION_CRITERIA_TYPE_ROLE] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_ROLE;
/**
@@ -56,9 +53,9 @@ class completion_criteria_role extends completion_criteria {
/**
* Add appropriate form elements to the critieria form
*
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data used to set default values of the form
*/
public function config_form_display(&$mform, $data = null) {
@@ -75,9 +72,13 @@ class completion_criteria_role extends completion_criteria {
* @param stdClass $data Form data
*/
public function update_config(&$data) {
if (!empty($data->criteria_role) && is_array($data->criteria_role)) {
$this->course = $data->id;
foreach (array_keys($data->criteria_role) as $role) {
$this->role = $role;
$this->id = NULL;
$this->insert();
@@ -98,13 +99,14 @@ class completion_criteria_role extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @param boolean $is_complete Set to false if the criteria has been completed just now.
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @param bool $is_complete Set to false if the criteria has been completed just now.
* @return bool
*/
public function review($completion, $mark = true, $is_complete = false) {
// If we are marking this as complete
if ($is_complete && $mark) {
if ($is_complete && $mark)
{
$completion->completedself = 1;
$completion->mark_complete();
@@ -127,7 +129,7 @@ class completion_criteria_role extends completion_criteria {
/**
* Return a more detailed criteria title for display in reports
*
*
* @return string
*/
public function get_title_detailed() {
@@ -160,4 +162,4 @@ class completion_criteria_role extends completion_criteria {
return $details;
}
}
}
+6 -8
View File
@@ -37,10 +37,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_self extends completion_criteria {
/**
* Criteria type constant [COMPLETION_CRITERIA_TYPE_SELF]
* @var int
*/
/* @var int Criteria type constant [COMPLETION_CRITERIA_TYPE_SELF] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_SELF;
/**
@@ -58,7 +55,7 @@ class completion_criteria_self extends completion_criteria {
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data Form data
*/
public function config_form_display(&$mform, $data = null) {
$mform->addElement('checkbox', 'criteria_self', get_string('enable'));
@@ -93,8 +90,9 @@ class completion_criteria_self extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @param bool $is_complete set true to mark activity complete.
* @return bool
*/
public function review($completion, $mark = true, $is_complete = false) {
// If we are marking this as complete
@@ -151,4 +149,4 @@ class completion_criteria_self extends completion_criteria {
return $details;
}
}
}
@@ -37,10 +37,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class completion_criteria_unenrol extends completion_criteria {
/**
* Criteria type constant [COMPLETION_CRITERIA_TYPE_UNENROL]
* @var int
*/
/* @var int Criteria type constant [COMPLETION_CRITERIA_TYPE_UNENROL] */
public $criteriatype = COMPLETION_CRITERIA_TYPE_UNENROL;
/**
@@ -58,7 +55,7 @@ class completion_criteria_unenrol extends completion_criteria {
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data
* @param stdClass $data Form data
*/
public function config_form_display(&$mform, $data = null) {
$mform->addElement('checkbox', 'criteria_unenrol', get_string('completiononunenrolment','completion'));
@@ -84,8 +81,8 @@ class completion_criteria_unenrol extends completion_criteria {
* Review this criteria and decide if the user has completed
*
* @param completion_completion $completion The user's completion record
* @param boolean $mark Optionally set false to not save changes to database
* @return boolean
* @param bool $mark Optionally set false to not save changes to database
* @return bool
*/
public function review($completion, $mark = true) {
// Check enrolment
@@ -134,4 +131,4 @@ class completion_criteria_unenrol extends completion_criteria {
$details['status'] = '';
return $details;
}
}
}
+6 -15
View File
@@ -37,16 +37,10 @@ defined('MOODLE_INTERNAL') || die();
*/
abstract class data_object {
/**
* Table that the class maps to in the database
* @var string
*/
/* @var string Table that the class maps to in the database */
public $table;
/**
* Array of required table fields, must start with 'id'.
* @var array
*/
/* @var array Array of required table fields, must start with 'id'. */
public $required_fields = array('id');
/**
@@ -56,10 +50,7 @@ abstract class data_object {
*/
public $optional_fields = array();
/**
* The primary key
* @var int $id
*/
/* @var int The primary key */
public $id;
/**
@@ -210,7 +201,7 @@ abstract class data_object {
/**
* Updates this object in the Database, based on its object variables. ID must be set.
*
* @return boolean success
* @return bool success
*/
public function update() {
global $DB;
@@ -231,7 +222,7 @@ abstract class data_object {
/**
* Deletes this object from the database.
*
* @return boolean success
* @return bool success
*/
public function delete() {
global $DB;
@@ -346,5 +337,5 @@ abstract class data_object {
*
* @param bool $deleted Set this to true if it has been deleted.
*/
function notify_changed($deleted) {}
public function notify_changed($deleted) {}
}
+8 -17
View File
@@ -98,7 +98,7 @@ define('COMPLETION_UNKNOWN', -1);
define('COMPLETION_GRADECHANGE', -2);
/**
* User must view this activit.
* User must view this activity.
* Whether view is required to create an activity (course_modules/completionview)
*/
define('COMPLETION_VIEW_REQUIRED', 1);
@@ -159,22 +159,13 @@ define('COMPLETION_AGGREGATION_ANY', 2);
*/
class completion_info {
/**
* Course object passed during construction
* @var stdClass
*/
/* @var stdClass Course object passed during construction */
private $course;
/**
* Course id
* @var int
*/
/* @var int Course id */
public $course_id;
/**
* Completion criteria {@see completion_info::get_criteria()}
* @var array
*/
/* @var array Completion criteria {@see completion_info::get_criteria()} */
private $criteria;
/**
@@ -280,7 +271,7 @@ class completion_info {
*
* @param int $user_id User id
* @param int $criteriatype Specific criteria type to return
* @return false|completion_criteria_completion
* @return bool|completion_criteria_completion returns false on fail
*/
public function get_completion($user_id, $criteriatype) {
$completions = $this->get_completions($user_id, $criteriatype);
@@ -537,7 +528,7 @@ class completion_info {
* Calculates the completion state for an activity and user.
*
* Internal function. Not private, so we can unit-test it.
*
*
* @param stdClass|cm_info $cm Activity
* @param int $userid ID of user
* @param stdClass $current Previous completion information from database
@@ -1272,8 +1263,8 @@ class completion_info {
*
* Internal function. Not private, so we can unit-test it.
*
* @param grade_item $item
* @param grade_grade $grade
* @param grade_item $item an instance of grade_item
* @param grade_grade $grade an instance of grade_grade
* @return int Completion state e.g. COMPLETION_INCOMPLETE
*/
public function internal_get_grade_state($item, $grade) {