Skip to content

Commit

Permalink
Removed refrences to next_doenetId
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Mar 26, 2023
1 parent eade9eb commit 5347709
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 65 deletions.
47 changes: 0 additions & 47 deletions src/Api/getNextDoenetId.php

This file was deleted.

52 changes: 37 additions & 15 deletions src/Api/getPortfolioActivityData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
header('Content-Type: application/json');

include 'db_connection.php';
include 'permissionsAndSettingsForOneCourseFunction.php';

$jwtArray = include 'jwtArray.php';
$userId = $jwtArray['userId'];
Expand Down Expand Up @@ -43,6 +44,39 @@
'pageDoenetId' => $pageDoenetId,
];

$courseId = '';

//What is the courseId of the doenetId
if ($success) {
$sql = "
SELECT courseId
FROM course_content
WHERE doenetId = '$doenetId'
";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$courseId = $row['courseId'];
} else {
$success = false;
$message = "Sorry! The activity doesn't have an associated portfolio.";
}
}

//Test if they have the permission to edit it
if ($success) {
$permissions = permissionsAndSettingsForOneCourseFunction(
$conn,
$userId,
$courseId
);
if ($permissions['canModifyActivitySettings'] == '0') {
$success = false;
$message = 'You need permission to edita a portfolio activity.';
}
}

//Assume we are updating the activity and need the current settings
if ($success) {
$sql = "
Expand All @@ -68,21 +102,9 @@
'pageDoenetId' => $pageDoenetId,
];
} else {
//It's a new activity or a hack
//So test if it's a hack
$sql = "
SELECT doenetId
FROM next_doenetId
WHERE userId='$userId'
AND doenetId='$doenetId'
";
$result = $conn->query($sql);
if ($result->num_rows <= 0) {
//It's a Hack
$success = false;
$message =
'Error: You need to click add activity before navigating here';
}
$success = false;
$message =
'Error: You need to click add activity before navigating here';
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Tools/_framework/Paths/Portfolio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function action({request}) {
let response = await fetch(`/api/deletePortfolioActivity.php?doenetId=${formObj.doenetId}`);

if (response.ok) {
let respObj = await response.json();
// let respObj = await response.json();
return true;
}else{
throw Error(response.message)
Expand All @@ -34,7 +34,7 @@ export async function action({request}) {
let response = await fetch(`/api/updateIsPublicActivity.php?doenetId=${formObj.doenetId}&isPublic=1`);

if (response.ok) {
let respObj = await response.json();
// let respObj = await response.json();
return true;
}else{
throw Error(response.message)
Expand All @@ -43,7 +43,7 @@ export async function action({request}) {
let response = await fetch(`/api/updateIsPublicActivity.php?doenetId=${formObj.doenetId}&isPublic=0`);

if (response.ok) {
let respObj = await response.json();
// let respObj = await response.json();
return true;
}else{
throw Error(response.message)
Expand Down

0 comments on commit 5347709

Please sign in to comment.