Completed
Branch master (1de524)
by Seth
09:29
created
js/relative-grades.js.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) . '"' ?>],
Please login to merge, or discard this patch.
course/common.inc.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
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` */
Please login to merge, or discard this patch.
course/relative-grades.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 /*
Please login to merge, or discard this patch.
course/observers.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -3,43 +3,43 @@
 block discarded – undo
3 3
 require_once 'common.inc.php';
4 4
 
5 5
 $toolbox->cache_pushKey(basename(__FILE__, '.php')); {
6
-	$observers = $toolbox->cache_get('observers');
7
-	if ($observers === false) {
8
-		$observers = [];
9
-		$enrollments = $toolbox->api_get(
10
-			'courses/' . $_SESSION[COURSE_ID] . '/enrollments', [
11
-				'role[]' => 'ObserverEnrollment' // FIXME this shouldn't requrie the faux-array
12
-			]
13
-		);
14
-		foreach ($enrollments as $enrollment) {
15
-			$observers[] = $toolbox->api_get("users/{$enrollment['user']['id']}/profile");
16
-		}
17
-		$toolbox->cache_set('observers', $observers);
18
-	}
6
+    $observers = $toolbox->cache_get('observers');
7
+    if ($observers === false) {
8
+        $observers = [];
9
+        $enrollments = $toolbox->api_get(
10
+            'courses/' . $_SESSION[COURSE_ID] . '/enrollments', [
11
+                'role[]' => 'ObserverEnrollment' // FIXME this shouldn't requrie the faux-array
12
+            ]
13
+        );
14
+        foreach ($enrollments as $enrollment) {
15
+            $observers[] = $toolbox->api_get("users/{$enrollment['user']['id']}/profile");
16
+        }
17
+        $toolbox->cache_set('observers', $observers);
18
+    }
19 19
 
20
-	$observees = $toolbox->cache_get('observees');
21
-	if ($observees === false) {
22
-		$observees = [];
23
-		foreach ($observers as $observer) {
24
-			$response = $toolbox->api_get("users/{$observer['id']}/observees");
25
-			$observees[$observer['id']] = $response[0];
26
-		}
27
-		$toolbox->cache_set('observees', $observees);
28
-	}
20
+    $observees = $toolbox->cache_get('observees');
21
+    if ($observees === false) {
22
+        $observees = [];
23
+        foreach ($observers as $observer) {
24
+            $response = $toolbox->api_get("users/{$observer['id']}/observees");
25
+            $observees[$observer['id']] = $response[0];
26
+        }
27
+        $toolbox->cache_set('observees', $observees);
28
+    }
29 29
 
30
-	$passwords = [];
31
-	foreach ($observers as $observer) {
32
-		$response = $toolbox->mysql_query("
30
+    $passwords = [];
31
+    foreach ($observers as $observer) {
32
+        $response = $toolbox->mysql_query("
33 33
 			SELECT * FROM `observers` WHERE `id` = '{$observer['id']}' LIMIT 1
34 34
 		");
35
-		$password = $response->fetch_assoc();
36
-		$passwords[$observer['id']] = $password['password'];
37
-	}
35
+        $password = $response->fetch_assoc();
36
+        $passwords[$observer['id']] = $password['password'];
37
+    }
38 38
 } $toolbox->cache_popKey();
39 39
 
40 40
 $toolbox->smarty_assign([
41
-	'observers' => $observers,
42
-	'passwords' => $passwords,
43
-	'observees' => $observees
41
+    'observers' => $observers,
42
+    'passwords' => $passwords,
43
+    'observees' => $observees
44 44
 ]);
45 45
 $toolbox->smarty_display('observers.tpl');
Please login to merge, or discard this patch.