Skip to content

Commit

Permalink
MDL-50287 completion: avoid introducing uncessary functions
Browse files Browse the repository at this point in the history
Also fix copyright
  • Loading branch information
danpoltawski committed Aug 27, 2015
1 parent 51e488e commit 0628925
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 39 deletions.
35 changes: 1 addition & 34 deletions completion/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Cron job for reviewing and aggregating course completion criteria
* Code used by scheduled tasks for reviewing and aggregating course completion criteria.
*
* @package core_completion
* @category completion
Expand All @@ -27,39 +27,6 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/completionlib.php');

/**
* Legacy - here for plugin use only, not used in scheduled tasks.
* Update user's course completion statuses
*
* First update all criteria completions, then aggregate all criteria completions
* and update overall course completions.
*/
function completion_cron() {
completion_cron_mark_started();

completion_cron_criteria();

completion_cron_completions();
}
/**
* Update user's course completion statuses
*
* First update all criteria completions, then aggregate all criteria completions
* and update overall course completions
*/
function completion_regular_cron() {
// Two Functions which check criteria and learner completions regularly for accurate data.
completion_cron_criteria();
completion_cron_completions();
}
/**
* Marks users as started if the config option is set.
*
* One function which takes a long time 60+ minutes to enrol users onto completion started.
*/
function completion_daily_cron() {
completion_cron_mark_started();
}
/**
* Mark users as started if the config option is set
*
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/task/completion_cron_daily_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function execute() {
if ($CFG->enablecompletion) {
// Daily Completion cron.
require_once($CFG->dirroot.'/completion/cron.php');
completion_daily_cron();
completion_cron_mark_started();
}
}

Expand Down
7 changes: 4 additions & 3 deletions lib/classes/task/completion_cron_regular_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
* A scheduled task.
*
* @package core
* @copyright 2013 onwards Martin Dougiamas http://dougiamas.com
* @copyright 2015 Josh Willcock
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\task;

/**
* Simple task to run the regular completion cron.
* @copyright 2013 onwards Martin Dougiamas http://dougiamas.com.
* @copyright 2015 Josh Willcock
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
class completion_cron_regular_task extends scheduled_task {
Expand All @@ -49,7 +49,8 @@ public function execute() {
if ($CFG->enablecompletion) {
// Regular Completion cron.
require_once($CFG->dirroot.'/completion/cron.php');
completion_regular_cron();
completion_cron_criteria();
completion_cron_completions();
}
}

Expand Down
23 changes: 22 additions & 1 deletion lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2378,4 +2378,25 @@ function get_referer($stripquery = true) {
} else {
return '';
}
}
}

/**
* Update user's course completion statuses
*
* First update all criteria completions, then aggregate all criteria completions
* and update overall course completions.
*
* @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
* @todo Remove this function in Moodle 3.2 MDL-51226.
*/
function completion_cron() {
global $CFG;
require_once($CFG->dirroot.'/completion/cron.php');

debugging('completion_cron() is deprecated. Functionality has been moved to scheduled tasks.', DEBUG_DEVELOPER);
completion_cron_mark_started();

completion_cron_criteria();

completion_cron_completions();
}

0 comments on commit 0628925

Please sign in to comment.