1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace smtech\SeeAllSubmissions; |
4
|
|
|
|
5
|
|
|
use smtech\LTI\Configuration\Option; |
6
|
|
|
use Battis\HierarchicalSimpleCache; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* See All Submissions toolbox |
10
|
|
|
* |
11
|
|
|
* Adds some common, useful methods to the St. Mark's-styled |
12
|
|
|
* ReflexiveCanvasLTI Toolbox |
13
|
|
|
* |
14
|
|
|
* @author Seth Battis <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class Toolbox extends \smtech\StMarksReflexiveCanvasLTI\Toolbox |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Configure course and account navigation placements |
21
|
|
|
* |
22
|
|
|
* @return Generator |
23
|
|
|
*/ |
24
|
|
|
public function getGenerator() |
25
|
|
|
{ |
26
|
|
|
parent::getGenerator(); |
27
|
|
|
|
28
|
|
|
$this->generator->setOptionProperty( |
29
|
|
|
Option::COURSE_NAVIGATION(), |
30
|
|
|
'visibility', |
31
|
|
|
'members' |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
return $this->generator; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* This is a quasi temporary "unborking" while a few support tickets are |
39
|
|
|
* working through the queue. See the fix-me notations below. |
40
|
|
|
* |
41
|
|
|
* @param string $previewUrl |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function unborkPreviewUrl($previewUrl) |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
if (!preg_match('%^https?://.*%', $previewUrl)) { |
47
|
|
|
/* |
48
|
|
|
* FIXME: per [case 01584858 ](https://cases.canvaslms.com/CommunityConsole?id=500A000000UPwauIAD) |
49
|
|
|
* attachments are not well-documented and the Crocodoc attachments |
50
|
|
|
* include an incomplete preview URL that works… but not in an IFRAME |
51
|
|
|
*/ |
52
|
|
|
return $_SESSION[CANVAS_INSTANCE_URL] . $previewUrl; |
53
|
|
|
} elseif (preg_match('%^(.*version=)(\d+)(.*)$%', $previewUrl, $match)) { |
54
|
|
|
/* |
55
|
|
|
* FIXME: per [case 01584819](https://cases.canvaslms.com/CommunityConsole?id=500A000000UPwSlIAL) |
56
|
|
|
* preview URLs are generated "off by one" and are really zero-indexed. |
57
|
|
|
*/ |
58
|
|
|
return $match[1] . ($match[2] - 1) . $match[3]; |
59
|
|
|
} else { |
60
|
|
|
/* whatevs, it is what it is… */ |
61
|
|
|
return $previewUrl; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: