-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_feedback_cli.php
62 lines (47 loc) · 1.42 KB
/
create_feedback_cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// This file is part of a plugin for Moodle - http://moodle.org/
/**
* @package local
* @subpackage fbwizard
* @copyright 2012-2013 Silecs {@link http://www.silecs.info/societe}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('CLI_SCRIPT', true);
require_once(__DIR__ . '/../../config.php');
require_once('locallib.php');
require_once('apogee.class.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
// now get cli options
list($options, $unrecognized) = cli_get_params(array(
'help'=>false, 'count'=>false, 'init'=>false ),
array('h'=>'help', 'c'=>'count', 'i'=>'init'));
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
$help =
"Deploy feedbacks from PAGS webservice. Normally, to be executed by a cron job.
Options:
-c, --count Return the number of course to deploy
-i, --init Apply to all course to eploy
-h, --help Print out this help
Example:
/usr/bin/php local/fbwizard/create_feedback_cli.php --init
";
if ( ! empty($options['help']) ) {
echo $help;
return 0;
}
echo $help;
// Ensure errors are well explained
$CFG->debug = DEBUG_NORMAL;
if ( $options['count'] ) {
$nb = count_courses();
echo $nb;
return 0;
}
if ( $options['init'] ) {
$since = 0;
create_courses();
return 0;
}