Skip to content

Commit

Permalink
Public Editor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Apr 11, 2023
1 parent aa8c976 commit 010c561
Show file tree
Hide file tree
Showing 6 changed files with 462 additions and 302 deletions.
27 changes: 18 additions & 9 deletions public/api/getPortfolioActivityData.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,34 @@
// WHERE doenetId='$doenetId'
// AND courseId = (SELECT courseId FROM course WHERE portfolioCourseForUserId = '$userId')
// ";
$sql = "
SELECT imagePath,
label,
userCanViewSource,
isPublic
FROM course_content
WHERE doenetId='$doenetId'
";
// $sql = "
// SELECT imagePath,
// label,
// userCanViewSource,
// isPublic
// FROM course_content
// WHERE doenetId='$doenetId'
// AND courseId = (SELECT courseId FROM course WHERE portfolioCourseForUserId = '$userId')
// ";
$sql = "
SELECT cc.imagePath,
cc.label,
cc.userCanViewSource,
cc.isPublic,
c.portfolioCourseForUserId
FROM course_content AS cc
LEFT JOIN course AS c
ON c.courseId = cc.courseId
WHERE doenetId='$doenetId'
";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$isPortfolioCourse = '0';
if ($row['portfolioCourseForUserId'] != ""){
$isPortfolioCourse = '1';
}
$activityData = [
'doenetId' => $doenetId,
'imagePath' => $row['imagePath'],
Expand All @@ -119,6 +126,8 @@
'isNew' => false,
'pageDoenetId' => $pageDoenetId,
'courseId' => $courseId,
'isPortfolioCourse' => $isPortfolioCourse,

];
} else {
$success = false;
Expand Down
53 changes: 53 additions & 0 deletions src/Tools/_framework/HeaderControls/PublicNavigation.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { Suspense } from 'react';
import Button from '../../../_reactComponents/PanelHeaderComponents/Button';
import { useNavigate, useLoaderData } from 'react-router';

export default function PublicNavigation() {
const navigate = useNavigate();
// const { isPortfolioCourse, doenetId, courseId } = useLoaderData();
const { signedIn, portfolioCourseId } = useLoaderData();
return (
<Suspense fallback={<div>loading Breadcrumbs...</div>}>
<div style={{ display: 'flex', columnGap: '4px', marginRight: '16px' }}>
<Button
value="Home"
onClick={() => {
navigate('/');
}}
/>
<Button
value="Community"
onClick={() => {
navigate('/community');
}}
/>
{signedIn ? (
<>
<Button
value="Portfolio"
onClick={() => {
navigate(`/portfolio/${portfolioCourseId}`);
}}
/>
</>
) : null}
{/* {isPortfolioCourse == '1' ? (
<>
<Button
value="Portfolio"
onClick={() => {
navigate(`/publicportfolio/${courseId}`);
}}
/>
<Button
value="Viewer"
onClick={() => {
navigate(`/portfolioviewer/${doenetId}`);
}}
/>
</>
) : null} */}
</div>
</Suspense>
);
}
47 changes: 47 additions & 0 deletions src/Tools/_framework/MenuPanelCaps/PublicEditorInfoCap.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Box, Image } from '@chakra-ui/react';
import React from 'react';
import { useLoaderData } from 'react-router';

export async function loader({ params }) {
const doenetId = params.doenetId;
const response = await fetch(
`/api/getPortfolioActivityData.php?doenetId=${doenetId}`,
);
const data = await response.json();

return data.activityData;
}

export default function PublicEditorInfoCap() {
let { activityData } = useLoaderData();
let imagePath = '/activity_default.jpg';
if (activityData?.imagePath != null) {
imagePath = activityData?.imagePath;
}
return (
<>
<Box
height="130px"
width="100%"
// width="180px"
background="black"
overflow="hidden"
// border="2px solid #949494"
// borderRadius= "6px"
margin="auto"
>
<Image
width="100%"
height="100%"
objectFit="contain"
src={imagePath}
alt="Activity Image"
/>
</Box>
<div style={{ marginBottom: '5px', padding: '1px 5px' }}>
Public Activity Editor
</div>
{/* <div style={{ marginBottom: "5px",padding:'1px 5px' }}>{data.label}</div> */}
</>
);
}
Loading

0 comments on commit 010c561

Please sign in to comment.