Skip to content
Merged
Changes from all commits
Commits
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
23 changes: 11 additions & 12 deletions client/src/components/questions/SingleQuestionStudent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import apiUtil from "../../utils/apiUtil";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";

// Store the answers payload stored in the server.
function SingleQuestionStudent(props) {
const navigate = useNavigate();
const dispatch = useDispatch();
Expand All @@ -16,21 +17,19 @@ function SingleQuestionStudent(props) {
const answers = props.question.answers
? Object.values(props.question.answers)
: [];
const [radioOptionSelected, setRadioOptionSelected] = useState([
false,
false,
false,
false,
]);

// Use the content array to determine the length the array needs to be.
const [radioOptionSelected, setRadioOptionSelected] = useState(
Array(content.length).fill(false)
);
const [checkboxOptionsSelected, setCheckboxOptionsSelected] = useState(
Array(content.length).fill(false)
);

const [radioChecked, setRadioChecked] = useState();
const [checkboxOptionsSelected, setCheckboxOptionsSelected] = useState([
false,
false,
false,
false,
]);
const [submissionError, setSubmissionError] = useState();

// Handle the submission of a question
const createResponse = async (e) => {
e.preventDefault();
if (props.question.type === "multiple choice" && radioChecked == null) {
Expand Down
Loading