Navigation rework, added prompt edit to components that were missing
This commit is contained in:
@@ -79,8 +79,7 @@ const evaluateSpeakingExercise = async (
|
||||
|
||||
formData.append("audio", audioFile, "audio.wav");
|
||||
|
||||
const evaluationQuestion =
|
||||
`${exercise.text.replaceAll("\n", "")}` + (exercise.prompts.length > 0 ? `You should talk about: ${exercise.prompts.join(", ")}` : "");
|
||||
const evaluationQuestion = `${exercise.text.replaceAll("\n", "")}` + (exercise.prompts.length > 0 ? `You should talk about: ${exercise.prompts.join(", ")}` : "");
|
||||
formData.append("question", evaluationQuestion);
|
||||
formData.append("id", id);
|
||||
formData.append("task", task.toString());
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import {Exercise} from "@/interfaces/exam";
|
||||
import {Stat} from "@/interfaces/user";
|
||||
import {uniq} from "lodash";
|
||||
import {groupBySession} from "./stats";
|
||||
import { Module } from "@/interfaces";
|
||||
import { Exercise } from "@/interfaces/exam";
|
||||
import { Stat } from "@/interfaces/user";
|
||||
import { uniq } from "lodash";
|
||||
import { groupBySession } from "./stats";
|
||||
|
||||
export const MODULE_ARRAY: Module[] = ["reading", "listening", "writing", "speaking", "level"];
|
||||
|
||||
export const moduleLabels: {[key in Module]: string} = {
|
||||
export const moduleLabels: { [key in Module]: string } = {
|
||||
listening: "Listening",
|
||||
reading: "Reading",
|
||||
speaking: "Speaking",
|
||||
@@ -14,7 +14,7 @@ export const moduleLabels: {[key in Module]: string} = {
|
||||
level: "Level",
|
||||
};
|
||||
|
||||
export const sortByModule = (a: {module: Module; [key: string]: any}, b: {module: Module; [key: string]: any}) => {
|
||||
export const sortByModule = (a: { module: Module;[key: string]: any }, b: { module: Module;[key: string]: any }) => {
|
||||
return MODULE_ARRAY.findIndex((x) => a.module === x) - MODULE_ARRAY.findIndex((x) => b.module === x);
|
||||
};
|
||||
|
||||
@@ -26,15 +26,51 @@ export const countExercises = (exercises: Exercise[]) => {
|
||||
const lengthMap = exercises.map((e) => {
|
||||
if (e.type === "multipleChoice") return e.questions.length;
|
||||
if (e.type === "interactiveSpeaking") return e.prompts.length;
|
||||
if (e.type === "fillBlanks") return e.words.length;
|
||||
if (e.type === "writeBlanks") return e.solutions.length;
|
||||
if (e.type === "fillBlanks") return e.solutions.length;
|
||||
if (e.type === "writeBlanks") return e.solutions.length
|
||||
if (e.type === "matchSentences") return e.sentences.length;
|
||||
if (e.type === "trueFalse") return e.questions.length;
|
||||
return 1;
|
||||
});
|
||||
|
||||
return lengthMap.reduce((accumulator, current) => accumulator + current, 0);
|
||||
};
|
||||
}
|
||||
|
||||
export const countCurrentExercises = (
|
||||
exercises: Exercise[],
|
||||
exerciseIndex: number,
|
||||
questionIndex?: number
|
||||
) => {
|
||||
return exercises.reduce((acc, exercise, index) => {
|
||||
if (index > exerciseIndex) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
|
||||
if (exercise.type === "multipleChoice") {
|
||||
if (index === exerciseIndex && questionIndex !== undefined) {
|
||||
count = questionIndex + 1;
|
||||
} else {
|
||||
count = exercise.questions!.length;
|
||||
}
|
||||
} else if (exercise.type === "interactiveSpeaking") {
|
||||
count = exercise.prompts.length;
|
||||
} else if (exercise.type === "fillBlanks") {
|
||||
count = exercise.solutions.length;
|
||||
} else if (exercise.type === "writeBlanks") {
|
||||
count = exercise.solutions.length;
|
||||
} else if (exercise.type === "matchSentences") {
|
||||
count = exercise.sentences.length;
|
||||
} else if (exercise.type === "trueFalse") {
|
||||
count = exercise.questions.length;
|
||||
} else {
|
||||
count = 1;
|
||||
}
|
||||
|
||||
return acc + count;
|
||||
}, 0);
|
||||
};
|
||||
|
||||
export const countFullExams = (stats: Stat[]) => {
|
||||
const sessionExams = groupBySession(stats);
|
||||
|
||||
13
src/utils/wdyr.ts
Normal file
13
src/utils/wdyr.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/// <reference types="@welldone-software/why-did-you-render" />
|
||||
|
||||
import React from "react";
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
const whyDidYouRender = require("@welldone-software/why-did-you-render");
|
||||
whyDidYouRender(React, {
|
||||
trackAllPureComponents: true,
|
||||
trackHooks: true,
|
||||
logOwnerReasons: true,
|
||||
collapseGroups: true,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user