mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-63149 mod_survey: Add userid param to mod_survey calendar callbacks
This commit is contained in:
parent
89d1238962
commit
a44fb747cf
2 changed files with 88 additions and 4 deletions
|
@ -1112,20 +1112,28 @@ function survey_check_updates_since(cm_info $cm, $from, $filter = array()) {
|
|||
*
|
||||
* @param calendar_event $event
|
||||
* @param \core_calendar\action_factory $factory
|
||||
* @param int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).
|
||||
* @return \core_calendar\local\event\entities\action_interface|null
|
||||
*/
|
||||
function mod_survey_core_calendar_provide_event_action(calendar_event $event,
|
||||
\core_calendar\action_factory $factory) {
|
||||
$cm = get_fast_modinfo($event->courseid)->instances['survey'][$event->instance];
|
||||
\core_calendar\action_factory $factory,
|
||||
int $userid = 0) {
|
||||
global $USER;
|
||||
|
||||
if (empty($userid)) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
$cm = get_fast_modinfo($event->courseid, $userid)->instances['survey'][$event->instance];
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
if (!has_capability('mod/survey:participate', $context)) {
|
||||
if (!has_capability('mod/survey:participate', $context, $userid)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$completion = new \completion_info($cm->get_course());
|
||||
|
||||
$completiondata = $completion->get_data($cm, false);
|
||||
$completiondata = $completion->get_data($cm, false, $userid);
|
||||
|
||||
if ($completiondata->completionstate != COMPLETION_INCOMPLETE) {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue