-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated details dashboard logic to avoid merging 3 APIs and utilize f… #488
base: main
Are you sure you want to change the base?
Changes from 2 commits
9a093f4
2aa513b
d34fe5d
0ed1d98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.student_header { | ||
display: flex; | ||
font-size: 1.1rem; | ||
margin: 10px; | ||
border-bottom: 2px solid purple; | ||
color: navy; | ||
font-weight: 100; | ||
background-color: hsl(194, 35%, 76%); | ||
max-width: fit-content; | ||
} | ||
|
||
.board_container { | ||
border: 4px solid black; | ||
padding: 10px; | ||
margin: 0px 5px 1px; | ||
background-color: grey; | ||
color: white; | ||
} | ||
|
||
.list_container { | ||
display: flex; | ||
|
||
flex-direction: row; | ||
align-items: center; | ||
gap: 10px; | ||
} | ||
|
||
.list_container h1 { | ||
font-weight: bold; | ||
font-size: 1.2rem; | ||
} | ||
.list_container button { | ||
font-size: 0.7rem; | ||
text-transform: uppercase; | ||
border: 1px solid navy; | ||
|
||
padding: 5px 10px; | ||
background-color: orange; | ||
} | ||
|
||
.list_container button:hover { | ||
background-color: rgb(89, 103, 174); | ||
color: white; | ||
} | ||
.inner_comp { | ||
background-color: grey; | ||
color: white; | ||
} | ||
|
||
.details_progress_stats { | ||
background-color: rgb(27, 15, 86); | ||
color: white; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
border: 1px solid rgb(93, 0, 255); | ||
padding: 10px; | ||
} | ||
|
||
.detailsBlockTitle { | ||
font-size: 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import styles from './DetailsCSS.module.css'; | ||
import DetailsDashboardList from './DetailsDashboardList'; | ||
//getStudentProgressInSuperblock | ||
|
||
import { getStudentProgressInSuperblock } from '../util/api_proccesor'; | ||
|
||
export default function DetailsDashboard(props) { | ||
const printSuperblockTitle = individualSuperblockJSON => { | ||
let indexOfTitleInSuperblockTitlesArray = | ||
props.superblocksDetailsJSONArray.indexOf(individualSuperblockJSON); | ||
let superblockTitle = | ||
props.superblockTitles[indexOfTitleInSuperblockTitlesArray]; | ||
return superblockTitle; | ||
}; | ||
|
||
const superblockProgress = superblockDashedName => { | ||
let studentProgress = props.studentData; | ||
|
||
return getStudentProgressInSuperblock( | ||
studentProgress, | ||
superblockDashedName | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
{props.superblocksDetailsJSONArray.map((arrayOfBlockObjs, idx) => { | ||
let index = props.superblocksDetailsJSONArray.indexOf(arrayOfBlockObjs); | ||
let superblockDashedName = | ||
props.superblocksDetailsJSONArray[index][0].superblock; | ||
let progressInBlocks = superblockProgress(superblockDashedName); | ||
let superblockTitle = printSuperblockTitle(arrayOfBlockObjs); | ||
return ( | ||
<div key={idx} className={styles.board_container}> | ||
<DetailsDashboardList | ||
superblockTitle={superblockTitle} | ||
blockData={arrayOfBlockObjs} | ||
studentProgressInBlocks={progressInBlocks} | ||
></DetailsDashboardList> | ||
</div> | ||
); | ||
})} | ||
</> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import { useState } from 'react'; | ||
import styles from './DetailsCSS.module.css'; | ||
import { getStudentTotalChallengesCompletedInBlock } from '../util/api_proccesor'; | ||
|
||
export default function DetailsDashboardList(props) { | ||
const [hideDetails, setHideDetails] = useState(true); | ||
const [buttonText, setButtonText] = useState('View details'); | ||
|
||
const handleShowDetails = () => { | ||
if (hideDetails) { | ||
setHideDetails(false); | ||
} else { | ||
setHideDetails(true); | ||
} | ||
Comment on lines
+10
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think we can reduce this to |
||
|
||
handleButtonText(hideDetails); | ||
}; | ||
|
||
const handleButtonText = hideDetails => { | ||
if (hideDetails) { | ||
setButtonText('View less'); | ||
} else { | ||
setButtonText('View details'); | ||
} | ||
}; | ||
|
||
const getStudentsProgressInBlock = blockName => { | ||
return getStudentTotalChallengesCompletedInBlock( | ||
props.studentProgressInBlocks, | ||
blockName | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={styles.list_container}> | ||
<h1>{props.superblockTitle} </h1> | ||
|
||
<button onClick={handleShowDetails}>{buttonText}</button> | ||
</div> | ||
<div className={styles.inner_comp}> | ||
{hideDetails ? ( | ||
'' | ||
) : ( | ||
<> | ||
<ul> | ||
<li> | ||
{props.blockData.map((blockDetails, idx) => { | ||
return ( | ||
<div className={styles.details_progress_stats} key={idx}> | ||
<h1 className={styles.detailsBlockTitle}> | ||
{blockDetails.blockName} | ||
</h1> | ||
<h1 className={styles.focus}> | ||
{getStudentsProgressInBlock(blockDetails.selector) + | ||
'/' + | ||
blockDetails.allChallenges.length} | ||
</h1> | ||
</div> | ||
); | ||
})} | ||
</li> | ||
</ul> | ||
</> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,12 @@ import { getSession } from 'next-auth/react'; | |
import GlobalDashboardTable from '../../../components/dashtable_v2'; | ||
import React from 'react'; | ||
import { | ||
createDashboardObject, | ||
getTotalChallenges, | ||
createSuperblockDashboardObject, | ||
getTotalChallengesForSuperblocks, | ||
getDashedNamesURLs, | ||
getSuperBlockJsons, | ||
formattedStudentData, | ||
getCompletionTimestamps | ||
fetchStudentData, | ||
checkIfStudentHasProgressDataForSuperblocksSelectedByTeacher | ||
} from '../../../util/api_proccesor'; | ||
|
||
export async function getServerSideProps(context) { | ||
|
@@ -58,35 +58,52 @@ export async function getServerSideProps(context) { | |
} | ||
}); | ||
|
||
let formattedStudentDataResponse = await formattedStudentData(); | ||
|
||
let timestamps = getCompletionTimestamps(formattedStudentDataResponse); | ||
|
||
let superblockURLS = await getDashedNamesURLs( | ||
certificationNumbers.fccCertifications | ||
); | ||
|
||
let superBlockJsons = await getSuperBlockJsons(superblockURLS); | ||
let dashboardObjs = createDashboardObject(superBlockJsons); | ||
let totalChallenges = getTotalChallenges(dashboardObjs); | ||
let superBlockJsons = await getSuperBlockJsons(superblockURLS); // this is an array of urls | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a comment letting us know this is an array of URLs, could we make this variable more descriptive so that it describes what it is supposed to be? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @GuillermoFloresV this name choice was introduced prior to me joining FCC which is why I added the comment. I could also make a separate 'easy' issue for this for CTI students or update it, @utsab let me know what you would prefer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let dashboardObjs = await createSuperblockDashboardObject(superBlockJsons); | ||
|
||
let totalChallenges = getTotalChallengesForSuperblocks(dashboardObjs); | ||
|
||
let studentData = await fetchStudentData(); | ||
|
||
// Temporary check to map/accomodate hard-coded mock student data progress in unselected superblocks by teacher | ||
let studentsAreEnrolledInSuperblocks = | ||
checkIfStudentHasProgressDataForSuperblocksSelectedByTeacher( | ||
studentData, | ||
dashboardObjs | ||
); | ||
studentData.forEach(studentJSON => { | ||
let indexToCheckProgress = studentData.indexOf(studentJSON); | ||
let isStudentEnrolledInAtLeastOneSuperblock = | ||
studentsAreEnrolledInSuperblocks[indexToCheckProgress].every( | ||
val => val === true | ||
); | ||
|
||
if (!isStudentEnrolledInAtLeastOneSuperblock) { | ||
studentData[indexToCheckProgress].certifications = []; | ||
} | ||
}); | ||
|
||
return { | ||
props: { | ||
userSession, | ||
classroomId: context.params.id, | ||
studentData: formattedStudentDataResponse, | ||
studentData, | ||
totalChallenges: totalChallenges, | ||
timestamps: timestamps | ||
studentsAreEnrolledInSuperblocks | ||
} | ||
}; | ||
} | ||
|
||
export default function Home({ | ||
userSession, | ||
studentData, | ||
classroomId, | ||
totalChallenges, | ||
timestamps | ||
studentData, | ||
studentsAreEnrolledInSuperblocks | ||
}) { | ||
return ( | ||
<Layout> | ||
|
@@ -106,10 +123,10 @@ export default function Home({ | |
</div> | ||
</Navbar> | ||
<GlobalDashboardTable | ||
studentData={studentData} | ||
classroomId={classroomId} | ||
timestamps={timestamps} | ||
totalChallenges={totalChallenges} | ||
studentData={studentData} | ||
studentsAreEnrolledInSuperblocks={studentsAreEnrolledInSuperblocks} | ||
></GlobalDashboardTable> | ||
</> | ||
)} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an edge case here where if we do not have a
superblocksDetailsJSONArray
is undefined, or of length 0? We can add conditional rendering to check if oursuperblocksDetailsJSONArray
is undefined/has a length of 0, display a message to alert the user that there is no data to displayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GuillermoFloresV this is a good separate issue for someone wanting to contribute to the UI/Design side of the page. I prefer to create a separate issue for conditional rendering.