1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace smtech\GradingAnalytics; |
4
|
|
|
|
5
|
|
|
use smtech\LTI\Configuration\Option; |
6
|
|
|
|
7
|
|
|
class Toolbox extends \smtech\StMarksReflexiveCanvasLTI\Toolbox |
8
|
|
|
{ |
9
|
|
|
public function getGenerator() |
10
|
|
|
{ |
11
|
|
|
parent::getGenerator(); |
12
|
|
|
|
13
|
|
|
$this->generator->setOptionProperty( |
14
|
|
|
Option::COURSE_NAVIGATION(), |
15
|
|
|
'visibility', |
16
|
|
|
'admins' |
17
|
|
|
); |
18
|
|
|
$this->generator->setOptionProperty( |
19
|
|
|
Option::ACCOUNT_NAVIGATION(), |
20
|
|
|
'visibility', |
21
|
|
|
'admins' |
22
|
|
|
); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
private $GRAPH_DATA_COUNT = 0; |
26
|
|
|
public function graphWidth($dataCount = false) |
27
|
|
|
{ |
28
|
|
|
if ($dataCount) { |
29
|
|
|
$this->GRAPH_DATA_COUNT = $dataCount; |
|
|
|
|
30
|
|
|
} |
31
|
|
|
return max(GRAPH_MIN_WIDTH, $this->GRAPH_DATA_COUNT * GRAPH_BAR_WIDTH); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function graphHeight($dataCount = false) |
35
|
|
|
{ |
36
|
|
|
if ($dataCount) { |
37
|
|
|
$this->GRAPH_DATA_COUNT = $dataCount; |
|
|
|
|
38
|
|
|
} |
39
|
|
|
return $this->graphWidth() * GRAPH_ASPECT_RATIO; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function averageTurnAround($departmentId = false) |
43
|
|
|
{ |
44
|
|
|
$stats = $this->mysql_query(" |
45
|
|
|
SELECT * FROM `course_statistics` |
46
|
|
|
WHERE |
47
|
|
|
`average_grading_turn_around` > 0 " . |
48
|
|
|
( |
49
|
|
|
$departmentId ? |
50
|
|
|
"AND `course[account_id]` = '$departmentId' " : |
51
|
|
|
'' |
52
|
|
|
) . " |
53
|
|
|
GROUP BY |
54
|
|
|
`course[id]` |
55
|
|
|
ORDER BY |
56
|
|
|
`timestamp` DESC |
57
|
|
|
"); |
58
|
|
|
|
59
|
|
|
$total = 0; |
60
|
|
|
$divisor = 0; |
61
|
|
|
while ($row = $stats->fetch_assoc()) { |
62
|
|
|
$total += $row['average_grading_turn_around'] * $row['student_count'] * $row['graded_assignment_count']; |
63
|
|
|
$divisor += $row['student_count'] * $row['graded_assignment_count']; |
64
|
|
|
} |
65
|
|
|
return $total / $divisor; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function averageAssignmentCount($departmentId = false) |
69
|
|
|
{ |
70
|
|
|
$stats = $this->mysql_query(" |
71
|
|
|
SELECT * FROM ( |
72
|
|
|
SELECT * FROM `course_statistics`" . |
73
|
|
|
( |
74
|
|
|
$departmentId ? " |
75
|
|
|
WHERE |
76
|
|
|
`course[account_id]` = '$departmentId'" : |
77
|
|
|
'' |
78
|
|
|
) . " |
79
|
|
|
ORDER BY |
80
|
|
|
`timestamp` DESC |
81
|
|
|
) AS `stats` |
82
|
|
|
GROUP BY |
83
|
|
|
`course[id]` |
84
|
|
|
"); |
85
|
|
|
|
86
|
|
|
$total = 0; |
87
|
|
|
while ($row = $stats->fetch_assoc()) { |
88
|
|
|
$total += $row['assignments_due_count'] + $row['dateless_assignment_count']; |
89
|
|
|
} |
90
|
|
|
return $total / $stats->num_rows; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.