Skip to content

Commit a13f59b

Browse files
committed
Convert deprecated legacy cron task to Tasks API
1 parent a5946ea commit a13f59b

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

classes/task/update_dirty_sets.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace mod_wwassignment\task;
4+
5+
defined('MOODLE_INTERNAL') || die();
6+
7+
class update_dirty_sets extends \core\task\scheduled_task {
8+
public function get_name() {
9+
return get_string('updatedirtysets', 'mod_wwassignment');
10+
}
11+
12+
public function execute() {
13+
global $CFG;
14+
require_once($CFG->dirroot . '/mod/wwassignment/locallib.php');
15+
16+
_wwassignment_update_dirty_sets();
17+
}
18+
}

db/tasks.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
defined('MOODLE_INTERNAL') || die();
4+
5+
$tasks = array(
6+
array(
7+
'classname' => 'mod_wwassignment\task\updatedirtysets',
8+
'blocking' => 0,
9+
'minute' => 'R',
10+
'hour' => '4',
11+
'day' => '*',
12+
'month' => '*',
13+
'dayofweek' => '*'
14+
)
15+
);

lib.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,25 +508,6 @@ function wwassignment_print_recent_activity($course, $isteacher, $timestart) {
508508
return false; // True if anything was printed, otherwise false
509509
}
510510

511-
/**
512-
* @desc Function that is run by the cron job. This makes sure that
513-
* the grades and all other data are pulled from webwork.
514-
* returns true if successful
515-
*/
516-
function wwassignment_cron() {
517-
traceLog("-------------Begin wwassignment_cron-------------------------");
518-
519-
//FIXME: Add a call that updates all events with dates (in case people forgot to push)
520-
//wwassignment_refresh_events();
521-
//FIXME: Add a call that updates all grades in all courses
522-
//wwassignment_update_grades(null,0);
523-
//try { // try didn't work on some php systems -- leave it out.
524-
_wwassignment_update_dirty_sets();
525-
traceLog("---------------------End wwassignment_cron------------------------");
526-
return true;
527-
}
528-
529-
530511
// reference material for improving update dirty sets:
531512
// from wiki/lib /print_recent_activity
532513
// $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l

version.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424

2525
// 3.0+
2626
defined('MOODLE_INTERNAL') || die();
27-
$plugin->version = 2015030918; // The current module version (Date: YYYYMMDDXX)
27+
$plugin->version = 2015030919; // The current module version (Date: YYYYMMDDXX)
2828
$plugin->requires = 2014110400; // Requires this Moodle version
29-
$plugin->cron = 300; // Period for cron to check this module (secs) -- every 5 minutes
3029
$plugin->component = 'mod_wwassignment';
3130
$plugin->maturity = MATURITY_STABLE;
3231

0 commit comments

Comments
 (0)