@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use smtech\AdvisorDashboard\Toolbox; |
| 6 | 6 | use smtech\ReflexiveCanvasLTI\LTI\ToolProvider; |
| 7 | -use smtech\ReflexiveCanvasLTI\Exception\ConfigurationException; |
|
| 8 | 7 | use Battis\DataUtilities; |
| 9 | 8 | |
| 10 | 9 | define('CONFIG_FILE', __DIR__ . '/config.xml'); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | if (empty($_SESSION[Toolbox::class])) { |
| 19 | 19 | $_SESSION[Toolbox::class] = Toolbox::fromConfiguration(CONFIG_FILE); |
| 20 | 20 | } |
| 21 | -$toolbox =& $_SESSION[Toolbox::class]; |
|
| 21 | +$toolbox = & $_SESSION[Toolbox::class]; |
|
| 22 | 22 | $toolbox->smarty_assign('category', DataUtilities::titleCase(preg_replace('/[\-_]+/', ' ', basename(__DIR__)))); |
| 23 | 23 | |
| 24 | 24 | /* set the Tool Consumer's instance URL, if present */ |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | /** |
| 22 | 22 | * Configure course and account navigation placements |
| 23 | 23 | * |
| 24 | - * @return Generator |
|
| 24 | + * @return \smtech\LTI\Configuration\Generator |
|
| 25 | 25 | */ |
| 26 | 26 | public function getGenerator() |
| 27 | 27 | { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace smtech\AdvisorDashboard; |
| 4 | 4 | |
| 5 | 5 | use smtech\LTI\Configuration\Option; |
| 6 | -use Battis\DataUtilities; |
|
| 7 | 6 | use Battis\HierarchicalSimpleCache; |
| 8 | 7 | |
| 9 | 8 | /** |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $points = 0; |
| 23 | 23 | function normalize($numerator, $denominator = false) { |
| 24 | - global $points; |
|
| 25 | - $denominator = ($denominator !== false ? $denominator : $points); |
|
| 26 | - $points = $denominator; |
|
| 27 | - return min(100, $numerator / $denominator * 100); |
|
| 24 | + global $points; |
|
| 25 | + $denominator = ($denominator !== false ? $denominator : $points); |
|
| 26 | + $points = $denominator; |
|
| 27 | + return min(100, $numerator / $denominator * 100); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | header('Content-Type: application/javascript'); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $analytics = $toolbox->cache_get('analytics'); |
| 36 | 36 | if ($analytics === false) { |
| 37 | - exit; |
|
| 37 | + exit; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | ?> |
@@ -47,29 +47,29 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | <?php |
| 49 | 49 | |
| 50 | - $labels = array(); |
|
| 51 | - $max_scores = array(); |
|
| 52 | - $min_scores = array(); |
|
| 53 | - $medians = array(); |
|
| 54 | - $first_quartiles = array(); |
|
| 55 | - $third_quartiles = array(); |
|
| 56 | - $scores = array(); |
|
| 57 | - foreach($analytic as $data) { |
|
| 58 | - if ($data['points_possible'] > 0 && $data['max_score'] > 0) { |
|
| 59 | - $labels[] = ''; // htmlentities($data['title']); |
|
| 60 | - $max_scores[] = normalize($data['max_score'], $data['points_possible']); |
|
| 61 | - $min_scores[] = normalize($data['min_score']); |
|
| 62 | - $medians[] = normalize($data['median']); |
|
| 63 | - $first_quartiles[] = normalize($data['first_quartile']); |
|
| 64 | - $third_quartiles[] = normalize($data['third_quartile']); |
|
| 65 | - if (empty($data['submission'])) { |
|
| 66 | - $scores[] = '""'; /* some assignments may not have grades */ |
|
| 67 | - } else { |
|
| 68 | - $scores[] = normalize($data['submission']['score']); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - ?> |
|
| 50 | + $labels = array(); |
|
| 51 | + $max_scores = array(); |
|
| 52 | + $min_scores = array(); |
|
| 53 | + $medians = array(); |
|
| 54 | + $first_quartiles = array(); |
|
| 55 | + $third_quartiles = array(); |
|
| 56 | + $scores = array(); |
|
| 57 | + foreach($analytic as $data) { |
|
| 58 | + if ($data['points_possible'] > 0 && $data['max_score'] > 0) { |
|
| 59 | + $labels[] = ''; // htmlentities($data['title']); |
|
| 60 | + $max_scores[] = normalize($data['max_score'], $data['points_possible']); |
|
| 61 | + $min_scores[] = normalize($data['min_score']); |
|
| 62 | + $medians[] = normalize($data['median']); |
|
| 63 | + $first_quartiles[] = normalize($data['first_quartile']); |
|
| 64 | + $third_quartiles[] = normalize($data['third_quartile']); |
|
| 65 | + if (empty($data['submission'])) { |
|
| 66 | + $scores[] = '""'; /* some assignments may not have grades */ |
|
| 67 | + } else { |
|
| 68 | + $scores[] = normalize($data['submission']['score']); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + ?> |
|
| 73 | 73 | |
| 74 | 74 | var data = { |
| 75 | 75 | labels: [<?= '"' . implode('", "', $labels) . '"' ?>], |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | define('MEDIAN_STROKE', '#fff'); // white |
| 13 | 13 | define('MEDIAN_FILL', THIRD_QUARTILE_FILL); |
| 14 | 14 | define('FIRST_QUARTILE_STROKE', TRANSPARENT); |
| 15 | -define('FIRST_QUARTILE_FILL', '#ffe399'); // light yellow |
|
| 15 | +define('FIRST_QUARTILE_FILL', '#ffe399'); // light yellow |
|
| 16 | 16 | define('LOW_STROKE', '#ff3f0c'); // medium red |
| 17 | 17 | define('LOW_FILL', '#fff'); // white |
| 18 | 18 | define('SCORE_STROKE', '#000'); // black |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $first_quartiles = array(); |
| 55 | 55 | $third_quartiles = array(); |
| 56 | 56 | $scores = array(); |
| 57 | - foreach($analytic as $data) { |
|
| 57 | + foreach ($analytic as $data) { |
|
| 58 | 58 | if ($data['points_possible'] > 0 && $data['max_score'] > 0) { |
| 59 | 59 | $labels[] = ''; // htmlentities($data['title']); |
| 60 | 60 | $max_scores[] = normalize($data['max_score'], $data['points_possible']); |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | 'course[course_code]' => $courseName |
| 32 | 32 | ]); |
| 33 | 33 | $sections = $toolbox->api_get("courses/{$course['id']}/sections"); |
| 34 | - foreach($sections as $section) { |
|
| 34 | + foreach ($sections as $section) { |
|
| 35 | 35 | if ($section['name'] == $course['name']) { |
| 36 | 36 | $toolbox->api_put("sections/{$sections[0]['id']}", [ |
| 37 | 37 | 'course_section[name]' => $courseName |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $created = 0; |
| 65 | 65 | $reset = 0; |
| 66 | 66 | |
| 67 | - foreach($advisories as $advisory) { |
|
| 67 | + foreach ($advisories as $advisory) { |
|
| 68 | 68 | /* cache the teacher */ |
| 69 | 69 | $advisors = $toolbox->api_get("courses/{$advisory['id']}/users", [ |
| 70 | 70 | 'enrollment_role' => 'TeacherEnrollment' |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } else { |
| 76 | 76 | $toolbox->smarty_addMessage( |
| 77 | 77 | "{$advisory['name']}", |
| 78 | - "No teacher was found in <a target=\"_parent\" href=\"" . $_SESSION[CANVAS_INSTANCE_URL]. "/courses/{$advisory['id']}\">this advisory</a> and it was skipped.", |
|
| 78 | + "No teacher was found in <a target=\"_parent\" href=\"" . $_SESSION[CANVAS_INSTANCE_URL] . "/courses/{$advisory['id']}\">this advisory</a> and it was skipped.", |
|
| 79 | 79 | NotificationMessage::ERROR |
| 80 | 80 | ); |
| 81 | 81 | break; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | 'enrollment_role' => 'StudentEnrollment' |
| 88 | 88 | ]); |
| 89 | 89 | |
| 90 | - foreach($advisees as $advisee) { |
|
| 90 | + foreach ($advisees as $advisee) { |
|
| 91 | 91 | |
| 92 | 92 | /* generate what the advisor account info should be */ |
| 93 | 93 | $observer = [ |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $communicationChannels = $toolbox->api_get("users/{$existing['id']}/communication_channels"); |
| 126 | 126 | $emailExists = false; |
| 127 | 127 | $channelsToDelete = []; |
| 128 | - foreach($communicationChannels as $communicationChannel) { |
|
| 128 | + foreach ($communicationChannels as $communicationChannel) { |
|
| 129 | 129 | if ($communicationChannel['address'] != $observer['email']) { |
| 130 | 130 | $channelsToDelete[] = $communicationChannel['id']; |
| 131 | 131 | } else { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | 'position' => 1 |
| 141 | 141 | ]); |
| 142 | 142 | } |
| 143 | - foreach($channelsToDelete as $channelToDelete) { |
|
| 143 | + foreach ($channelsToDelete as $channelToDelete) { |
|
| 144 | 144 | $toolbox->api_delete("users/{$existing['id']}/communication_channels/{$channelToDelete}"); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | /* store any requested actions for future handling */ |
| 15 | 15 | $action = (empty($_REQUEST['action']) ? |
| 16 | - ACTION_UNSPECIFIED : |
|
| 17 | - strtolower($_REQUEST['action']) |
|
| 16 | + ACTION_UNSPECIFIED : strtolower($_REQUEST['action']) |
|
| 18 | 17 | ); |
| 19 | 18 | |
| 20 | 19 | /* action requests only come from outside the LTI! */ |
@@ -30,7 +29,7 @@ discard block |
||
| 30 | 29 | @session_unset(); |
| 31 | 30 | @session_start(); |
| 32 | 31 | @session_regenerate_id(true); |
| 33 | - $_SESSION[Toolbox::class] =& $toolbox; |
|
| 32 | + $_SESSION[Toolbox::class] = & $toolbox; |
|
| 34 | 33 | session_write_close(); |
| 35 | 34 | $toolbox->lti_authenticate(); |
| 36 | 35 | exit; |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | /* if not authenticated, default to showing credentials */ |
| 50 | 49 | } else { |
| 51 | 50 | $action = (empty($action) ? |
| 52 | - ACTION_CONFIG : |
|
| 53 | - $action |
|
| 51 | + ACTION_CONFIG : $action |
|
| 54 | 52 | ); |
| 55 | 53 | } |
| 56 | 54 | |
@@ -60,7 +58,7 @@ discard block |
||
| 60 | 58 | /* reset cached install data from config file */ |
| 61 | 59 | case ACTION_INSTALL: { |
| 62 | 60 | $_SESSION['toolbox'] = Toolbox::fromConfiguration(CONFIG_FILE, true); |
| 63 | - $toolbox =& $_SESSION['toolbox']; |
|
| 61 | + $toolbox = & $_SESSION['toolbox']; |
|
| 64 | 62 | |
| 65 | 63 | /* test to see if we can connect to the API */ |
| 66 | 64 | try { |
@@ -11,14 +11,14 @@ |
||
| 11 | 11 | /* get and cache ID of first student in the advisory group */ |
| 12 | 12 | $firstStudent = $toolbox->cache_get('first-student'); |
| 13 | 13 | if (empty($firstStudent)) { |
| 14 | - $enrollments = $toolbox->api_get( |
|
| 15 | - 'courses/' . $_SESSION[ToolProvider::class]['canvas']['course_id'] . '/enrollments', |
|
| 16 | - [ |
|
| 17 | - 'role[]' => 'StudentEnrollment' |
|
| 18 | - ] |
|
| 19 | - ); |
|
| 20 | - $firstStudent = $enrollments[0]['user']['id']; |
|
| 21 | - $toolbox->cache_set('first-student', $firstStudent); |
|
| 14 | + $enrollments = $toolbox->api_get( |
|
| 15 | + 'courses/' . $_SESSION[ToolProvider::class]['canvas']['course_id'] . '/enrollments', |
|
| 16 | + [ |
|
| 17 | + 'role[]' => 'StudentEnrollment' |
|
| 18 | + ] |
|
| 19 | + ); |
|
| 20 | + $firstStudent = $enrollments[0]['user']['id']; |
|
| 21 | + $toolbox->cache_set('first-student', $firstStudent); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /* generate faculty journal URL for use by `smtech/canvashack-plugin-faculty-journal` */ |
@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -header ('Location: relative-grades.php'); |
|
| 3 | +header('Location: relative-grades.php'); |
|
| 4 | 4 | exit; |
@@ -7,14 +7,14 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $accounts = $toolbox->getAccountList(); |
| 9 | 9 | function isAcademic($account) { |
| 10 | - global $accounts; |
|
| 11 | - if ($account == 132) { // FIXME really, hard-coded values? Really? |
|
| 12 | - return true; |
|
| 13 | - } elseif ($account == 1 || !is_integer($account)) { |
|
| 14 | - return false; |
|
| 15 | - } else { |
|
| 16 | - return isAcademic($accounts[$account]['parent_account_id']); |
|
| 17 | - } |
|
| 10 | + global $accounts; |
|
| 11 | + if ($account == 132) { // FIXME really, hard-coded values? Really? |
|
| 12 | + return true; |
|
| 13 | + } elseif ($account == 1 || !is_integer($account)) { |
|
| 14 | + return false; |
|
| 15 | + } else { |
|
| 16 | + return isAcademic($accounts[$account]['parent_account_id']); |
|
| 17 | + } |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $toolbox->cache_pushKey(basename(__FILE__, '.php')); |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $advisees = $toolbox->cache_get('advisees'); |
| 26 | 26 | if ($advisees === false) { |
| 27 | - $advisees = $toolbox->api_get( |
|
| 28 | - 'courses/' . $_SESSION[COURSE_ID] . '/enrollments', [ |
|
| 29 | - 'role[]' => 'StudentEnrollment' // FIXME this shouldn't require the faux-array |
|
| 30 | - ] |
|
| 31 | - ); |
|
| 32 | - $toolbox->cache_set('advisees', $advisees); |
|
| 27 | + $advisees = $toolbox->api_get( |
|
| 28 | + 'courses/' . $_SESSION[COURSE_ID] . '/enrollments', [ |
|
| 29 | + 'role[]' => 'StudentEnrollment' // FIXME this shouldn't require the faux-array |
|
| 30 | + ] |
|
| 31 | + ); |
|
| 32 | + $toolbox->cache_set('advisees', $advisees); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $advisee = (isset($_REQUEST['advisee']) ? $_REQUEST['advisee'] : $advisees[0]['user']['id']); |
@@ -38,40 +38,40 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $courses = $toolbox->cache_get('courses'); |
| 40 | 40 | if ($courses === false) { |
| 41 | - $allCourses = $toolbox->api_get("users/$advisee/courses"); |
|
| 42 | - |
|
| 43 | - $courses = []; |
|
| 44 | - foreach ($allCourses as $course) { |
|
| 45 | - if ( |
|
| 46 | - !empty($course['account_id']) && |
|
| 47 | - isAcademic($course['account_id']) |
|
| 48 | - ) { |
|
| 49 | - |
|
| 50 | - $courses[$course['id']] = $course; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - $toolbox->cache_set('courses', $courses); |
|
| 41 | + $allCourses = $toolbox->api_get("users/$advisee/courses"); |
|
| 42 | + |
|
| 43 | + $courses = []; |
|
| 44 | + foreach ($allCourses as $course) { |
|
| 45 | + if ( |
|
| 46 | + !empty($course['account_id']) && |
|
| 47 | + isAcademic($course['account_id']) |
|
| 48 | + ) { |
|
| 49 | + |
|
| 50 | + $courses[$course['id']] = $course; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + $toolbox->cache_set('courses', $courses); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $analytics = $toolbox->cache_get('analytics'); |
| 57 | 57 | if ($analytics === false) { |
| 58 | - $analytics = []; |
|
| 59 | - foreach ($courses as $course) { |
|
| 60 | - $analytics[$course['id']] = $toolbox->api_get("courses/{$course['id']}/analytics/users/$advisee/assignments"); |
|
| 61 | - } |
|
| 62 | - $toolbox->cache_set('analytics', $analytics); |
|
| 58 | + $analytics = []; |
|
| 59 | + foreach ($courses as $course) { |
|
| 60 | + $analytics[$course['id']] = $toolbox->api_get("courses/{$course['id']}/analytics/users/$advisee/assignments"); |
|
| 61 | + } |
|
| 62 | + $toolbox->cache_set('analytics', $analytics); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $toolbox->cache_popKey(); |
| 66 | 66 | $toolbox->cache_popKey(); |
| 67 | 67 | |
| 68 | 68 | $toolbox->smarty_assign([ |
| 69 | - 'advisee' => $advisee, |
|
| 70 | - 'advisees' => $advisees, |
|
| 71 | - 'terms' => $terms, |
|
| 72 | - 'courses' => $courses, |
|
| 73 | - 'analytics' => $analytics, |
|
| 74 | - 'canvasInstanceUrl' => $_SESSION[CANVAS_INSTANCE_URL] |
|
| 69 | + 'advisee' => $advisee, |
|
| 70 | + 'advisees' => $advisees, |
|
| 71 | + 'terms' => $terms, |
|
| 72 | + 'courses' => $courses, |
|
| 73 | + 'analytics' => $analytics, |
|
| 74 | + 'canvasInstanceUrl' => $_SESSION[CANVAS_INSTANCE_URL] |
|
| 75 | 75 | ]); |
| 76 | 76 | |
| 77 | 77 | /* |