Skip to content

Commit

Permalink
Merge pull request #54 from Aar-if/newaltv1
Browse files Browse the repository at this point in the history
Restricted skip from assessment.
  • Loading branch information
Aar-if authored Mar 21, 2024
2 parents 247efee + 9eefddd commit f66f2d1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/studentprogram/src/pages/lessonList.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ export default function LessonList({ footerLinks }) {
const navigate = useNavigate();
const [trackData, setTrackData] = React.useState();
const [loading, setLoading] = React.useState(true);

const updateAllowSkipProperty = (data) => {
const updatedData = JSON.parse(JSON.stringify(data));
// Creating a deep copy of JSON data that
//we are getting from SUNBIRD API

// Helper function that will recursively update "allowSkip" property from YES TO NO from all places.
const updateAllowSkipRecursive = (obj) => {
for (const key in obj) {
if (obj[key] && typeof obj[key] === "object") {
updateAllowSkipRecursive(obj[key]); // Recursive call for nested objects
} else if (key === "allowSkip" && obj[key] === "Yes") {
obj[key] = "No"; // Update "allowSkip" to "No"
}
}
};

updateAllowSkipRecursive(updatedData);

return updatedData;
};

const setLessonData = async (id) => {
let resultData = await courseRegistryService.getOne({
id: id,
Expand All @@ -60,7 +82,9 @@ export default function LessonList({ footerLinks }) {
? instructionData?.instructions
: {},
};
setLesson(newData);

const updatedAssessmentData = await updateAllowSkipProperty(newData);
setLesson(updatedAssessmentData);
};

React.useEffect(async () => {
Expand Down

0 comments on commit f66f2d1

Please sign in to comment.