MDL-58138 completion: Assorted linting fixes.

Part of MDL-58138 epic
This commit is contained in:
Jake Dallimore 2017-03-21 15:09:56 +08:00
parent 8db355c58f
commit b17ee68202
8 changed files with 68 additions and 39 deletions

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
@ -32,6 +31,7 @@ use cm_info;
use tabobject;
use lang_string;
use moodle_url;
defined('MOODLE_INTERNAL') || die;
/**
* Bulk activity completion manager class
@ -43,8 +43,15 @@ use moodle_url;
*/
class manager {
/**
* @var int $courseid the course id.
*/
protected $courseid;
/**
* manager constructor.
* @param int $courseid the course id.
*/
public function __construct($courseid) {
$this->courseid = $courseid;
}
@ -185,6 +192,11 @@ class manager {
return $activeruledescriptions;
}
/**
* Gets the course modules for the current course.
*
* @return stdClass $data containing the modules
*/
public function get_activities_and_resources() {
global $DB, $OUTPUT, $CFG;
require_once($CFG->dirroot.'/course/lib.php');
@ -238,7 +250,9 @@ class manager {
}
/**
* @param stdClass|int $courseorid
* Gets the available completion tabs for the current course and user.
*
* @param stdClass|int $courseorid the course object or id.
* @return tabobject[]
*/
public static function get_available_completion_tabs($courseorid) {

View file

@ -173,37 +173,42 @@ class core_completion_bulk_update_testcase extends advanced_testcase {
*/
public function bulk_form_submit_multiple_provider() {
return [
'Several modules with the same module type (choice)' =>
[['modulenames' => ['choice', 'choice', 'choice'],
'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1],
'validatedata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1],
'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC],
'instancedata' => [
['completionsubmit' => 1],
['completionsubmit' => 1],
['completionsubmit' => 1],
]]],
'Several modules with different module type' =>
[['modulenames' => ['choice', 'forum'],
'Several modules with the same module type (choice)' => [
[
'modulenames' => ['choice', 'choice', 'choice'],
'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1],
'validatedata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1],
'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC],
'instancedata' => [['completionsubmit' => 1], ['completionsubmit' => 1], ['completionsubmit' => 1]]
]
],
'Several modules with different module type' => [
[
'modulenames' => ['choice', 'forum'],
'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1],
'validatedata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1],
'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC],
'instancedata' => null]],
'Setting manual completion (completionview shoud be ignored)' =>
[['modulenames' => ['scorm', 'forum', 'label', 'assign'],
'instancedata' => null
]
],
'Setting manual completion (completionview shoud be ignored)' => [
[
'modulenames' => ['scorm', 'forum', 'label', 'assign'],
'submitdata' => ['completion' => COMPLETION_TRACKING_MANUAL, 'completionview' => 1],
'validatedata' => [],
'cmdata' => ['completion' => COMPLETION_TRACKING_MANUAL, 'completionview' => 0],
'instancedata' => null]],
'If at least one module does not support completionsubmit it can\'t be set' =>
[['modulenames' => ['survey', 'wiki'],
'instancedata' => null
]
],
'If at least one module does not support completionsubmit it can\'t be set' => [
[
'modulenames' => ['survey', 'wiki'],
'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1, 'completionsubmit' => 1],
'validatedata' => [],
'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1],
'instancedata' => [
['completionsubmit' => 0],
[]
]]],
'instancedata' => [['completionsubmit' => 0], []]
]
]
];
}