Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert deprecated legacy cron task to Tasks API (fixes #5) #7

Open
wants to merge 2 commits into
base: ver3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions classes/task/update_dirty_sets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace mod_wwassignment\task;

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

class update_dirty_sets extends \core\task\scheduled_task {
public function get_name() {
return get_string('updatedirtysets', 'mod_wwassignment');
}

public function execute() {
global $CFG;
require_once($CFG->dirroot . '/mod/wwassignment/locallib.php');

_wwassignment_update_dirty_sets();
}
}
15 changes: 15 additions & 0 deletions db/tasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

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

$tasks = array(
array(
'classname' => 'mod_wwassignment\task\update_dirty_sets',
'blocking' => 0,
'minute' => 'R',
'hour' => '4',
'day' => '*',
'month' => '*',
'dayofweek' => '*'
)
);
1 change: 1 addition & 0 deletions lang/en/wwassignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@
$string['writing'] = 'WWASSIGN:writing';
$string['writing_help'] = 'WWASSIGN:writing_help';

$string['updatedirtysets'] = 'Synchronise grades from WebWorK';
19 changes: 0 additions & 19 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,25 +508,6 @@ function wwassignment_print_recent_activity($course, $isteacher, $timestart) {
return false; // True if anything was printed, otherwise false
}

/**
* @desc Function that is run by the cron job. This makes sure that
* the grades and all other data are pulled from webwork.
* returns true if successful
*/
function wwassignment_cron() {
traceLog("-------------Begin wwassignment_cron-------------------------");

//FIXME: Add a call that updates all events with dates (in case people forgot to push)
//wwassignment_refresh_events();
//FIXME: Add a call that updates all grades in all courses
//wwassignment_update_grades(null,0);
//try { // try didn't work on some php systems -- leave it out.
_wwassignment_update_dirty_sets();
traceLog("---------------------End wwassignment_cron------------------------");
return true;
}


// reference material for improving update dirty sets:
// from wiki/lib /print_recent_activity
// $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l
Expand Down
3 changes: 1 addition & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

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