Skip to content

Commit

Permalink
Move extra requires into locallib.php to make it easier to extend.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Nov 14, 2023
1 parent 5255582 commit 7648d76
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
5 changes: 0 additions & 5 deletions classes/task/check_recompletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ public function get_user_courses_to_reset() {
*/
public function execute() {
global $CFG, $DB;
require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->dirroot . '/local/recompletion/locallib.php');
require_once($CFG->libdir . '/completionlib.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/lib.php');

if (!\completion_info::is_enabled_for_site()) {
return;
Expand Down
7 changes: 0 additions & 7 deletions editcompletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@
*/

require_once('../../config.php');
require_once($CFG->dirroot.'/user/lib.php');
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot.'/local/recompletion/locallib.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/lib.php');

$courseid = required_param('id', PARAM_INT);
$userid = optional_param('user', 0, PARAM_INT);
Expand Down
10 changes: 10 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

// Used by settings to decide if attempts should be deleted or an extra attempt allowed.
define('LOCAL_RECOMPLETION_NOTHING', 0);
define('LOCAL_RECOMPLETION_DELETE', 1);
define('LOCAL_RECOMPLETION_EXTRAATTEMPT', 2);

require_once($CFG->dirroot.'/user/lib.php');
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/lib.php');

/**
* Get list of supported plugin classes.
* @return array
Expand Down
5 changes: 0 additions & 5 deletions resetcompletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

require_once(__DIR__.'/../../config.php');
require_once($CFG->dirroot.'/local/recompletion/locallib.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/lib.php');

$id = required_param('id', PARAM_INT); // Course id.
$confirm = optional_param('confirm', '', PARAM_INT);
Expand Down

0 comments on commit 7648d76

Please sign in to comment.