-
Notifications
You must be signed in to change notification settings - Fork 3
/
cloudManager.php
181 lines (131 loc) · 5.28 KB
/
cloudManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/*
==============================================================================
Copyright (c) 2009 Rustici Software
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
==============================================================================
*/
$language_file[] = "document";
$language_file[] = "scorm";
$language_file[] = "scormdocument";
$language_file[] = "learnpath";
$language_file[] = "scorm_cloud";
// global settings initialisation
// also provides access to main api (inc/lib/main_api.lib.php)
include("../inc/global.inc.php");
$is_allowed_to_edit = api_is_allowed_to_edit();
if(!$is_allowed_to_edit){
api_not_allowed(true);
}
/*
-----------------------------------------------------------
Libraries
-----------------------------------------------------------
*/
//many useful functions in main_api.lib.php, by default included
//require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
require_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
require_once ('scorm_cloud.lib.php');
$ScormService = cloud_getScormEngineService();
if (isset($_REQUEST['action'])){
if ($_REQUEST['action'] == 'delete' && isset($_REQUEST['ccid'])){
cloud_deleteCourse($_REQUEST['ccid']);
header('location: cloudManager.php');
} elseif ($_REQUEST['action'] == 'upload'){
$courseId = uniqid();
require_once('CloudPHPLibrary/CourseData.php');
$uploadService = $ScormService->getUploadService();
$courseService = $ScormService->getCourseService();
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['user_file']['name']);
$tempFile = $_FILES["user_file"]["tmp_name"];
move_uploaded_file($_FILES['user_file']['tmp_name'], $target_path);
$absoluteFilePathToZip = $target_path;
//now upload the file and save the resulting location
$location = $uploadService->UploadFile($absoluteFilePathToZip,null);
$courseService->ImportUploadedCourse($courseId, $location, null);
//delete local(Dokeos server) copy
unlink($target_path);
header('location: cloudManager.php');
}
}
$htmlHeadXtra[] = '
<style>
.manager_table {padding:5px;width:90%;}
.manager_table td {padding:2px; height:25px; border-bottom:1px dotted;}
.tblHeader td {font-weight:bold; font-size:110%; border-bottom:1px solid;}
.link_disable {color:#A8A7A7;}
div.row {clear:both; padding-top:15px;}
#usageFrame {padding:5px;width:90%;border:none;height:300px;}
.usage {margin-top:20px;}
</style>';
$nameTools = "SCORM Cloud Manager";
Display::display_header($nameTools,"Path");
$courseService = $ScormService->getCourseService();
$allResults = $courseService->GetCourseList();
echo '<div class="row"><div class="form_header">SCORM Cloud Packages</div></div>';
echo '<table class="manager_table" cellspacing="0">';
echo '<tr class="tblHeader"><td>Package Title</td><td>Total Cloud Registrations</td><td>'.get_lang('MyCourses').' (Trainer)</td><td> </td></tr>';
foreach($allResults as $course)
{
$ccid = $course->getCourseId();
echo '<td>';
echo $course->getTitle();
echo '</td><td>';
echo $course->getNumberOfRegistrations();
echo '</td>';
$tbl_scorm_cloud = Database :: get_main_table('scorm_cloud');
$tbl_course = Database :: get_main_table('course');
//select distinct c.title from course c inner join scorm_cloud sc on sc.course_code = c.code where sc.cloud_course_id = '4a8d6623c554c'
$sql_cloud = "select distinct c.title,c.tutor_name from $tbl_course c inner join $tbl_scorm_cloud sc on sc.course_code = c.code ".
"where sc.cloud_course_id = '$ccid'";
$res = api_sql_query($sql_cloud, __FILE__, __LINE__);
echo '<td>';
while ($row = Database :: fetch_array($res)) {
echo $row['title'].' ('.$row['tutor_name'].')<br/>';
}
echo '</td><td>';
if (Database :: num_rows($res) > 0){
echo '<span class="link_disable">Delete Package</span>';
} else {
echo '<a href="cloudManager.php?action=delete&ccid='.$course->getCourseId().'">Delete Package</a>';
}
echo '</td></tr>';
}
echo '</table>';
echo '
<br/>
<br/>
<form method="post" action="cloudManager.php" enctype="multipart/form-data">
<div class="row">
<div class="form_header">New SCORM Cloud Upload</div>
</div>
<div class="row">
<div class="label">SCORM or AICC file to upload</div>
<div class="formw"><input type="file" name="user_file"/></div>
</div>
<input type="hidden" name="action" value="upload"/>
<div class="row">
<div class="label"> </div>
<div class="formw"><button class="upload" type="submit" name="submit">Upload</button></div>
</div>
</form>
';
$appId = api_get_setting('scormCloudCredsId','appId');
$cssUrl = api_get_path(WEB_PATH).'main/scorm_cloud/cloudsignup.css';
?>
<div class="row usage">
<div class="form_header">SCORM Cloud Usage</div>
</div>
<iframe id='usageFrame' src='https://accounts.scorm.com/scorm-cloud-manager/public/usage-meter?appId=<?php echo $appId; ?>&cssurl=<?php echo $cssUrl; ?>'/>
<?php
Display::display_footer();
?>