Only hooked up the section state had forgot to plugin into Header's isEvaluationEnabled
This commit is contained in:
@@ -106,7 +106,7 @@ const FillBlanksLetters: React.FC<{ exercise: FillBlanksExercise; sectionId: num
|
|||||||
onPractice: () => {
|
onPractice: () => {
|
||||||
const updatedExercise = {
|
const updatedExercise = {
|
||||||
...local,
|
...local,
|
||||||
//isPractice: !isPractice,
|
isPractice: !local.isPractice,
|
||||||
};
|
};
|
||||||
const newState = { ...section };
|
const newState = { ...section };
|
||||||
newState.exercises = newState.exercises.map((ex) =>
|
newState.exercises = newState.exercises.map((ex) =>
|
||||||
@@ -242,8 +242,6 @@ const FillBlanksLetters: React.FC<{ exercise: FillBlanksExercise; sectionId: num
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [answers, blanksState.blanks, blanksState.textMode])
|
}, [answers, blanksState.blanks, blanksState.textMode])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
setEditingAlert(editing, setAlerts);
|
setEditingAlert(editing, setAlerts);
|
||||||
}, [editing])
|
}, [editing])
|
||||||
@@ -266,7 +264,7 @@ const FillBlanksLetters: React.FC<{ exercise: FillBlanksExercise; sectionId: num
|
|||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
setEditing={setEditing}
|
setEditing={setEditing}
|
||||||
onPractice={handlePractice}
|
onPractice={handlePractice}
|
||||||
isEvaluationEnabled={true}//local.isPractice}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
{!blanksState.textMode && <Card className="p-4">
|
{!blanksState.textMode && <Card className="p-4">
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ const FillBlanksMC: React.FC<{ exercise: FillBlanksExercise; sectionId: number }
|
|||||||
onPractice={handlePractice}
|
onPractice={handlePractice}
|
||||||
setEditing={setEditing}
|
setEditing={setEditing}
|
||||||
onBlankRemove={handleBlankRemove}
|
onBlankRemove={handleBlankRemove}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
>
|
>
|
||||||
{!blanksState.textMode && selectedBlankId && (
|
{!blanksState.textMode && selectedBlankId && (
|
||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ const WriteBlanksFill: React.FC<{ exercise: WriteBlanksExercise; sectionId: numb
|
|||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
onPractice={handlePractice}
|
onPractice={handlePractice}
|
||||||
setEditing={setEditing}
|
setEditing={setEditing}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
>
|
>
|
||||||
{!blanksState.textMode && (
|
{!blanksState.textMode && (
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ interface Props {
|
|||||||
onDiscard: () => void;
|
onDiscard: () => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onPractice: () => void;
|
onPractice: () => void;
|
||||||
isEvaluationEnabled: boolean;
|
isEvaluationEnabled?: boolean;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ const MatchSentences: React.FC<{ exercise: MatchSentencesExercise, sectionId: nu
|
|||||||
handleDelete={handleDelete}
|
handleDelete={handleDelete}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowReference(!showReference)}
|
onClick={() => setShowReference(!showReference)}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ const UnderlineMultipleChoice: React.FC<{exercise: MultipleChoiceExercise, secti
|
|||||||
handleDelete={handleDelete}
|
handleDelete={handleDelete}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
/>
|
/>
|
||||||
{alerts.length > 0 && <Alert className="mb-6" alerts={alerts} />}
|
{alerts.length > 0 && <Alert className="mb-6" alerts={alerts} />}
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ const MultipleChoice: React.FC<MultipleChoiceProps> = ({ exercise, sectionId, op
|
|||||||
handleDelete={handleDelete}
|
handleDelete={handleDelete}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
/>
|
/>
|
||||||
{alerts.length > 0 && <Alert className="mb-6" alerts={alerts} />}
|
{alerts.length > 0 && <Alert className="mb-6" alerts={alerts} />}
|
||||||
<Card className="mb-6">
|
<Card className="mb-6">
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ const InteractiveSpeaking: React.FC<Props> = ({ sectionId, exercise, module = "s
|
|||||||
handleEdit={handleEdit}
|
handleEdit={handleEdit}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
module="speaking"
|
module="speaking"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ const Speaking1: React.FC<Props> = ({ sectionId, exercise, module = "speaking" }
|
|||||||
handleEdit={handleEdit}
|
handleEdit={handleEdit}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
module="speaking"
|
module="speaking"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ const Speaking2: React.FC<Props> = ({ sectionId, exercise, module = "speaking" }
|
|||||||
handleEdit={handleEdit}
|
handleEdit={handleEdit}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
module="speaking"
|
module="speaking"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ const WriteBlanks: React.FC<{ sectionId: number; exercise: WriteBlanksExercise;
|
|||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handleDelete={handleDelete}
|
handleDelete={handleDelete}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
/>
|
/>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{alerts.length > 0 && <Alert alerts={alerts} />}
|
{alerts.length > 0 && <Alert alerts={alerts} />}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ const Writing: React.FC<Props> = ({ sectionId, exercise, module, index }) => {
|
|||||||
handleEdit={handleEdit}
|
handleEdit={handleEdit}
|
||||||
handleDiscard={handleDiscard}
|
handleDiscard={handleDiscard}
|
||||||
handlePractice={handlePractice}
|
handlePractice={handlePractice}
|
||||||
isEvaluationEnabled={true}
|
isEvaluationEnabled={!local.isPractice}
|
||||||
module={"writing"}
|
module={"writing"}
|
||||||
/>
|
/>
|
||||||
{alerts.length !== 0 && <Alert alerts={alerts} />}
|
{alerts.length !== 0 && <Alert alerts={alerts} />}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Module } from "@/interfaces";
|
import { Module } from "@/interfaces";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { MdDelete, MdEdit, MdEditOff, MdRefresh, MdSave} from "react-icons/md";
|
import { MdDelete, MdEdit, MdEditOff, MdRefresh, MdSave } from "react-icons/md";
|
||||||
import { HiOutlineClipboardCheck, HiOutlineClipboardList} from "react-icons/hi";
|
import { HiOutlineClipboardCheck, HiOutlineClipboardList } from "react-icons/hi";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export const rootReducer = (
|
|||||||
state: ExamEditorStore,
|
state: ExamEditorStore,
|
||||||
action: Action
|
action: Action
|
||||||
): Partial<ExamEditorStore> => {
|
): Partial<ExamEditorStore> => {
|
||||||
console.log(action);
|
|
||||||
if (MODULE_ACTIONS.includes(action.type as any)) {
|
if (MODULE_ACTIONS.includes(action.type as any)) {
|
||||||
if (action.type === "REORDER_EXERCISES") {
|
if (action.type === "REORDER_EXERCISES") {
|
||||||
const updatedState = sectionReducer(state, action as SectionActions);
|
const updatedState = sectionReducer(state, action as SectionActions);
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export const moduleReducer = (
|
|||||||
|
|
||||||
case 'TOGGLE_SECTION':
|
case 'TOGGLE_SECTION':
|
||||||
const { sectionId } = action.payload;
|
const { sectionId } = action.payload;
|
||||||
console.log("TOGGLE SECTION TRIGGERED");
|
|
||||||
|
|
||||||
const prev = currentModuleState.sections;
|
const prev = currentModuleState.sections;
|
||||||
const updatedSections = prev.some(section => section.sectionId === sectionId)
|
const updatedSections = prev.some(section => section.sectionId === sectionId)
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ export const sectionReducer = (
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'UPDATE_SECTION_SINGLE_FIELD':{
|
case 'UPDATE_SECTION_SINGLE_FIELD':{
|
||||||
const { module, field, value, sectionId } = action.payload;
|
const { module, field, value, sectionId } = action.payload;
|
||||||
console.log(`Updating ${module}-${sectionId} ${field} to ${value}`);
|
|
||||||
return {
|
return {
|
||||||
modules: {
|
modules: {
|
||||||
...state.modules,
|
...state.modules,
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ const reorderSection = (exercises: Exercise[], startId: number): { exercises: Ex
|
|||||||
currentId += 1;
|
currentId += 1;
|
||||||
return exercise;
|
return exercise;
|
||||||
default:
|
default:
|
||||||
console.log("HERE IT IS");
|
|
||||||
return exercise;
|
return exercise;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -188,7 +187,6 @@ const reorderModule = (moduleState: ModuleState) => {
|
|||||||
let currentId = 1;
|
let currentId = 1;
|
||||||
let reorderedSections = moduleState.sections.map(section => {
|
let reorderedSections = moduleState.sections.map(section => {
|
||||||
let currentSection = section.state as ReadingPart | ListeningPart | LevelPart;
|
let currentSection = section.state as ReadingPart | ListeningPart | LevelPart;
|
||||||
console.log(currentSection.exercises);
|
|
||||||
let result = reorderSection(currentSection.exercises, currentId);
|
let result = reorderSection(currentSection.exercises, currentId);
|
||||||
currentId = result.lastId;
|
currentId = result.lastId;
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user