-
Notifications
You must be signed in to change notification settings - Fork 1
/
worker.php
46 lines (42 loc) · 1.37 KB
/
worker.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
<?php
session_start();
//require_once 'vendor/autoload.php';
require_once 'kpasinc/dataporten.inc';
require_once 'kpasinc/vars.inc';
require_once 'kpasinc/curlutility.inc';
require_once 'kpasinc/canvas.inc';
require_once 'kpasinc/utility.inc';
printHtmlHeader();
try {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$jsonGroup = $_POST["group"];
$group = json_decode($jsonGroup, true);
$result = AddUserToGroup($group["user_id"], $group);
echo $result;
}
$courseId = $_SESSION["courseId"];
printCourseId($courseId);
$userInfo = $_SESSION["userInfo"];
$dataportenGroups = $_SESSION["groups"];
$extraUserInfo = $_SESSION["extraUserInfo"];
$feideid = getFeideIdFromDataportenUserInfo($userInfo);
mydbg("FeideId: " . $feideid);
$canvasUser = null;
$canvasUser = getCanvasUserFromFeideId($feideid);
if(!$canvasUser) {
throw new Exception("Kunne ikke finne brukeren " . $feideid . " i Canvas.");
}
printCanvasUser($canvasUser);
printDataportenUserInfo($userInfo);
printDataportenExtraUserInfo($extraUserInfo);
$user_id = $canvasUser["id"];
printCanvasUserId($user_id);
printDataportenGroupsInfo($dataportenGroups);
printGroupsForCourse($courseId, $dataportenGroups);
printLogoutButton();
} catch (Exception $e) {
$result = $e->getMessage();
print $result;
}
printHtmlFooter();
?>