import { useState } from 'react'; import { highlightC } from '../training/cSyntaxHighlight.js'; export function ExamPanel({ exam, language }) { const [student, setStudent] = useState(''), [code, setCode] = useState(''); const { t } = exam; const locale = language === 'fr' ? 'fr' : 'en'; return
{!exam.auth ?
{ event.preventDefault(); if (await exam.login(student, code)) setCode(''); }}>
: <> {exam.quizPending ?

{t('Commencez par le quiz. Les exercices s’ouvriront quand vous l’aurez terminé.', 'Start with the quiz. The exercises open once you finish it.')}

: exam.auth.exam.exercises.map(item => )} {!exam.auth.submissionAvailable &&

{t('L’enseignant doit encore configurer l’envoi des copies.', 'The teacher still needs to configure submissions.')}

} {exam.activity.syncError &&

{t('Journal non synchronisé. Une nouvelle tentative sera faite au retour de la connexion.', 'Activity log not synced. It will be retried when the connection returns.')}

} } {exam.notice &&

{exam.notice}

} {exam.storageError &&

{t('Stockage indisponible : téléchargez votre fichier .c avant de fermer cette page.', 'Storage unavailable: download your .c file before closing this page.')}

}
; } // Shown in place of the editor until the student finishes the quiz; it cannot be reopened afterwards. export function ExamQuiz({ exam }) { const [confirming, setConfirming] = useState(false); const { t, quizAnswers: answers } = exam; const questions = exam.auth.exam.quiz; const missing = questions.filter(item => !answers[item.id]?.trim()).length; return
{t(`Quiz — ${questions.length} questions`, `Quiz — ${questions.length} questions`)}

{t('Répondez aux questions puis cliquez sur « Terminer le quiz ». Vos réponses sont alors envoyées à l’enseignant et le quiz n’est plus accessible ; les exercices s’ouvrent ensuite.', 'Answer the questions, then click “Finish quiz”. Your answers are sent to the teacher and the quiz closes; the exercises open next.')}

    {questions.map((item, index) =>
  1. {t(`Question ${index + 1}`, `Question ${index + 1}`)}{item.question} {/* highlightC escapes the source; the only markup is its token spans, as in the editor. */} {item.code &&
    }
    {item.choices ? item.choices.map(choice => ) :