import React, { useContext } from 'react';
import classnames from 'classnames';
import { QuestionContext } from '../../context/QuestionContext';
import { useIsStudentsExamineExamPage } from '../isExamineExamPageHook';
import { ResultsContext } from '../../context/ResultsContext';
import { useExamTranslation } from '../../../i18n';
function QuestionScoresContainer({ answers, displayNumber, children, multilineAnswer, questionId }) {
    var _a;
    const { displayNumber: topLevelDisplayNumber } = useContext(QuestionContext);
    const isStudentsExamineExamPage = useIsStudentsExamineExamPage();
    const fullDisplayNumber = displayNumber ? `${topLevelDisplayNumber}.${displayNumber === null || displayNumber === void 0 ? void 0 : displayNumber.replace('.', '')}` : undefined;
    const { answersByQuestionId } = useContext(ResultsContext);
    const isNonAnswer = questionId && answersByQuestionId ? (_a = answersByQuestionId[questionId]) === null || _a === void 0 ? void 0 : _a.answerNonAnswer : false;
    const { t } = useExamTranslation();
    if (isStudentsExamineExamPage) {
        return null;
    }
    const showSup = answers.length > 1 && displayNumber;
    return (React.createElement("span", { className: classnames('e-result-scorecount', 'e-float-right', {
            'e-result-scorecount-multiline-answer': multilineAnswer
        }), id: fullDisplayNumber },
        isNonAnswer && React.createElement("div", { className: "non-answer" }, t('grading.non-answer-not-graded')),
        React.createElement("span", { className: "e-result-scorecount-border-wrap" },
            showSup && (React.createElement("sup", { className: "e-result-scorecount-sup e-mrg-r-1", "aria-hidden": "true" }, displayNumber)),
            children)));
}
export default React.memo(QuestionScoresContainer);
//# sourceMappingURL=QuestionScoresContainer.js.map