forked from Doenet/DoenetTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf288e2
commit e63643b
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
header('Access-Control-Allow-Origin: *'); | ||
header('Access-Control-Allow-Headers: access'); | ||
header('Access-Control-Allow-Methods: GET'); | ||
header('Access-Control-Allow-Credentials: true'); | ||
header('Content-Type: application/json'); | ||
|
||
include 'db_connection.php'; | ||
|
||
$jwtArray = include 'jwtArray.php'; | ||
$userId = $jwtArray['userId']; | ||
|
||
$success = true; | ||
$message = ''; | ||
|
||
if ($userId == '') { | ||
$success = false; | ||
$message = 'Error: You need to sign in'; | ||
} | ||
|
||
$publicActivities = []; | ||
$privateActivities = []; | ||
|
||
//Assume we are updating the activity and need the current settings | ||
if ($success) { | ||
$sql = " | ||
SELECT doenetId, | ||
imagePath, | ||
label, | ||
isPublic | ||
FROM course_content | ||
WHERE courseId = (SELECT courseId FROM course WHERE portfolioCourseForUserId = '$userId') | ||
"; | ||
$result = $conn->query($sql); | ||
|
||
if ($result->num_rows > 0) { | ||
while ($row = $result->fetch_assoc()) { | ||
$activity = [ | ||
'doenetId' => $row['doenetId'], | ||
'imagePath' => $row['imagePath'], | ||
'label' => $row['label'], | ||
'public' => $row['isPublic'], | ||
]; | ||
if ($row['isPublic'] == '1') { | ||
array_push($publicActivities, $activity); | ||
} else { | ||
array_push($privateActivities, $activity); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$response_arr = [ | ||
'success' => $success, | ||
'message' => $message, | ||
'publicActivities' => $publicActivities, | ||
'privateActivities' => $privateActivities, | ||
]; | ||
|
||
http_response_code(200); | ||
|
||
// make it json format | ||
echo json_encode($response_arr); | ||
|
||
$conn->close(); | ||
|
||
?> |