Skip to content
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

Assesment/multipleoption #1067

Merged
merged 20 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6177f13
assement change
saloni-080601 Oct 9, 2023
464300f
assesment/multiple changeing
saloni-080601 Oct 16, 2023
946533f
checkbox_and_radiobutton_functionality_change
Tamannatanwa Oct 17, 2023
c024ac9
Completed the logic part for the multiple choice assessement.
amansharmma Oct 23, 2023
0da8c3d
Fixed the assessment bug and implementing the multiple choice section.
amansharmma Nov 5, 2023
143775b
Worked for the multiple option functionality
amansharmma Nov 9, 2023
5281374
Updated assessement
amansharmma Nov 16, 2023
48a3706
Implemented the MCQ & SCQ for the Assessment.
amansharmma Nov 17, 2023
24795ac
Resolved Conflicts.
amansharmma Nov 18, 2023
9205ed8
Implemented the Img section for the MCQ.
amansharmma Nov 22, 2023
53004eb
Fixed some style part, Resolved conflicts, Fixed some Feedbacks, Adde…
amansharmma Nov 28, 2023
7e443f4
Resolved Conflicts.
amansharmma Nov 28, 2023
d9375e3
Merge branch 'dev' of https://github.com/navgurukul/bhanwari-devi int…
amansharmma Nov 30, 2023
33e6833
Updating the design & Functionality for the assessmets.
amansharmma Dec 2, 2023
9c18cba
Fixed bug
amansharmma Dec 5, 2023
36045c0
Fixed some Feedback Parts.
amansharmma Dec 8, 2023
fbc7f11
Fixed Styling, Functionality.
amansharmma Dec 13, 2023
ae95ae5
working on checkbox and radio button design in Assesments
Tamannatanwa Dec 25, 2023
5c4bc2b
adding style to radio CancelIcon
Tamannatanwa Dec 26, 2023
5f41639
Merge pull request #1089 from navgurukul/Assesment/Checkbox
amansharmma Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Class/ClassForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function ClassForm({
}
axios({
method: METHODS.GET,
url: `${process.env.REACT_APP_MERAKI_URL}/courses/${courseId}/exercises`,
url: `${process.env.REACT_APP_MERAKI_URL}/courses/${courseId}/exercises/v2`,
headers: {
accept: "application/json",
"version-code": versionCode,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Class/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function Class({ classToEdit, indicator }) {
}
axios({
method: METHODS.GET,
url: `${process.env.REACT_APP_MERAKI_URL}/courses/${courseId}/exercises`,
url: `${process.env.REACT_APP_MERAKI_URL}/courses/${courseId}/exercises/v2`,
headers: {
accept: "application/json",
"version-code": versionCode,
Expand Down
5 changes: 3 additions & 2 deletions src/components/Course/redux/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ export const getCourses = () => {
export const getCourseContent = (data) => {
const { courseId, lang, versionCode, user } = data;
return axios({
url: `${process.env.REACT_APP_MERAKI_URL}/courses/${courseId}/exercises?lang=${lang}`,
url: `${process.env.REACT_APP_MERAKI_URL}/courses/${courseId}/exercises/v2?lang=${lang}`,
method: METHODS.GET,
headers: {
"version-code": versionCode,
accept: "application/json",
Authorization: user?.data?.token ?? localStorage.getItem("studentAuthToken"),
Authorization:
user?.data?.token ?? localStorage.getItem("studentAuthToken"),
},
// headers: HeaderFactory(token),
});
Expand Down
53 changes: 26 additions & 27 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,31 +209,32 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => {
)}
</Box>

{localStorage.getItem("studentAuth") ?
<a
href={`http://localhost:8080/login/?studentAuth=${localStorage.getItem("studentAuthToken")}`}
target="_blank"
style={{ textDecoration: "none", color:"black" }}
>
<Typography
variant="subtitle1"
sx={{
height: "36px",
padding: "6px 16px",
display: "flex",
alignItems: "center",
"&:hover": {
backgroundColor: "#E9F5E9",
borderRadius: "8px",
},
}}
>
Scratch
<OpenInNewIcon style={{ color: "Black", paddingLeft: "9px" }} />

</Typography>
</a>
: (
{localStorage.getItem("studentAuth") ? (
<a
href={`http://localhost:8080/login/?studentAuth=${localStorage.getItem(
"studentAuthToken"
amansharmma marked this conversation as resolved.
Show resolved Hide resolved
)}`}
target="_blank"
style={{ textDecoration: "none", color: "black" }}
>
<Typography
variant="subtitle1"
sx={{
height: "36px",
padding: "6px 16px",
display: "flex",
alignItems: "center",
"&:hover": {
backgroundColor: "#E9F5E9",
komalahire marked this conversation as resolved.
Show resolved Hide resolved
borderRadius: "8px",
},
}}
>
Scratch
<OpenInNewIcon style={{ color: "Black", paddingLeft: "9px" }} />
</Typography>
</a>
) : (
<>
{!leftDrawer && (
<Box sx={{ flexGrow: 0, display: { xs: "none", md: "flex" } }}>
Expand All @@ -250,8 +251,6 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => {
)}
</>
)}


</>
);
};
Expand Down
9 changes: 3 additions & 6 deletions src/components/PathwayCourse/C4CApathway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ function C4CApathway() {
const history = useHistory();

useEffect(() => {

if(localStorage.getItem("studentAuth")===null)
history.push("/login");
if (localStorage.getItem("studentAuth") === null) history.push("/login");
amansharmma marked this conversation as resolved.
Show resolved Hide resolved

axios({
method: METHODS.GET,
Expand All @@ -43,8 +41,7 @@ if(localStorage.getItem("studentAuth")===null)
},
})
.then((response) => {
if(pathway?.length<1)
setPathway(response?.data);
if (pathway?.length < 1) setPathway(response?.data);
})
.catch((err) => {});
}, []);
Expand Down Expand Up @@ -208,4 +205,4 @@ if(localStorage.getItem("studentAuth")===null)
</Container>
);
}
export default C4CApathway;
export default C4CApathway;
11 changes: 7 additions & 4 deletions src/components/PathwayCourse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ function PathwayCourse() {
url: `${process.env.REACT_APP_MERAKI_URL}/certificate?pathway_code=${certificateCode}`,
headers: {
accept: "application/json",
Authorization: user?.data?.token || localStorage.getItem("studentAuthToken"),
Authorization:
user?.data?.token || localStorage.getItem("studentAuthToken"),
},
})
.then((response) => {
Expand Down Expand Up @@ -209,7 +210,8 @@ function PathwayCourse() {
url: `${process.env.REACT_APP_MERAKI_URL}/teacher/checking`,
headers: {
accept: "application/json",
Authorization: user?.data?.token || localStorage.getItem("studentAuthToken"),
Authorization:
user?.data?.token || localStorage.getItem("studentAuthToken"),
},
})
.then((response) => {
Expand All @@ -232,7 +234,8 @@ function PathwayCourse() {
url: `${process.env.REACT_APP_MERAKI_URL}/pathways/${pathwayId}/completePortion`,
headers: {
accept: "application/json",
Authorization: user?.data?.token || localStorage.getItem("studentAuthToken"),
Authorization:
user?.data?.token || localStorage.getItem("studentAuthToken"),
},
})
.then((response) => {
Expand Down Expand Up @@ -439,7 +442,7 @@ function PathwayCourse() {
<>
<PathwayCards
userEnrolledClasses={userEnrolledClasses}
data={pathwayCourse.data}
data={pathwayCourse?.data}
/>
</>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function LastCoursePage({ C4CALastPage }) {
const isActive = useMediaQuery("(max-width:" + breakpoints.values.sm + "px)");
const history = useHistory();
const params = useParams();
const studentAuthToken = localStorage.getItem("studentAuthToken");
const studentAuthToken = localStorage.getItem("studentAuthToken");
return (
<>
<Container maxWidth="lg" align="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useEffect, useState } from "react";
import { Grid, Typography, Box, Button, Paper, Stack } from "@mui/material";
import useStyles from "../../styles";
import get from "lodash/get";

import { Radio, Checkbox, FormControlLabel, RadioGroup } from "@mui/material";
import CancelIcon from "@mui/icons-material/Cancel";
import DOMPurify from "dompurify";
import { fi } from "date-fns/locale";
function UnsafeHTML(props) {
komalahire marked this conversation as resolved.
Show resolved Hide resolved
const { html, Container, ...otherProps } = props;
const sanitizedHTML = DOMPurify.sanitize(html);
Expand Down Expand Up @@ -44,8 +46,12 @@ const AssessmentContent = ({
setTriedAgain,
submitDisable,
submitAssessment,
type,
setType,
Partially_ans,
setWrongAnswer,
finalDesicion,
}) => {

const classes = useStyles();
if (content.component === "header") {
if (triedAgain > 1) {
Expand Down Expand Up @@ -90,9 +96,24 @@ const AssessmentContent = ({
</Box>
);
} else {
const Partially_retry = DOMPurify.sanitize(get(Partially_ans, "value"));
return (
<Grid container spacing={2} mt={3} mb={10}>
<Grid item xs={12} sm={6}>
<>
{(submit &&
((finalDesicion && finalDesicion === "partially correct") ||
finalDesicion === "partially incorrect")) ||
finalDesicion === "incorrect" ? (
<UnsafeHTML
Container={Typography}
variant="body1"
html={Partially_retry}
/>
) : (
""
)}

<Grid container spacing={2} mt={1} mb={10}>
{/* <Grid item xs={12} sm={6}>
<Button
variant="outlined"
disabled
Expand All @@ -106,21 +127,22 @@ const AssessmentContent = ({
See Answer & Explanation
</Typography>
</Button>
</Grid> */}
<Grid item xs={12} sm={6}>
<Button
variant="outlined"
fullWidth
onClick={() => {
setAnswer([]);
setSubmit();
setSubmitDisable();
}}
>
<Typography variant="subtitle2">Re-try</Typography>
</Button>
</Grid>
</Grid>
<Grid item xs={12} sm={6}>
<Button
variant="outlined"
fullWidth
onClick={() => {
setAnswer();
setSubmit();
setSubmitDisable();
}}
>
<Typography variant="subtitle2">Re-try</Typography>
</Button>
</Grid>
</Grid>
</>
);
}
}
Expand Down Expand Up @@ -179,7 +201,15 @@ const AssessmentContent = ({
return (
<Box sx={{ m: "32px 0px" }}>
{Object.values(content.value).map((item, index) => {
const text = DOMPurify.sanitize(item.value.slice(2));
const text = DOMPurify.sanitize(item.value);
const isChecked = answer?.includes(item.id);
const isRadioChecked =
answer?.length === 1 && answer?.includes(item.id);

const isValuePresent = solution?.some(
(sitem) => sitem.value === item.id
);

return (
<Paper
elevation={3}
Expand All @@ -191,24 +221,80 @@ const AssessmentContent = ({
}}
className={
submit
? correct
? answer === item.id && classes.correctAnswer
: triedAgain === 1
? answer === item.id && classes.inCorrectAnswer
: (answer == item.id && classes.inCorrectAnswer) ||
(solution == item.id && classes.correctAnswer)
: answer == item.id && classes.option
? answer?.includes(item.id) && isValuePresent
? classes.correctAnswer
: answer?.includes(item.id)
? classes.inCorrectAnswer
: ""
: ""
}
onClick={() => !submitDisable && setAnswer(item.id)}
onClick={() => {
if (type === "single") {
if (submit === true) {
return;
} else {
setAnswer([item.id]);
}
} else {
if (submit === true) {
return;
} else {
const updatedAnswer = isChecked
? answer.filter((id) => id !== item.id)
: [...answer, item.id];
setAnswer();
setAnswer(updatedAnswer);
}
}
}}
>
<Stack direction="row" gap={1}>
<Typography variant="body1">
{item.value.slice(0, 2)}
</Typography>
<UnsafeHTML
Container={Typography}
variant="body1"
html={text}
<FormControlLabel
control={
type === "single" ? (
submit ? (
answer?.includes(item.id) && isValuePresent ? (
<Radio
checked={isRadioChecked}
disabled={submit && true}
amansharmma marked this conversation as resolved.
Show resolved Hide resolved
/>
) : answer?.includes(item.id) ? (
<CancelIcon
sx={{ color: "red", marginLeft: 1, marginRight: 1 }}
/>
) : (
<Radio
checked={isRadioChecked}
disabled={submit && true}
/>
)
) : (
<Radio
checked={isRadioChecked}
disabled={submit && true}
/>
)
) : submit ? (
answer?.includes(item.id) && isValuePresent ? (
<Checkbox checked={isChecked} />
) : answer?.includes(item.id) ? (
<CancelIcon
sx={{ color: "red", marginLeft: 1, marginRight: 1 }}
/>
) : (
<Checkbox checked={isChecked} />
)
) : (
<Checkbox checked={isChecked} disabled={submit && true} />
)
}
label={
<UnsafeHTML
Container={Typography}
variant="body1"
html={text}
/>
}
/>
</Stack>
</Paper>
Expand All @@ -218,7 +304,9 @@ const AssessmentContent = ({
);
}
if (content.component === "solution") {
setSolution(content.value);
setSolution(content?.correct_options_value);
setType(content?.type);
setWrongAnswer();
}
return "";
};
Expand Down
Loading
Loading