1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once('common.inc.php'); |
4
|
|
|
|
5
|
|
|
use Battis\BootstrapSmarty\NotificationMessage; |
6
|
|
|
|
7
|
|
|
define('STEP_INSTRUCTIONS', 1); |
8
|
|
|
define('STEP_GO', 2); |
9
|
|
|
|
10
|
|
|
$step = (empty($_REQUEST['step']) ? STEP_INSTRUCTIONS : $_REQUEST['step']); |
11
|
|
|
|
12
|
|
|
switch ($step) { |
13
|
|
|
case STEP_GO: |
14
|
|
|
$terms = array( |
15
|
|
|
'2015-2016-full-year', |
16
|
|
|
'2015-2016-semester-fall', |
17
|
|
|
'2015-2016-semester-spring' |
18
|
|
|
); |
19
|
|
|
|
20
|
|
|
$fixed = 0; |
21
|
|
|
$checked = 0; |
22
|
|
|
$affected = array(); |
23
|
|
|
$ignored = array(); |
24
|
|
|
|
25
|
|
|
try { |
26
|
|
|
foreach ($terms as $term) { |
27
|
|
|
$courses = $toolbox->api_get( |
28
|
|
|
'accounts/1/courses', |
29
|
|
|
array( |
30
|
|
|
'enrollment_term_id' => "sis_term_id:$term" |
31
|
|
|
) |
32
|
|
|
); |
33
|
|
|
foreach ($courses as $course) { |
34
|
|
|
$sections = $toolbox->api_get("/courses/{$course['id']}/sections"); |
35
|
|
|
foreach ($sections as $section) { |
36
|
|
|
$checked++; |
37
|
|
|
if (preg_match('/wglsqla/', $section['sis_section_id'])) { |
38
|
|
|
$new = $toolbox->api_put( |
39
|
|
|
"sections/{$section['id']}", |
40
|
|
|
array( |
41
|
|
|
'course_section[sis_section_id]' => strtoupper(str_replace('-temp', '', $section['sis_section_id'])) |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$fixed++; |
46
|
|
|
$affected[] = "<a target=\"_parent\" href=\"{$_SESSION[CANVAS_INSTANCE_URL]}/courses/{$course['id']}/sections/{$section['id']}\">{$section['name']}</a> ({$section['sis_section_id']} → {$new['sis_section_id']})"; |
47
|
|
|
} else { |
48
|
|
|
$ignored[] = "<a target=\"_parent\" href=\"{$_SESSION[CANVAS_INSTANCE_URL]}/courses/{$course['id']}/sections{$section['id']}\">{$section['name']}</a> ({$section['sis_section_id']})"; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} catch (Exception $e) { |
54
|
|
|
$toolbox->exceptionErrorMessage($e); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$toolbox->smarty_addMessage( |
58
|
|
|
"Fixed $fixed of $checked Sections", |
59
|
|
|
'<p>All the section SIS IDs that seemed to be incorrectly capitalized have been capitalized.</p><dl><dt>Ignored</dt><dd><ol><li>' . implode('</li><li>', $ignored) . '</li><ol></dd><dt>Affected</dt><dd><ol><li>' . implode('</li><li>', $affected) . '</li></ol></dd></dl>', |
60
|
|
|
NotificationMessage::GOOD |
|
|
|
|
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
/* flows into STEP_INSTRUCTIONS */ |
64
|
|
|
|
65
|
|
|
case STEP_INSTRUCTIONS: |
66
|
|
|
default: |
67
|
|
|
$toolbox->smarty_assign('formHidden', array('step' => STEP_GO)); |
68
|
|
|
$toolbox->smarty_display(basename(__FILE__, '.php') . '/instructions.tpl'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/* FIXME WTF is this nonsense? */ |
72
|
|
|
$terms = array( |
73
|
|
|
'2014-2015-full-year', |
74
|
|
|
'2014-2015-semester-fall', |
75
|
|
|
'2014-2015-seemster-spring' |
76
|
|
|
); |
77
|
|
|
|
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.