Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
H5P activity manager class
Copyright: | 2020 Ferran Recio <ferran@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 571 lines (20 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
manager:: (21 methods):
__construct()
create_from_instance()
create_from_coursemodule()
get_grading_methods()
get_selected_attempt()
get_review_modes()
is_tracking_enabled()
can_view_all_attempts()
can_view_own_attempts()
get_users_scaled_score()
count_attempts()
get_active_users_join()
count_users_attempts()
get_context()
get_instance()
get_coursemodule()
get_grader()
get_report()
get_attempt()
get_user_attempts()
set_module_viewed()
__construct(cm_info $coursemodule, stdClass $instance) X-Ref |
Class contructor. param: cm_info $coursemodule course module info object param: stdClass $instance H5Pactivity instance object. |
create_from_instance(stdClass $instance) X-Ref |
Create a manager instance from an instance record. param: stdClass $instance a h5pactivity record return: manager |
create_from_coursemodule($coursemodule) X-Ref |
Create a manager instance from an course_modules record. param: stdClass|cm_info $coursemodule a h5pactivity record return: manager |
get_grading_methods() X-Ref |
Return the available grading methods. return: string[] an array "option value" => "option description" |
get_selected_attempt() X-Ref |
Return the selected attempt criteria. return: string[] an array "grademethod value", "attempt description" |
get_review_modes() X-Ref |
Return the available review modes. return: string[] an array "option value" => "option description" |
is_tracking_enabled(stdClass $user = null) X-Ref |
Check if tracking is enabled in a particular h5pactivity for a specific user. param: stdClass|null $user user record (default $USER) return: bool if tracking is enabled in this activity |
can_view_all_attempts(stdClass $user = null) X-Ref |
Check if a user can see the activity attempts list. param: stdClass|null $user user record (default $USER) return: bool if the user can see the attempts link |
can_view_own_attempts(stdClass $user = null) X-Ref |
Check if a user can see own attempts. param: stdClass|null $user user record (default $USER) return: bool if the user can see the own attempts link |
get_users_scaled_score(int $userid = 0) X-Ref |
Return a relation of userid and the valid attempt's scaled score. The returned elements contain a record of userid, scaled value, attemptid and timemodified. In case the grading method is "GRADEAVERAGEATTEMPT" the attemptid will be zero. In case that tracking is disabled or grading method is "GRADEMANUAL" the method will return null. param: int $userid a specific userid or 0 for all user attempts. return: array|null of userid, scaled value and, if exists, the attempt id |
count_attempts(int $userid = null) X-Ref |
Count the activity completed attempts. If no user is provided the method will count all active users attempts. Check get_active_users_join PHPdoc to a more detailed description of "active users". param: int|null $userid optional user id (default null) return: int the total amount of attempts |
get_active_users_join(bool $allpotentialusers = false, $currentgroup = false) X-Ref |
Return the join to collect all activity active users. The concept of active user is relative to the activity permissions. All users with "mod/h5pactivity:view" are potential users but those with "mod/h5pactivity:reviewattempts" are evaluators and they don't count as valid submitters. Note that, in general, the active list has the same effect as checking for "mod/h5pactivity:submit" but submit capability cannot be used because is a write capability and does not apply to frozen contexts. param: bool $allpotentialusers if true, the join will return all active users, not only the ones with attempts. param: int|bool $currentgroup False if groups not used, 0 for all groups, group id (int) to filter by specific group return: sql_join the active users attempts join |
count_users_attempts() X-Ref |
Return an array of all users and it's total attempts. Note: this funciton only returns the list of users with attempts, it does not check all participants. return: array indexed count userid => total number of attempts |
get_context() X-Ref |
Return the current context. return: context_module |
get_instance() X-Ref |
Return the current instance. return: stdClass the instance record |
get_coursemodule() X-Ref |
Return the current cm_info. return: cm_info the course module |
get_grader() X-Ref |
Return the specific grader object for this activity. return: grader |
get_report(int $userid = null, int $attemptid = null, $currentgroup = false) X-Ref |
Return the suitable report to show the attempts. This method controls the access to the different reports the activity have. param: int $userid an opional userid to show param: int $attemptid an optional $attemptid to show param: int|bool $currentgroup False if groups not used, 0 for all groups, group id (int) to filter by specific group return: report|null available report (or null if no report available) |
get_attempt(int $attemptid) X-Ref |
Return a single attempt. param: int $attemptid the attempt id return: attempt |
get_user_attempts(int $userid) X-Ref |
Return an array of all user attempts (including incompleted) param: int $userid the user id return: attempt[] |
set_module_viewed(stdClass $course) X-Ref |
Trigger module viewed event and set the module viewed for completion. param: stdClass $course course object return: void |