1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace smtech\GradingAnalytics; |
4
|
|
|
|
5
|
|
|
use smtech\LTI\Configuration\Option; |
6
|
|
|
use Battis\HierarchicalSimpleCache; |
7
|
|
|
|
8
|
|
|
class Toolbox extends \smtech\StMarksReflexiveCanvasLTI\Toolbox |
9
|
|
|
{ |
10
|
|
|
const TOOL_CANVAS_EXTERNAL_TOOL_ID = 'TOOL_CANVAS_EXTERNAL_TOOL_ID'; |
11
|
|
|
|
12
|
|
|
protected $history; |
13
|
|
|
|
14
|
|
|
protected $snapshots; |
15
|
|
|
|
16
|
|
|
public function getGenerator() |
17
|
|
|
{ |
18
|
|
|
parent::getGenerator(); |
19
|
|
|
|
20
|
|
|
$this->generator->setOptionProperty( |
21
|
|
|
Option::COURSE_NAVIGATION(), |
22
|
|
|
'visibility', |
23
|
|
|
'admins' |
24
|
|
|
); |
25
|
|
|
$this->generator->setOptionProperty( |
26
|
|
|
Option::ACCOUNT_NAVIGATION(), |
27
|
|
|
'visibility', |
28
|
|
|
'admins' |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
return $this->generator; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function loadConfiguration($configFilePath, $forceRecache = false) |
35
|
|
|
{ |
36
|
|
|
parent::loadConfiguration($configFilePath, $forceRecache); |
37
|
|
|
|
38
|
|
|
if ($forceRecache) { |
39
|
|
|
$this->clearConfig(self::TOOL_CANVAS_EXTERNAL_TOOL_ID); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
private $GRAPH_DATA_COUNT = 0; |
44
|
|
|
public function graphWidth($dataCount = false) |
45
|
|
|
{ |
46
|
|
|
if ($dataCount) { |
47
|
|
|
$this->GRAPH_DATA_COUNT = $dataCount; |
|
|
|
|
48
|
|
|
} |
49
|
|
|
return max(GRAPH_MIN_WIDTH, $this->GRAPH_DATA_COUNT * GRAPH_BAR_WIDTH); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function graphHeight($dataCount = false) |
53
|
|
|
{ |
54
|
|
|
if ($dataCount) { |
55
|
|
|
$this->GRAPH_DATA_COUNT = $dataCount; |
|
|
|
|
56
|
|
|
} |
57
|
|
|
return $this->graphWidth() * GRAPH_ASPECT_RATIO; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getHistory($courseId) |
61
|
|
|
{ |
62
|
|
|
if (!is_a($this->history, History::class)) { |
63
|
|
|
$this->history = new History($this, $courseId); |
64
|
|
|
} |
65
|
|
|
return $this->history->getHistory(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getSnapshot($courseOrDepartmentId, Domain $domain, $isCourseId = true, $teacherFilter = false) |
69
|
|
|
{ |
70
|
|
|
if (empty($this->snapshots[$domain])) { |
71
|
|
|
$this->snapshots[$domain] = new Snapshot($this, $domain, $courseOrDepartmentId, $isCourseId); |
72
|
|
|
} |
73
|
|
|
return $this->snapshots[$domain]->getSnapshot($teacherFilter); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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.