Skip to content

Commit

Permalink
Fixed some links
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Mar 21, 2023
1 parent 6648553 commit 618f6e4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/Api/getPortfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
//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')
SELECT cc.doenetId,
cc.imagePath,
cc.label,
cc.isPublic,
p.doenetId AS 'pageDoenetId'
FROM course_content AS cc
LEFT JOIN pages AS p
ON p.containingDoenetId = cc.doenetId
WHERE cc.courseId = (SELECT courseId FROM course WHERE portfolioCourseForUserId = '$userId')
";
$result = $conn->query($sql);

Expand All @@ -40,6 +43,7 @@
'imagePath' => $row['imagePath'],
'label' => $row['label'],
'public' => $row['isPublic'],
'pageDoenetId' => $row['pageDoenetId'],
];
if ($row['isPublic'] == '1') {
array_push($publicActivities, $activity);
Expand Down
15 changes: 15 additions & 0 deletions src/Api/getPortfolioActivityData.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@
$message = 'Error: You need to sign in';
}

$sql = "
SELECT doenetId
FROM pages
WHERE containingDoenetId = '$doenetId'
";
$result = $conn->query($sql);
$pageDoenetId = '';

if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$pageDoenetId = $row['doenetId'];
}

$activityData = [
'doenetId' => $doenetId,
'imagePath' => '/media/activity_default.jpg',
'label' => '',
'learningOutcomes' => '',
'public' => false, //default to private
'isNew' => true,
'pageDoenetId' => $pageDoenetId,
];

//Assume we are updating the activity and need the current settings
Expand All @@ -51,6 +65,7 @@
'learningOutcomes' => $row['learningOutcomes'],
'public' => $row['isPublic'],
'isNew' => false,
'pageDoenetId' => $pageDoenetId,
];
} else {
//It's a new activity or a hack
Expand Down
7 changes: 4 additions & 3 deletions src/Tools/_framework/Paths/Portfolio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function action() {

if (response.ok) {
let { doenetId, pageDoenetId } = await response.json();
return redirect(`/portfolio?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`);
return redirect(`/portfolioeditor?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`);
// return redirect(`/portfolio/${doenetId}/settings`) //Should use doenetId next for loader
}else{
throw Error(response.message)
Expand Down Expand Up @@ -78,7 +78,7 @@ const PrivateActivitiesSection = styled.div`
background: var(--mainGray);
`

function Card({ doenetId,imagePath,label }) {
function Card({ doenetId,imagePath,label, pageDoenetId }) {
const cardStyle = {
display: 'flex',
flexDirection: 'column',
Expand Down Expand Up @@ -139,7 +139,8 @@ function Card({ doenetId,imagePath,label }) {
// maxWidth: '240px',
}

const activityLink = `/portfolio/${doenetId}/editor`;
// const activityLink = `/portfolio/${doenetId}/editor`;
const activityLink = `/portfolioeditor?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`;

return (
<a style={linkStyle} href={activityLink} target="_blank">
Expand Down
13 changes: 10 additions & 3 deletions src/Tools/_framework/Paths/PortfolioActivitySettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ export async function action({ request, params }) {
let response = await axios.post("/api/updatePortfolioActivitySettings.php",{
...updates, doenetId:params.doenetId
})
const portfolioCourseId = response.data.portfolioCourseId;
// const portfolioCourseId = response.data.portfolioCourseId;

// if (response.ok) {
// // let { doenetId } = await response.json();

return redirect(`/portfolio/${portfolioCourseId}`)
// if (updates._source == "_source")
return redirect(`/portfolioeditor?tool=editor&doenetId=${updates.doenetId}&pageId=${updates.pageDoenetId}`)
// return redirect(`/portfolioeditor?tool=editor&doenetId=${updates.doenetId}&pageId=${updates.pageDoenetId}`)
// }else{
// return redirect(`/portfolio/${portfolioCourseId}`)
// }
// }else{
// throw Error(response.message)
// }
Expand Down Expand Up @@ -276,6 +280,9 @@ export function PortfolioActivitySettings(){
</Slot3>
</MainGrid>
<input type="hidden" name="imagePath" value={imagePath}></input>
<input type="hidden" name="doenetId" value={data.doenetId}></input>
<input type="hidden" name="pageDoenetId" value={data.pageDoenetId}></input>
{/* <input type="hidden" name="_source" value="portfolio activity settings"></input> */}
</Form>
</>
}
Expand Down

0 comments on commit 618f6e4

Please sign in to comment.