@digabi/exam-engine-core 19.12.1-alpha.2 → 19.12.1-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/__tests__/testExamRendering.js +2 -1
- package/dist/__tests__/testExamRendering.js.map +1 -1
- package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
- package/dist/assets/logo.png +0 -0
- package/dist/components/context/ResultsContext.js +1 -1
- package/dist/components/context/ResultsContext.js.map +1 -1
- package/dist/components/exam/StudentNameHeader.d.ts +8 -0
- package/dist/components/exam/StudentNameHeader.d.ts.map +1 -0
- package/dist/components/exam/StudentNameHeader.js +3 -0
- package/dist/components/exam/StudentNameHeader.js.map +1 -0
- package/dist/components/exam/UndoHistoryEntry.d.ts +19 -0
- package/dist/components/exam/UndoHistoryEntry.d.ts.map +1 -0
- package/dist/components/exam/UndoHistoryEntry.js +39 -0
- package/dist/components/exam/UndoHistoryEntry.js.map +1 -0
- package/dist/components/exam/UndoView.d.ts +35 -0
- package/dist/components/exam/UndoView.d.ts.map +1 -0
- package/dist/components/exam/UndoView.js +162 -0
- package/dist/components/exam/UndoView.js.map +1 -0
- package/dist/components/exam/internal/ErrorIndicator.js +1 -1
- package/dist/components/exam/internal/ErrorIndicator.js.map +1 -1
- package/dist/components/exam/undo-view.d.ts +36 -0
- package/dist/components/exam/undo-view.d.ts.map +1 -0
- package/dist/components/exam/undo-view.js +162 -0
- package/dist/components/exam/undo-view.js.map +1 -0
- package/dist/components/results/ChoiceAnswer.js +6 -5
- package/dist/components/results/ChoiceAnswer.js.map +1 -1
- package/dist/components/results/DropdownAnswer.d.ts +1 -1
- package/dist/components/results/DropdownAnswer.d.ts.map +1 -1
- package/dist/components/results/DropdownAnswer.js +23 -23
- package/dist/components/results/DropdownAnswer.js.map +1 -1
- package/dist/components/results/MultiLineAnswer.d.ts.map +1 -1
- package/dist/components/results/MultiLineAnswer.js +4 -1
- package/dist/components/results/MultiLineAnswer.js.map +1 -1
- package/dist/components/results/Question.d.ts.map +1 -1
- package/dist/components/results/Question.js +5 -4
- package/dist/components/results/Question.js.map +1 -1
- package/dist/components/results/QuestionTitle.d.ts.map +1 -1
- package/dist/components/results/QuestionTitle.js +7 -2
- package/dist/components/results/QuestionTitle.js.map +1 -1
- package/dist/components/results/Results.d.ts +1 -0
- package/dist/components/results/Results.d.ts.map +1 -1
- package/dist/components/results/Results.js +23 -5
- package/dist/components/results/Results.js.map +1 -1
- package/dist/components/results/Section.d.ts.map +1 -1
- package/dist/components/results/Section.js +2 -9
- package/dist/components/results/Section.js.map +1 -1
- package/dist/components/results/SingleLineAnswer.d.ts.map +1 -1
- package/dist/components/results/SingleLineAnswer.js +4 -1
- package/dist/components/results/SingleLineAnswer.js.map +1 -1
- package/dist/components/results/internal/QuestionAutoScore.d.ts +1 -1
- package/dist/components/results/internal/QuestionAutoScore.d.ts.map +1 -1
- package/dist/components/results/internal/QuestionAutoScore.js +5 -0
- package/dist/components/results/internal/QuestionAutoScore.js.map +1 -1
- package/dist/components/results/internal/QuestionScoresContainer.d.ts +1 -1
- package/dist/components/results/internal/QuestionScoresContainer.d.ts.map +1 -1
- package/dist/components/results/internal/QuestionScoresContainer.js +5 -0
- package/dist/components/results/internal/QuestionScoresContainer.js.map +1 -1
- package/dist/components/results/isExamFinishPageHook.d.ts +2 -0
- package/dist/components/results/isExamFinishPageHook.d.ts.map +1 -0
- package/dist/components/results/isExamFinishPageHook.js +7 -0
- package/dist/components/results/isExamFinishPageHook.js.map +1 -0
- package/dist/main-bundle.js +1 -1
- package/dist/main.css +1 -1
- package/package.json +3 -3
Binary file
|
@@ -17,7 +17,7 @@ export const withResultsContext = withContext(ResultsContext, ({ scores, doc, gr
|
|
17
17
|
};
|
18
18
|
});
|
19
19
|
export function findMultiChoiceFromGradingStructure(gradingStructure, id) {
|
20
|
-
const choiceGroups = gradingStructure.questions.filter(v => v.type === 'choicegroup');
|
20
|
+
const choiceGroups = (gradingStructure === null || gradingStructure === void 0 ? void 0 : gradingStructure.questions.filter(v => v.type === 'choicegroup')) || [];
|
21
21
|
for (let i = 0, length = choiceGroups.length; i < length; i++) {
|
22
22
|
const choiceGroup = choiceGroups[i];
|
23
23
|
for (let j = 0, choicesLength = choiceGroup.choices.length; j < choicesLength; j++) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResultsContext.js","sourceRoot":"","sources":["../../../src/components/context/ResultsContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAUpG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAY3C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAiB,EAAoB,CAAC,CAAA;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAC3C,cAAc,EACd,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE;IACzE,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAC1D,MAAM,iBAAiB,GAAG,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;IAC1E,MAAM,UAAU,GAAG,+BAA+B,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAA;IAEpH,OAAO;QACL,mBAAmB;QACnB,gBAAgB;QAChB,MAAM;QACN,UAAU;QACV,WAAW;QACX,aAAa;KACd,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,UAAU,mCAAmC,CACjD,gBAAkC,EAClC,EAAU;IAEV,MAAM,YAAY,GAAG,gBAAgB,
|
1
|
+
{"version":3,"file":"ResultsContext.js","sourceRoot":"","sources":["../../../src/components/context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AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,eAAO,MAAM,iBAAiB,UAAW,KAAK,sBAAwE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"StudentNameHeader.js","sourceRoot":"","sources":["../../../src/components/exam/StudentNameHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,6BAAK,SAAS,EAAC,0BAA0B,IAAE,KAAK,CAAC,WAAW,CAAO,CAAA"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export interface UndoHistoryEntryProps {
|
3
|
+
croppedAnswer: string;
|
4
|
+
minutesSinceAnswer: number;
|
5
|
+
answerIndex: number;
|
6
|
+
selected: boolean;
|
7
|
+
onChange: (index: number) => void;
|
8
|
+
characterCount: number;
|
9
|
+
screenshotCount: number;
|
10
|
+
}
|
11
|
+
export declare class UndoHistoryEntry extends React.PureComponent<UndoHistoryEntryProps> {
|
12
|
+
private entryInputRef;
|
13
|
+
private labelInputRef;
|
14
|
+
constructor(props: UndoHistoryEntryProps);
|
15
|
+
componentDidMount(): void;
|
16
|
+
private inputValueChanged;
|
17
|
+
render(): React.JSX.Element;
|
18
|
+
}
|
19
|
+
//# sourceMappingURL=UndoHistoryEntry.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UndoHistoryEntry.d.ts","sourceRoot":"","sources":["../../../src/components/exam/UndoHistoryEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC;IAC9E,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,aAAa,CAAmC;gBAE5C,KAAK,EAAE,qBAAqB;IAMjC,iBAAiB;IAMxB,OAAO,CAAC,iBAAiB,CAKxB;IAEM,MAAM;CAuBd"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { useExamTranslation } from '../../i18n';
|
3
|
+
export class UndoHistoryEntry extends React.PureComponent {
|
4
|
+
constructor(props) {
|
5
|
+
super(props);
|
6
|
+
this.inputValueChanged = () => {
|
7
|
+
this.props.onChange(this.props.answerIndex);
|
8
|
+
if (this.labelInputRef && this.labelInputRef.current) {
|
9
|
+
this.labelInputRef.current.scrollIntoView({ block: 'center' });
|
10
|
+
}
|
11
|
+
};
|
12
|
+
this.entryInputRef = React.createRef();
|
13
|
+
this.labelInputRef = React.createRef();
|
14
|
+
}
|
15
|
+
componentDidMount() {
|
16
|
+
if (this.entryInputRef.current && this.props.answerIndex === 0) {
|
17
|
+
this.entryInputRef.current.focus();
|
18
|
+
}
|
19
|
+
}
|
20
|
+
render() {
|
21
|
+
const { selected, croppedAnswer, characterCount, screenshotCount, answerIndex, minutesSinceAnswer } = this.props;
|
22
|
+
return (React.createElement("label", { ref: this.labelInputRef, className: "js-undo-history-entry" },
|
23
|
+
React.createElement("input", { type: "radio", className: "e-undo-view-entry-tab", name: "undoHistory", value: answerIndex, checked: selected, onChange: this.inputValueChanged, ref: this.entryInputRef }),
|
24
|
+
React.createElement(UndoEntry, { croppedAnswer: croppedAnswer, characterCount: characterCount, screenshotCount: screenshotCount, answerIndex: answerIndex, minutesSinceAnswer: minutesSinceAnswer })));
|
25
|
+
}
|
26
|
+
}
|
27
|
+
const UndoEntry = ({ croppedAnswer, characterCount, screenshotCount, answerIndex, minutesSinceAnswer }) => {
|
28
|
+
const { t } = useExamTranslation();
|
29
|
+
const characterCountText = characterCount > 0 ? t('undo.answerCharacterCount', { count: characterCount }) : null;
|
30
|
+
const imageCountText = screenshotCount > 0 ? t('undo.answerImageCount', { count: screenshotCount }) : null;
|
31
|
+
const arr = [characterCountText, imageCountText].filter(x => x !== null);
|
32
|
+
return (React.createElement("div", { className: "e-undo-view-entry js-undo-entry-content" },
|
33
|
+
React.createElement("div", { className: "js-undo-history-entry-time" }, answerIndex === 0 ? t('undo.latestVersion') : t('undo.minutesSinceAnswer', { minutes: minutesSinceAnswer })),
|
34
|
+
React.createElement("div", { className: "e-undo-view-answer-cropped js-undo-history-entry-answer" }, croppedAnswer || t('undo.answerNoText')),
|
35
|
+
React.createElement("div", { className: "e-undo-view-answer-length js-undo-history-entry-stats" }, arr.map((el, index) => (React.createElement(React.Fragment, { key: index },
|
36
|
+
el,
|
37
|
+
index < arr.length - 1 && React.createElement("span", null, ", ")))))));
|
38
|
+
};
|
39
|
+
//# sourceMappingURL=UndoHistoryEntry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UndoHistoryEntry.js","sourceRoot":"","sources":["../../../src/components/exam/UndoHistoryEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAY/C,MAAM,OAAO,gBAAiB,SAAQ,KAAK,CAAC,aAAoC;IAI9E,YAAY,KAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAA;QAWN,sBAAiB,GAAG,GAAG,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YAC3C,IAAI,I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E,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,MAAM,kBAAkB,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAChH,MAAM,cAAc,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAE1G,MAAM,GAAG,GAAG,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;IAExE,OAAO,CACL,6BAAK,SAAS,EAAC,yCAAyC;QACtD,6BAAK,SAAS,EAAC,4BAA4B,IACxC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CACxG;QACN,6BAAK,SAAS,EAAC,yDAAyD,IACrE,aAAa,IAAI,CAAC,CAAC,mBAAmB,CAAC,CACpC;QACN,6BAAK,SAAS,EAAC,uDAAuD,IACnE,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CACtB,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,KAAK;YACvB,EAAE;YACF,KAAK,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,uCAAe,CAC3B,CAClB,CAAC,CACE,CACF,CACP,CAAA;AACH,CAAC,CAAA"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { RichTextAnswer, TextAnswer } from '../../types/ExamAnswer';
|
3
|
+
export interface AnswerHistoryEntry {
|
4
|
+
type: 'text' | 'richText';
|
5
|
+
value: string;
|
6
|
+
characterCount: number;
|
7
|
+
answerTime: number;
|
8
|
+
}
|
9
|
+
export interface UndoViewProps {
|
10
|
+
close: () => void;
|
11
|
+
restoreAnswer: (examAnswer: TextAnswer | RichTextAnswer) => void;
|
12
|
+
questionId: number;
|
13
|
+
title: string;
|
14
|
+
}
|
15
|
+
interface UndoViewState {
|
16
|
+
answers: AnswerHistoryEntry[];
|
17
|
+
selectedAnswerIndex: number;
|
18
|
+
loading: boolean;
|
19
|
+
loadRetryTimeout: number | null;
|
20
|
+
}
|
21
|
+
export declare class UndoView extends React.PureComponent<UndoViewProps, UndoViewState> {
|
22
|
+
private source;
|
23
|
+
constructor(props: UndoViewProps);
|
24
|
+
toggleBodyScroll: (scrollEnabled: boolean) => boolean;
|
25
|
+
componentDidMount(): void;
|
26
|
+
componentWillUnmount(): void;
|
27
|
+
componentDidUpdate(prevProps: UndoViewProps): void;
|
28
|
+
private overlayClicked;
|
29
|
+
private keydownListener;
|
30
|
+
private fetchAnswerHistory;
|
31
|
+
private close;
|
32
|
+
render(): React.JSX.Element;
|
33
|
+
}
|
34
|
+
export {};
|
35
|
+
//# sourceMappingURL=UndoView.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UndoView.d.ts","sourceRoot":"","sources":["../../../src/components/exam/UndoView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAI/E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,KAAK,IAAI,CAAA;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AA0FD,qBAAa,QAAS,SAAQ,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,aAAa,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAuB;gBAEzB,KAAK,EAAE,aAAa;IAUhC,gBAAgB,kBAAmB,OAAO,aAC0C;IAE7E,iBAAiB;IAMjB,oBAAoB;IAMpB,kBAAkB,CAAC,SAAS,EAAE,aAAa;IAMlD,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe,CAQtB;YAEa,kBAAkB;IAmBhC,OAAO,CAAC,KAAK;IASN,MAAM;CAkDd"}
|
@@ -0,0 +1,162 @@
|
|
1
|
+
import axios from 'axios';
|
2
|
+
import React from 'react';
|
3
|
+
import { UndoHistoryEntry } from './UndoHistoryEntry';
|
4
|
+
import FocusTrap from 'focus-trap-react';
|
5
|
+
import { useExamTranslation } from '../../i18n';
|
6
|
+
const CancelToken = axios.CancelToken;
|
7
|
+
function toAnswerHistoryEntry(answer) {
|
8
|
+
return {
|
9
|
+
type: answer.type,
|
10
|
+
value: answer.value,
|
11
|
+
answerTime: answer.answer_time,
|
12
|
+
characterCount: answer.character_count
|
13
|
+
};
|
14
|
+
}
|
15
|
+
function AnswerDisplay(props) {
|
16
|
+
const { selectedAnswer } = props;
|
17
|
+
return selectedAnswer ? (selectedAnswer.type === 'richText' ? (React.createElement("div", { className: "e-undo-view-answer-content js-undo-answer-detail", dangerouslySetInnerHTML: { __html: selectedAnswer.value } })) : (React.createElement("div", { className: "e-undo-view-answer-content js-undo-answer-detail plainText" }, selectedAnswer.value))) : null;
|
18
|
+
}
|
19
|
+
function BottomBar(props) {
|
20
|
+
const { selectedAnswer, selectedAnswerIndex, restoreAnswer, questionId } = props;
|
21
|
+
const disableRestoreButton = !selectedAnswer || selectedAnswerIndex === 0;
|
22
|
+
return (React.createElement("div", { className: "e-undo-view-bottom-bar" },
|
23
|
+
React.createElement("button", { className: "e-button-default e-button js-restore-answer-button", disabled: disableRestoreButton, onClick: () => selectedAnswer && restoreAnswer({ ...selectedAnswer, questionId }) },
|
24
|
+
React.createElement(RestoreButtonLabel, null))));
|
25
|
+
}
|
26
|
+
function escapedHtml(html) {
|
27
|
+
const container = document.createElement('div');
|
28
|
+
container.innerHTML = html;
|
29
|
+
return container.innerText;
|
30
|
+
}
|
31
|
+
function getAnswerText(answer) {
|
32
|
+
const fullText = answer.type === 'text' ? answer.value : escapedHtml(answer.value);
|
33
|
+
return fullText.replace(/\s+/g, ' ').trim();
|
34
|
+
}
|
35
|
+
function truncateAnswer(answer, length = 50) {
|
36
|
+
const answerText = getAnswerText(answer);
|
37
|
+
if (answerText.length <= length) {
|
38
|
+
return answerText;
|
39
|
+
}
|
40
|
+
const separator = '…';
|
41
|
+
const charsToShow = length - separator.length;
|
42
|
+
const startChars = Math.ceil(charsToShow / 2);
|
43
|
+
const endChars = charsToShow - startChars;
|
44
|
+
return answerText.substr(0, startChars) + separator + answerText.substr(answerText.length - endChars);
|
45
|
+
}
|
46
|
+
function countCharacters(answer) {
|
47
|
+
const text = getAnswerText(answer);
|
48
|
+
return text.replace(/\s/g, '').length;
|
49
|
+
}
|
50
|
+
function countScreenshots(answer) {
|
51
|
+
const answerElement = document.createElement('div');
|
52
|
+
answerElement.innerHTML = answer.value;
|
53
|
+
const equationImageSelector = 'img[src^="/math.svg"], img[src^="data:image/svg+xml"]';
|
54
|
+
const imageCount = answerElement.querySelectorAll('img').length;
|
55
|
+
const emptyImageCount = answerElement.querySelectorAll('img[src=""]').length;
|
56
|
+
const equationCount = answerElement.querySelectorAll(equationImageSelector).length;
|
57
|
+
return imageCount - equationCount - emptyImageCount;
|
58
|
+
}
|
59
|
+
export class UndoView extends React.PureComponent {
|
60
|
+
constructor(props) {
|
61
|
+
super(props);
|
62
|
+
this.source = CancelToken.source();
|
63
|
+
this.toggleBodyScroll = (scrollEnabled) => document.documentElement.classList.toggle('e-exam-body-no-scroll', !scrollEnabled);
|
64
|
+
this.keydownListener = (event) => {
|
65
|
+
if (event.keyCode === 13) {
|
66
|
+
const selectedAnswer = this.state.answers[this.state.selectedAnswerIndex];
|
67
|
+
this.props.restoreAnswer({ ...selectedAnswer, questionId: this.props.questionId });
|
68
|
+
this.close();
|
69
|
+
}
|
70
|
+
else if (event.keyCode === 27) {
|
71
|
+
this.close();
|
72
|
+
}
|
73
|
+
};
|
74
|
+
this.state = {
|
75
|
+
answers: [],
|
76
|
+
selectedAnswerIndex: 0,
|
77
|
+
loading: true,
|
78
|
+
loadRetryTimeout: null
|
79
|
+
};
|
80
|
+
}
|
81
|
+
componentDidMount() {
|
82
|
+
this.toggleBodyScroll(false);
|
83
|
+
document.addEventListener('keydown', this.keydownListener, false);
|
84
|
+
void this.fetchAnswerHistory(this.props.questionId);
|
85
|
+
}
|
86
|
+
componentWillUnmount() {
|
87
|
+
this.source.cancel();
|
88
|
+
document.removeEventListener('keydown', this.keydownListener, false);
|
89
|
+
this.toggleBodyScroll(true);
|
90
|
+
}
|
91
|
+
componentDidUpdate(prevProps) {
|
92
|
+
if (this.props.questionId !== prevProps.questionId) {
|
93
|
+
void this.fetchAnswerHistory(this.props.questionId);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
overlayClicked(event) {
|
97
|
+
const targetClass = event.target.className;
|
98
|
+
if (targetClass.includes('js-undo-overlay')) {
|
99
|
+
this.close();
|
100
|
+
}
|
101
|
+
}
|
102
|
+
async fetchAnswerHistory(questionId) {
|
103
|
+
try {
|
104
|
+
const answerHistoryResult = await axios.get(`/rest/answer-history/${questionId}`, {
|
105
|
+
cancelToken: this.source.token
|
106
|
+
});
|
107
|
+
const answerHistory = answerHistoryResult.data;
|
108
|
+
const answers = answerHistory.map(toAnswerHistoryEntry);
|
109
|
+
this.setState({ answers, selectedAnswerIndex: 0, loading: false, loadRetryTimeout: null });
|
110
|
+
}
|
111
|
+
catch (error) {
|
112
|
+
if (!axios.isCancel(error)) {
|
113
|
+
this.setState({
|
114
|
+
loadRetryTimeout: window.setTimeout(() => {
|
115
|
+
void this.fetchAnswerHistory(questionId);
|
116
|
+
}, 4000)
|
117
|
+
});
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
close() {
|
122
|
+
const timeout = this.state.loadRetryTimeout;
|
123
|
+
if (timeout) {
|
124
|
+
clearTimeout(timeout);
|
125
|
+
}
|
126
|
+
this.source.cancel();
|
127
|
+
this.props.close();
|
128
|
+
}
|
129
|
+
render() {
|
130
|
+
const selectedAnswer = this.state.answers[this.state.selectedAnswerIndex];
|
131
|
+
const now = new Date().getTime();
|
132
|
+
return (React.createElement(FocusTrap, null,
|
133
|
+
React.createElement("div", { onClick: this.overlayClicked.bind(this), className: "e-overlay js-undo-overlay", "aria-modal": "true" },
|
134
|
+
React.createElement("div", { id: "undo", className: "e-undo-view" },
|
135
|
+
React.createElement(CloseButton, { close: this.close.bind(this) }),
|
136
|
+
this.state.loading ? (React.createElement(Loading, null)) : (React.createElement("div", { className: "e-undo-view-content" },
|
137
|
+
React.createElement("div", { className: "e-undo-view-answer-index js-undo-answer-index" }, this.state.answers.map((answer, index) => {
|
138
|
+
const timeSinceAnswer = now - new Date(answer.answerTime).getTime();
|
139
|
+
const toMinutes = Math.round(timeSinceAnswer / 1000 / 60);
|
140
|
+
return (React.createElement(UndoHistoryEntry, { key: new Date(answer.answerTime).getTime(), answerIndex: index, selected: index === this.state.selectedAnswerIndex, onChange: index => this.setState({ selectedAnswerIndex: index }), croppedAnswer: truncateAnswer(answer), minutesSinceAnswer: toMinutes, characterCount: countCharacters(answer), screenshotCount: countScreenshots(answer) }));
|
141
|
+
})),
|
142
|
+
React.createElement("div", { className: "e-undo-view-right-panel" },
|
143
|
+
React.createElement("div", { className: "e-undo-view-header js-undo-view-header" },
|
144
|
+
React.createElement("h3", { className: "e-undo-view-title js-undo-view-title" }, this.props.title)),
|
145
|
+
React.createElement(AnswerDisplay, { selectedAnswer: selectedAnswer }),
|
146
|
+
React.createElement(BottomBar, { selectedAnswer: selectedAnswer, selectedAnswerIndex: this.state.selectedAnswerIndex, restoreAnswer: this.props.restoreAnswer, questionId: this.props.questionId }))))))));
|
147
|
+
}
|
148
|
+
}
|
149
|
+
const Loading = () => {
|
150
|
+
const { t } = useExamTranslation();
|
151
|
+
return React.createElement("div", { style: { padding: '10px' } }, t('undo.loading'));
|
152
|
+
};
|
153
|
+
const CloseButton = ({ close }) => {
|
154
|
+
const { t } = useExamTranslation();
|
155
|
+
return (React.createElement("div", null,
|
156
|
+
React.createElement("img", { src: "img/closeButton.svg", id: "closeUndoDialogButton", className: "e-undo-view-close-overlay-button js-close-undo-dialog-button", onClick: close, tabIndex: 0, role: "button", "aria-label": t('undo.close') })));
|
157
|
+
};
|
158
|
+
const RestoreButtonLabel = () => {
|
159
|
+
const { t } = useExamTranslation();
|
160
|
+
return React.createElement("div", null, t('undo.restoreAnswer'));
|
161
|
+
};
|
162
|
+
//# sourceMappingURL=UndoView.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UndoView.js","sourceRoot":"","sources":["../../../src/components/exam/UndoView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAG/C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAA;AA4BrC,SAAS,oBAAoB,CAAC,MAA2B;IACvD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC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,CACI,CACb,CAAA;IACH,CAAC;CACF;AAED,MAAM,OAAO,GAAG,GAAG,EAAE;IACnB,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,OAAO,6BAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,CAAC,CAAC,cAAc,CAAC,CAAO,CAAA;AACnE,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAyB,EAAE,EAAE;IACvD,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,OAAO,CACL;QACE,6BACE,GAAG,EAAC,qBAAqB,EACzB,EAAE,EAAC,uBAAuB,EAC1B,SAAS,EAAC,8DAA8D,EACxE,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,CAAC,EACX,IAAI,EAAC,QAAQ,gBACD,CAAC,CAAC,YAAY,CAAY,GACtC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,OAAO,iCAAM,CAAC,CAAC,oBAAoB,CAAC,CAAO,CAAA;AAC7C,CAAC,CAAA"}
|
@@ -26,7 +26,7 @@ const AnswerTooLongError = ({ displayNumber, characterCount }) => {
|
|
26
26
|
};
|
27
27
|
export function ErrorIndicatorForErrors({ validationErrors, inExam }) {
|
28
28
|
return validationErrors.length > 0 ? (React.createElement("div", { className: classNames({ 'error-indicator e-bg-color-error e-color-off-white': inExam }, 'e-columns e-columns--inline e-font-size-xs e-pad-1 e-mrg-r-1'), role: "alert" },
|
29
|
-
React.createElement("div", { className: "e-column e-column--narrow" },
|
29
|
+
React.createElement("div", { className: "e-column e-column--narrow", style: { color: '#f90' } },
|
30
30
|
React.createElement(FontAwesomeIcon, { size: "lg", icon: faExclamationTriangle, fixedWidth: true, className: "e-mrg-r-1" })),
|
31
31
|
React.createElement("div", { className: "e-column e-column--gapless" }, validationErrors.map(validationError => {
|
32
32
|
const key = validationError.type + validationError.displayNumber;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ErrorIndicator.js","sourceRoot":"","sources":["../../../../src/components/exam/internal/ErrorIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,OAAO,qBAAqB,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,MAAM,gBAAgB,GAAyC,KAAK,CAAC,EAAE;IACrE,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;IAC5C,OAAO,CACL;QACG,WAAW,KAAK,MAAM,IAAI,WAAW,KAAK,aAAa;YACtD,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,CAAC,IAAI,oBAAC,aAAa,OAAK,KAAK,GAAI;YACnE,CAAC,CAAC,EAAE;QAAE,GAAG;QACV,oBAAC,qBAAqB,OAAK,KAAK,GAAI,CACjC,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,kBAAkB,GAA2C,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAE;IACvG,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,OAAO,CACL;QACG,CAAC,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
|
+
export interface AnswerHistoryEntry {
|
5
|
+
type: 'text' | 'richText';
|
6
|
+
value: string;
|
7
|
+
characterCount: number;
|
8
|
+
answerTime: moment.Moment;
|
9
|
+
}
|
10
|
+
export interface UndoViewProps {
|
11
|
+
close: () => void;
|
12
|
+
restoreAnswer: (examAnswer: TextAnswer | RichTextAnswer) => void;
|
13
|
+
questionId: number;
|
14
|
+
title: string;
|
15
|
+
}
|
16
|
+
interface UndoViewState {
|
17
|
+
answers: AnswerHistoryEntry[];
|
18
|
+
selectedAnswerIndex: number;
|
19
|
+
loading: boolean;
|
20
|
+
loadRetryTimeout: number | null;
|
21
|
+
}
|
22
|
+
export declare class UndoView extends React.PureComponent<UndoViewProps, UndoViewState> {
|
23
|
+
private source;
|
24
|
+
constructor(props: UndoViewProps);
|
25
|
+
toggleBodyScroll: (scrollEnabled: boolean) => boolean;
|
26
|
+
componentDidMount(): void;
|
27
|
+
componentWillUnmount(): void;
|
28
|
+
componentDidUpdate(prevProps: UndoViewProps): void;
|
29
|
+
private overlayClicked;
|
30
|
+
private keydownListener;
|
31
|
+
private fetchAnswerHistory;
|
32
|
+
private close;
|
33
|
+
render(): React.JSX.Element;
|
34
|
+
}
|
35
|
+
export {};
|
36
|
+
//# sourceMappingURL=undo-view.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"undo-view.d.ts","sourceRoot":"","sources":["../../../src/components/exam/undo-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAI3B,OAAO,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAI/E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,KAAK,IAAI,CAAA;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AA+FD,qBAAa,QAAS,SAAQ,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,aAAa,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAuB;gBAEzB,KAAK,EAAE,aAAa;IAUhC,gBAAgB,kBAAmB,OAAO,aAC0C;IAE7E,iBAAiB;IAMjB,oBAAoB;IAMpB,kBAAkB,CAAC,SAAS,EAAE,aAAa;IAMlD,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe,CAQtB;YAEa,kBAAkB;IAmBhC,OAAO,CAAC,KAAK;IASN,MAAM;CAgDd"}
|
@@ -0,0 +1,162 @@
|
|
1
|
+
import axios from 'axios';
|
2
|
+
import React from 'react';
|
3
|
+
//import { Spinner } from '../components/spinner'
|
4
|
+
import moment from 'moment';
|
5
|
+
import { UndoHistoryEntry } from './UndoHistoryEntry';
|
6
|
+
import FocusTrap from 'focus-trap-react';
|
7
|
+
import { useExamTranslation } from '../../i18n';
|
8
|
+
const CancelToken = axios.CancelToken;
|
9
|
+
function toAnswerHistoryEntry(answer) {
|
10
|
+
return {
|
11
|
+
type: answer.type,
|
12
|
+
value: answer.value,
|
13
|
+
answerTime: moment(answer.answer_time),
|
14
|
+
characterCount: answer.character_count
|
15
|
+
};
|
16
|
+
}
|
17
|
+
function AnswerDisplay(props) {
|
18
|
+
const { selectedAnswer } = props;
|
19
|
+
return selectedAnswer ? (selectedAnswer.type === 'richText' ? (React.createElement("div", { className: "k-undo-view-answer-content js-undo-answer-detail", dangerouslySetInnerHTML: { __html: selectedAnswer.value } })) : (React.createElement("div", { className: "k-undo-view-answer-content js-undo-answer-detail plainText" }, selectedAnswer.value))) : null;
|
20
|
+
}
|
21
|
+
function BottomBar(props) {
|
22
|
+
const { selectedAnswer, selectedAnswerIndex, restoreAnswer, questionId } = props;
|
23
|
+
const disableRestoreButton = !selectedAnswer || selectedAnswerIndex === 0;
|
24
|
+
return (React.createElement("div", { className: "k-undo-view-bottom-bar" },
|
25
|
+
React.createElement("button", { className: "k-button-default k-button js-restore-answer-button", disabled: disableRestoreButton, onClick: () => selectedAnswer && restoreAnswer({ ...selectedAnswer, questionId }) },
|
26
|
+
React.createElement(RestoreButtonLabel, null))));
|
27
|
+
}
|
28
|
+
function escapedHtml(html) {
|
29
|
+
const container = document.createElement('div');
|
30
|
+
container.innerHTML = html;
|
31
|
+
return container.innerText;
|
32
|
+
}
|
33
|
+
function getAnswerText(answer) {
|
34
|
+
const fullText = answer.type === 'text' ? answer.value : escapedHtml(answer.value);
|
35
|
+
return fullText.replace(/\s+/g, ' ').trim();
|
36
|
+
}
|
37
|
+
function truncateAnswer(answer, length = 50) {
|
38
|
+
const answerText = getAnswerText(answer);
|
39
|
+
if (answerText.length <= length) {
|
40
|
+
return answerText;
|
41
|
+
}
|
42
|
+
const separator = '…';
|
43
|
+
const charsToShow = length - separator.length;
|
44
|
+
const startChars = Math.ceil(charsToShow / 2);
|
45
|
+
const endChars = charsToShow - startChars;
|
46
|
+
return answerText.substr(0, startChars) + separator + answerText.substr(answerText.length - endChars);
|
47
|
+
}
|
48
|
+
function countWords(answer) {
|
49
|
+
const text = getAnswerText(answer);
|
50
|
+
return text.length === 0 ? 0 : text.split(/\s+/gi).filter(s => s.length > 0).length;
|
51
|
+
}
|
52
|
+
function countCharacters(answer) {
|
53
|
+
const text = getAnswerText(answer);
|
54
|
+
return text.replace(/\s/g, '').length;
|
55
|
+
}
|
56
|
+
function countScreenshots(answer) {
|
57
|
+
const answerElement = document.createElement('div');
|
58
|
+
answerElement.innerHTML = answer.value;
|
59
|
+
const equationImageSelector = 'img[src^="/math.svg"], img[src^="data:image/svg+xml"]';
|
60
|
+
const imageCount = answerElement.querySelectorAll('img').length;
|
61
|
+
const emptyImageCount = answerElement.querySelectorAll('img[src=""]').length;
|
62
|
+
const equationCount = answerElement.querySelectorAll(equationImageSelector).length;
|
63
|
+
return imageCount - equationCount - emptyImageCount;
|
64
|
+
}
|
65
|
+
export class UndoView extends React.PureComponent {
|
66
|
+
constructor(props) {
|
67
|
+
super(props);
|
68
|
+
this.source = CancelToken.source();
|
69
|
+
this.toggleBodyScroll = (scrollEnabled) => document.documentElement.classList.toggle('k-exam-body-no-scroll', !scrollEnabled);
|
70
|
+
this.keydownListener = (event) => {
|
71
|
+
if (event.keyCode === 13) {
|
72
|
+
const selectedAnswer = this.state.answers[this.state.selectedAnswerIndex];
|
73
|
+
this.props.restoreAnswer({ ...selectedAnswer, questionId: this.props.questionId });
|
74
|
+
this.close();
|
75
|
+
}
|
76
|
+
else if (event.keyCode === 27) {
|
77
|
+
this.close();
|
78
|
+
}
|
79
|
+
};
|
80
|
+
this.state = {
|
81
|
+
answers: [],
|
82
|
+
selectedAnswerIndex: 0,
|
83
|
+
loading: true,
|
84
|
+
loadRetryTimeout: null
|
85
|
+
};
|
86
|
+
}
|
87
|
+
componentDidMount() {
|
88
|
+
this.toggleBodyScroll(false);
|
89
|
+
document.addEventListener('keydown', this.keydownListener, false);
|
90
|
+
void this.fetchAnswerHistory(this.props.questionId);
|
91
|
+
}
|
92
|
+
componentWillUnmount() {
|
93
|
+
this.source.cancel();
|
94
|
+
document.removeEventListener('keydown', this.keydownListener, false);
|
95
|
+
this.toggleBodyScroll(true);
|
96
|
+
}
|
97
|
+
componentDidUpdate(prevProps) {
|
98
|
+
if (this.props.questionId !== prevProps.questionId) {
|
99
|
+
void this.fetchAnswerHistory(this.props.questionId);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
overlayClicked(event) {
|
103
|
+
const targetClass = event.target.className;
|
104
|
+
if (targetClass.includes('js-undo-overlay')) {
|
105
|
+
this.close();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
async fetchAnswerHistory(questionId) {
|
109
|
+
try {
|
110
|
+
const answerHistoryResult = await axios.get(`/rest/answer-history/${questionId}`, {
|
111
|
+
cancelToken: this.source.token
|
112
|
+
});
|
113
|
+
const answerHistory = answerHistoryResult.data;
|
114
|
+
const answers = answerHistory.map(toAnswerHistoryEntry);
|
115
|
+
this.setState({ answers, selectedAnswerIndex: 0, loading: false, loadRetryTimeout: null });
|
116
|
+
}
|
117
|
+
catch (error) {
|
118
|
+
if (!axios.isCancel(error)) {
|
119
|
+
this.setState({
|
120
|
+
loadRetryTimeout: window.setTimeout(() => {
|
121
|
+
void this.fetchAnswerHistory(questionId);
|
122
|
+
}, 4000)
|
123
|
+
});
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
close() {
|
128
|
+
const timeout = this.state.loadRetryTimeout;
|
129
|
+
if (timeout) {
|
130
|
+
clearTimeout(timeout);
|
131
|
+
}
|
132
|
+
this.source.cancel();
|
133
|
+
this.props.close();
|
134
|
+
}
|
135
|
+
render() {
|
136
|
+
const selectedAnswer = this.state.answers[this.state.selectedAnswerIndex];
|
137
|
+
const now = moment();
|
138
|
+
return (React.createElement(FocusTrap, null,
|
139
|
+
React.createElement("div", { onClick: this.overlayClicked.bind(this), className: "k-overlay js-undo-overlay", "aria-modal": "true" },
|
140
|
+
React.createElement("div", { id: "undo", className: "k-undo-view" },
|
141
|
+
React.createElement("div", { className: "k-undo-view-header js-undo-view-header" },
|
142
|
+
React.createElement("h3", { className: "k-undo-view-title js-undo-view-title" }, this.props.title),
|
143
|
+
React.createElement(CloseButton, { close: this.close.bind(this) })),
|
144
|
+
this.state.loading ? ('Loading...') : (
|
145
|
+
//<Spinner />
|
146
|
+
React.createElement("div", { className: "k-undo-view-content" },
|
147
|
+
React.createElement("div", { className: "k-undo-view-answer-index js-undo-answer-index" }, this.state.answers.map((answer, index) => (React.createElement(UndoHistoryEntry, { key: answer.answerTime.unix(), answerIndex: index, selected: index === this.state.selectedAnswerIndex, onChange: index => this.setState({ selectedAnswerIndex: index }), croppedAnswer: truncateAnswer(answer), minutesSinceAnswer: now.diff(answer.answerTime, 'minutes'), wordCount: countWords(answer), characterCount: countCharacters(answer), screenshotCount: countScreenshots(answer) })))),
|
148
|
+
React.createElement("div", { className: "k-undo-view-right-panel" },
|
149
|
+
React.createElement(AnswerDisplay, { selectedAnswer: selectedAnswer }),
|
150
|
+
React.createElement(BottomBar, { selectedAnswer: selectedAnswer, selectedAnswerIndex: this.state.selectedAnswerIndex, restoreAnswer: this.props.restoreAnswer, questionId: this.props.questionId }))))))));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
const CloseButton = ({ close }) => {
|
154
|
+
const { t } = useExamTranslation();
|
155
|
+
return (React.createElement("div", null,
|
156
|
+
React.createElement("img", { src: "img/closeButton.svg", id: "closeUndoDialogButton", className: "k-undo-view-close-overlay-button js-close-undo-dialog-button", onClick: close, tabIndex: 0, role: "button", "aria-label": t('undo.close') })));
|
157
|
+
};
|
158
|
+
const RestoreButtonLabel = () => {
|
159
|
+
const { t } = useExamTranslation();
|
160
|
+
return React.createElement("div", null, t('undo.restoreAnswer'));
|
161
|
+
};
|
162
|
+
//# sourceMappingURL=undo-view.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"undo-view.js","sourceRoot":"","sources":["../../../src/components/exam/undo-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,iDAAiD;AACjD,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAA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wBACN,6BAAK,SAAS,EAAC,yBAAyB;4BACtC,oBAAC,aAAa,IAAC,cAAc,EAAE,cAAc,GAAI;4BACjD,oBAAC,SAAS,IACR,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,EACnD,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GACjC,CACE,CACF,CACP,CACG,CACF,CACI,CACb,CAAA;IACH,CAAC;CACF;AAED,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAyB,EAAE,EAAE;IACvD,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,OAAO,CACL;QACE,6BACE,GAAG,EAAC,qBAAqB,EACzB,EAAE,EAAC,uBAAuB,EAC1B,SAAS,EAAC,8DAA8D,EACxE,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,CAAC,EACX,IAAI,EAAC,QAAQ,gBACD,CAAC,CAAC,YAAY,CAAY,GACtC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,OAAO,iCAAM,CAAC,CAAC,oBAAoB,CAAC,CAAO,CAAA;AAC7C,CAAC,CAAA"}
|
@@ -26,30 +26,31 @@ function ChoiceAnswerOption({ renderChildNodes, selected, element, questionId, d
|
|
26
26
|
React.createElement(Content, null))));
|
27
27
|
}
|
28
28
|
function ChoiceAnswer({ element, renderChildNodes }) {
|
29
|
-
var _a;
|
29
|
+
var _a, _b;
|
30
30
|
const { answersByQuestionId, gradingStructure } = useContext(ResultsContext);
|
31
31
|
const questionId = getNumericAttribute(element, 'question-id');
|
32
32
|
const answer = answersByQuestionId[questionId];
|
33
33
|
const direction = element.getAttribute('direction') || 'vertical';
|
34
34
|
const className = element.getAttribute('class');
|
35
35
|
const choice = findMultiChoiceFromGradingStructure(gradingStructure, questionId);
|
36
|
-
const scoreValue = answer && ((_a = choice.options.find(option => option.id === Number(answer.value))) === null ||
|
36
|
+
const scoreValue = answer && ((_b = (_a = choice === null || choice === void 0 ? void 0 : choice.options) === null || _a === void 0 ? void 0 : _a.find(option => option.id === Number(answer.value))) === null || _b === void 0 ? void 0 : _b.score);
|
37
37
|
const maxScore = getNumericAttribute(element, 'max-score');
|
38
38
|
return (React.createElement(React.Fragment, null,
|
39
|
-
|
39
|
+
React.createElement(ResultsExamQuestionAutoScore, { score: scoreValue, maxScore: maxScore }),
|
40
40
|
React.createElement("div", { className: classNames('e-choice-answer', className, {
|
41
41
|
'e-columns': direction === 'horizontal'
|
42
42
|
}) }, mapChildElements(element, childElement => {
|
43
|
+
var _a;
|
43
44
|
const optionId = getNumericAttribute(childElement, 'option-id');
|
44
45
|
const selected = answer != null && Number(answer.value) === optionId;
|
45
|
-
const grading = choice.options.find(option => option.id === optionId);
|
46
|
+
const grading = (_a = choice === null || choice === void 0 ? void 0 : choice.options) === null || _a === void 0 ? void 0 : _a.find(option => option.id === optionId);
|
46
47
|
return (React.createElement(ChoiceAnswerOption, { element: childElement,
|
47
48
|
renderChildNodes,
|
48
49
|
questionId,
|
49
50
|
key: optionId,
|
50
51
|
direction,
|
51
52
|
selected,
|
52
|
-
isCorrect: grading.correct }));
|
53
|
+
isCorrect: (grading === null || grading === void 0 ? void 0 : grading.correct) || false }));
|
53
54
|
}))));
|
54
55
|
}
|
55
56
|
export default React.memo(ChoiceAnswer);
|