Improved the solutions to be more mobile friendly

This commit is contained in:
Tiago Ribeiro
2023-04-20 22:55:24 +01:00
parent 02d76e4c3c
commit ed11d6f9d6
6 changed files with 41 additions and 21 deletions

View File

@@ -52,8 +52,8 @@ function Question({
return ( return (
<div className="flex flex-col items-center gap-4"> <div className="flex flex-col items-center gap-4">
<span>{prompt}</span> <span className="text-center">{prompt}</span>
<div className="grid grid-cols-4 gap-4 place-items-center"> <div className="grid grid-rows-4 md:grid-rows-1 md:grid-cols-4 gap-4 place-items-center">
{variant === "image" && {variant === "image" &&
options.map((option) => ( options.map((option) => (
<div <div
@@ -117,8 +117,8 @@ export default function MultipleChoice({id, prompt, type, questions, onNext, onB
return ( return (
<> <>
<div className="flex flex-col items-center gap-8"> <div className="flex flex-col items-center gap-4">
<span className="text-lg font-medium text-center px-48">{prompt}</span> <span className="text-base md:text-lg font-medium text-center px-2 md:px-4 lg:px-48">{prompt}</span>
{questionIndex < questions.length && ( {questionIndex < questions.length && (
<Question <Question
{...questions[questionIndex]} {...questions[questionIndex]}

View File

@@ -5,6 +5,7 @@ import Icon from "@mdi/react";
import clsx from "clsx"; import clsx from "clsx";
import reactStringReplace from "react-string-replace"; import reactStringReplace from "react-string-replace";
import {CommonProps} from "."; import {CommonProps} from ".";
import {Fragment} from "react";
export default function FillBlanksSolutions({prompt, solutions, text, userSolutions, onNext, onBack}: FillBlanksExercise & CommonProps) { export default function FillBlanksSolutions({prompt, solutions, text, userSolutions, onNext, onBack}: FillBlanksExercise & CommonProps) {
const renderLines = (line: string) => { const renderLines = (line: string) => {
@@ -44,26 +45,33 @@ export default function FillBlanksSolutions({prompt, solutions, text, userSoluti
return ( return (
<> <>
<div className="flex flex-col"> <div className="flex flex-col gap-4">
<span className="text-lg font-medium text-center px-48">{prompt}</span> <span className="text-base md:text-lg font-medium text-center px-2 md:px-4 lg:px-48">
{prompt.split("\\n").map((line, index) => (
<Fragment key={index}>
{line}
<br />
</Fragment>
))}
</span>
<span> <span>
{text.split("\\n").map((line) => ( {text.split("\\n").map((line, index) => (
<> <Fragment key={index}>
{renderLines(line)} {renderLines(line)}
<br /> <br />
</> </Fragment>
))} ))}
</span> </span>
</div> </div>
<div className="self-end flex gap-8"> <div className="self-end flex flex-col-reverse items-center w-full md:justify-between md:items-start md:flex-row gap-8">
<button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}> <button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}>
<div className="absolute left-4"> <div className="absolute left-4">
<Icon path={mdiArrowLeft} color="white" size={1} /> <Icon path={mdiArrowLeft} color="white" size={1} />
</div> </div>
Back Back
</button> </button>
<button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={() => onNext()}> <button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={onNext}>
Next Next
<div className="absolute right-4"> <div className="absolute right-4">
<Icon path={mdiArrowRight} color="white" size={1} /> <Icon path={mdiArrowRight} color="white" size={1} />

View File

@@ -5,12 +5,21 @@ import {CommonProps} from ".";
import {errorButtonStyle, infoButtonStyle} from "@/constants/buttonStyles"; import {errorButtonStyle, infoButtonStyle} from "@/constants/buttonStyles";
import {mdiArrowLeft, mdiArrowRight} from "@mdi/js"; import {mdiArrowLeft, mdiArrowRight} from "@mdi/js";
import Icon from "@mdi/react"; import Icon from "@mdi/react";
import {Fragment} from "react";
export default function MatchSentencesSolutions({options, prompt, sentences, userSolutions, onNext, onBack}: MatchSentencesExercise & CommonProps) { export default function MatchSentencesSolutions({options, prompt, sentences, userSolutions, onNext, onBack}: MatchSentencesExercise & CommonProps) {
return ( return (
<> <>
<div className="flex flex-col items-center gap-8"> <div className="flex flex-col items-center gap-8">
<span className="text-lg font-medium text-center px-48">{prompt}</span> <span className="text-base md:text-lg font-medium text-center px-2 md:px-4 lg:px-48">
{prompt.split("\\n").map((line, index) => (
<Fragment key={index}>
{line}
<br />
</Fragment>
))}
</span>
<div className="grid grid-cols-2 gap-16 place-items-center"> <div className="grid grid-cols-2 gap-16 place-items-center">
<div className="flex flex-col gap-1"> <div className="flex flex-col gap-1">
{sentences.map(({sentence, id, color, solution}) => ( {sentences.map(({sentence, id, color, solution}) => (
@@ -54,14 +63,14 @@ export default function MatchSentencesSolutions({options, prompt, sentences, use
</div> </div>
</div> </div>
<div className="self-end flex gap-8"> <div className="self-end flex flex-col-reverse items-center w-full md:justify-between md:items-start md:flex-row gap-8">
<button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}> <button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}>
<div className="absolute left-4"> <div className="absolute left-4">
<Icon path={mdiArrowLeft} color="white" size={1} /> <Icon path={mdiArrowLeft} color="white" size={1} />
</div> </div>
Back Back
</button> </button>
<button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={() => onNext()}> <button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={onNext}>
Next Next
<div className="absolute right-4"> <div className="absolute right-4">
<Icon path={mdiArrowRight} color="white" size={1} /> <Icon path={mdiArrowRight} color="white" size={1} />

View File

@@ -105,8 +105,8 @@ export default function MultipleChoice({prompt, questions, userSolutions, onNext
return ( return (
<> <>
<div className="flex flex-col items-center gap-8"> <div className="flex flex-col items-center gap-4">
<span className="text-lg font-medium text-center px-48">{prompt}</span> <span className="text-base md:text-lg font-medium text-center px-2 md:px-4 lg:px-48">{prompt}</span>
{questionIndex < questions.length && ( {questionIndex < questions.length && (
<Question <Question
{...questions[questionIndex]} {...questions[questionIndex]}
@@ -115,7 +115,8 @@ export default function MultipleChoice({prompt, questions, userSolutions, onNext
/> />
)} )}
</div> </div>
<div className="self-end flex gap-8">
<div className="self-end flex flex-col-reverse items-center w-full md:justify-between md:items-start md:flex-row gap-8">
<button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={back}> <button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={back}>
<div className="absolute left-4"> <div className="absolute left-4">
<Icon path={mdiArrowLeft} color="white" size={1} /> <Icon path={mdiArrowLeft} color="white" size={1} />

View File

@@ -91,14 +91,14 @@ export default function WriteBlanksSolutions({
</span> </span>
</div> </div>
<div className="self-end flex gap-8"> <div className="self-end flex flex-col-reverse items-center w-full md:justify-between md:items-start md:flex-row gap-8">
<button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}> <button className={clsx("btn btn-wide gap-4 relative text-white", errorButtonStyle)} onClick={onBack}>
<div className="absolute left-4"> <div className="absolute left-4">
<Icon path={mdiArrowLeft} color="white" size={1} /> <Icon path={mdiArrowLeft} color="white" size={1} />
</div> </div>
Back Back
</button> </button>
<button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={() => onNext()}> <button className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)} onClick={onNext}>
Next Next
<div className="absolute right-4"> <div className="absolute right-4">
<Icon path={mdiArrowRight} color="white" size={1} /> <Icon path={mdiArrowRight} color="white" size={1} />

View File

@@ -71,7 +71,7 @@ export default function Listening({exam, showSolutions = false, onFinish}: Props
return ( return (
<> <>
<div className="w-full h-full relative flex flex-col gap-8 items-center justify-center p-8 px-16 overflow-hidden"> <div className="w-full relative flex flex-col gap-8 items-center justify-center p-8 px-16 overflow-hidden">
{renderAudioPlayer()} {renderAudioPlayer()}
{exerciseIndex > -1 && {exerciseIndex > -1 &&
exerciseIndex < exam.exercises.length && exerciseIndex < exam.exercises.length &&
@@ -82,7 +82,9 @@ export default function Listening({exam, showSolutions = false, onFinish}: Props
showSolutions && showSolutions &&
renderSolution(exam.exercises[exerciseIndex], nextExercise, previousExercise)} renderSolution(exam.exercises[exerciseIndex], nextExercise, previousExercise)}
{exerciseIndex === -1 && ( {exerciseIndex === -1 && (
<button className={clsx("btn btn-wide gap-4 relative text-white self-end", infoButtonStyle)} onClick={() => nextExercise()}> <button
className={clsx("btn md:btn-wide w-full gap-4 relative text-white self-end", infoButtonStyle)}
onClick={() => nextExercise()}>
Next Next
<div className="absolute right-4"> <div className="absolute right-4">
<Icon path={mdiArrowRight} color="white" size={1} /> <Icon path={mdiArrowRight} color="white" size={1} />