@digabi/exam-engine-core 16.6.4 → 16.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
- package/dist/main.css +1 -1
- package/package.json +2 -2
- package/dist/components/grading/Grading.d.ts +0 -15
- package/dist/components/grading/Grading.d.ts.map +0 -1
- package/dist/components/grading/Grading.js +0 -72
- package/dist/components/grading/Grading.js.map +0 -1
- package/dist/components/grading/MultiLineAnswer.d.ts +0 -8
- package/dist/components/grading/MultiLineAnswer.d.ts.map +0 -1
- package/dist/components/grading/MultiLineAnswer.js +0 -19
- package/dist/components/grading/MultiLineAnswer.js.map +0 -1
- package/dist/components/grading/Question.d.ts +0 -5
- package/dist/components/grading/Question.d.ts.map +0 -1
- package/dist/components/grading/Question.js +0 -23
- package/dist/components/grading/Question.js.map +0 -1
- package/dist/components/grading/QuestionTitle.d.ts +0 -6
- package/dist/components/grading/QuestionTitle.d.ts.map +0 -1
- package/dist/components/grading/QuestionTitle.js +0 -21
- package/dist/components/grading/QuestionTitle.js.map +0 -1
- package/dist/components/grading/ScoredTextAnswer.d.ts +0 -6
- package/dist/components/grading/ScoredTextAnswer.d.ts.map +0 -1
- package/dist/components/grading/ScoredTextAnswer.js +0 -22
- package/dist/components/grading/ScoredTextAnswer.js.map +0 -1
- package/dist/components/grading/Section.d.ts +0 -5
- package/dist/components/grading/Section.d.ts.map +0 -1
- package/dist/components/grading/Section.js +0 -18
- package/dist/components/grading/Section.js.map +0 -1
- package/dist/components/grading/SingleLineAnswer.d.ts +0 -12
- package/dist/components/grading/SingleLineAnswer.d.ts.map +0 -1
- package/dist/components/grading/SingleLineAnswer.js +0 -23
- package/dist/components/grading/SingleLineAnswer.js.map +0 -1
- package/dist/components/grading/TextAnswer.d.ts +0 -7
- package/dist/components/grading/TextAnswer.d.ts.map +0 -1
- package/dist/components/grading/TextAnswer.js +0 -53
- package/dist/components/grading/TextAnswer.js.map +0 -1
- package/dist/components/grading/internal/AnnotationList.d.ts +0 -5
- package/dist/components/grading/internal/AnnotationList.d.ts.map +0 -1
- package/dist/components/grading/internal/AnnotationList.js +0 -43
- package/dist/components/grading/internal/AnnotationList.js.map +0 -1
- package/dist/components/grading/internal/QuestionAutoScore.d.ts +0 -10
- package/dist/components/grading/internal/QuestionAutoScore.d.ts.map +0 -1
- package/dist/components/grading/internal/QuestionAutoScore.js +0 -17
- package/dist/components/grading/internal/QuestionAutoScore.js.map +0 -1
- package/dist/components/grading/internal/QuestionManualScore.d.ts +0 -12
- package/dist/components/grading/internal/QuestionManualScore.d.ts.map +0 -1
- package/dist/components/grading/internal/QuestionManualScore.js +0 -61
- package/dist/components/grading/internal/QuestionManualScore.js.map +0 -1
- package/dist/components/grading/internal/QuestionScoresContainer.d.ts +0 -10
- package/dist/components/grading/internal/QuestionScoresContainer.d.ts.map +0 -1
- package/dist/components/grading/internal/QuestionScoresContainer.js +0 -12
- package/dist/components/grading/internal/QuestionScoresContainer.js.map +0 -1
- package/dist/editAnnotations.d.ts +0 -3
- package/dist/editAnnotations.d.ts.map +0 -1
- package/dist/editAnnotations.js +0 -340
- package/dist/editAnnotations.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"TextAnswer.d.ts","sourceRoot":"","sources":["../../../src/components/grading/TextAnswer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAYjE,iBAAS,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,kBAAkB,eAoDlD;;AAED,wBAAqC"}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
2
|
-
import { getNumericAttribute } from '../../dom-utils';
|
3
|
-
import { useExamTranslation } from '../../i18n';
|
4
|
-
import { shortDisplayNumber } from '../../shortDisplayNumber';
|
5
|
-
import AnswerToolbar from '../AnswerToolbar';
|
6
|
-
import { QuestionContext } from '../context/QuestionContext';
|
7
|
-
import { findScore, ResultsContext } from '../context/ResultsContext';
|
8
|
-
import AnswerLengthInfo from '../shared/AnswerLengthInfo';
|
9
|
-
import ResultsExamQuestionManualScore from './internal/QuestionManualScore';
|
10
|
-
import { MultiLineAnswer } from './MultiLineAnswer';
|
11
|
-
import ResultsSingleLineAnswer from './SingleLineAnswer';
|
12
|
-
function TextAnswer({ element }) {
|
13
|
-
var _a;
|
14
|
-
const { answers } = useContext(QuestionContext);
|
15
|
-
const { answersByQuestionId, scores } = useContext(ResultsContext);
|
16
|
-
const { t } = useExamTranslation();
|
17
|
-
const questionId = getNumericAttribute(element, 'question-id');
|
18
|
-
const maxScore = getNumericAttribute(element, 'max-score');
|
19
|
-
const answer = answersByQuestionId[questionId];
|
20
|
-
const value = answer && answer.value;
|
21
|
-
const displayNumber = answers.length > 1 ? shortDisplayNumber(element.getAttribute('display-number')) : undefined;
|
22
|
-
const score = findScore(scores, questionId);
|
23
|
-
const comment = (_a = score === null || score === void 0 ? void 0 : score.pregrading) === null || _a === void 0 ? void 0 : _a.comment;
|
24
|
-
const type = (element.getAttribute('type') || 'single-line');
|
25
|
-
const maxLength = getNumericAttribute(element, 'max-length');
|
26
|
-
switch (type) {
|
27
|
-
case 'rich-text':
|
28
|
-
case 'multi-line': {
|
29
|
-
return (React.createElement(React.Fragment, null,
|
30
|
-
maxLength != null && React.createElement(AnswerLengthInfo, { ...{ maxLength } }),
|
31
|
-
React.createElement(ResultsExamQuestionManualScore, { multilineAnswer: true, scores: score, maxScore: maxScore }),
|
32
|
-
React.createElement(MultiLineAnswer, { ...{ type, value, score } }),
|
33
|
-
React.createElement(AnswerToolbar, { ...{
|
34
|
-
answer,
|
35
|
-
element,
|
36
|
-
} }),
|
37
|
-
comment && (React.createElement(React.Fragment, null,
|
38
|
-
React.createElement("h5", null, t('comment')),
|
39
|
-
React.createElement("p", { className: "e-italic" }, comment)))));
|
40
|
-
}
|
41
|
-
case 'single-line':
|
42
|
-
default:
|
43
|
-
return (React.createElement(ResultsSingleLineAnswer, { ...{
|
44
|
-
answers,
|
45
|
-
score,
|
46
|
-
displayNumber,
|
47
|
-
value,
|
48
|
-
} },
|
49
|
-
React.createElement(ResultsExamQuestionManualScore, { ...{ scores: score, maxScore, displayNumber } })));
|
50
|
-
}
|
51
|
-
}
|
52
|
-
export default React.memo(TextAnswer);
|
53
|
-
//# sourceMappingURL=TextAnswer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"TextAnswer.js","sourceRoot":"","sources":["../../../src/components/grading/TextAnswer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,gBAAgB,MAAM,4BAA4B,CAAA;AACzD,OAAO,8BAA8B,MAAM,gCAAgC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,uBAAuB,MAAM,oBAAoB,CAAA;AAExD,SAAS,UAAU,CAAC,EAAE,OAAO,EAAsB;;IACjD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAC/C,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAA;IAClE,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EA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;oBACvB,2BAAG,SAAS,EAAC,UAAU,IAAE,OAAO,CAAK,CACpC,CACJ,CACA,CACJ,CAAA;SACF;QACD,KAAK,aAAa,CAAC;QACnB;YACE,OAAO,CACL,oBAAC,uBAAuB,OAClB;oBACF,OAAO;oBACP,KAAK;oBACL,aAAa;oBACb,KAAK;iBACN;gBAED,oBAAC,8BAA8B,OAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAI,CAC1D,CAC3B,CAAA;KACJ;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"AnnotationList.d.ts","sourceRoot":"","sources":["../../../../src/components/grading/internal/AnnotationList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAA;AA0CzC,iBAAS,qBAAqB,uBAoD7B;;AAED,wBAAgD"}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import * as _ from 'lodash-es';
|
2
|
-
import React, { useContext } from 'react';
|
3
|
-
import { getNumericAttribute } from '../../../dom-utils';
|
4
|
-
import { useExamTranslation } from '../../../i18n';
|
5
|
-
import { shortDisplayNumber } from '../../../shortDisplayNumber';
|
6
|
-
import { mapMaybe } from '../../../utils';
|
7
|
-
import { QuestionContext } from '../../context/QuestionContext';
|
8
|
-
import { findScore, ResultsContext } from '../../context/ResultsContext';
|
9
|
-
const hasAnnotations = (score) => { var _a, _b, _c, _d; return Boolean(((_b = (_a = score === null || score === void 0 ? void 0 : score.pregrading) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? void 0 : _b.length) || ((_d = (_c = score === null || score === void 0 ? void 0 : score.censoring) === null || _c === void 0 ? void 0 : _c.annotations) === null || _d === void 0 ? void 0 : _d.length)); };
|
10
|
-
const getPrefix = (answers, answer) => answers.length > 1 ? shortDisplayNumber(answer.getAttribute('display-number')) : '';
|
11
|
-
const AnnotationListComponent = ({ i18nTitleKey, annotations }) => {
|
12
|
-
const { t } = useExamTranslation();
|
13
|
-
return annotations ? (React.createElement(React.Fragment, null,
|
14
|
-
i18nTitleKey && React.createElement("h5", null, t(i18nTitleKey)),
|
15
|
-
React.createElement("ol", { className: "e-list-data e-pad-l-0 e-font-size-s" }, annotations.map(({ numbering, message }) => (React.createElement("li", { "data-list-number": numbering, key: numbering }, message)))))) : null;
|
16
|
-
};
|
17
|
-
function ResultsAnnotationList() {
|
18
|
-
const { answers } = useContext(QuestionContext);
|
19
|
-
const { scores, singleGrading } = useContext(ResultsContext);
|
20
|
-
const answersAndScores = mapMaybe(answers, (answer) => {
|
21
|
-
const questionId = getNumericAttribute(answer, 'question-id');
|
22
|
-
const score = findScore(scores, questionId);
|
23
|
-
return score && answer && hasAnnotations(score) ? [answer, score] : undefined;
|
24
|
-
});
|
25
|
-
const getListOfAnnotations = (answerElementAndScores, annotationsFrom, listNumberOffset = 0) => _.flatMap(answerElementAndScores, ([answer, score]) => {
|
26
|
-
var _a, _b, _c;
|
27
|
-
return (_c = (_b = (_a = score[annotationsFrom]) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? void 0 : _b.filter((a) => a.message.length).map((annotation, i) => {
|
28
|
-
const numbering = getPrefix(answers, answer) + String(listNumberOffset + i + 1) + ')';
|
29
|
-
const message = annotation.message;
|
30
|
-
return { numbering, message };
|
31
|
-
})) !== null && _c !== void 0 ? _c : [];
|
32
|
-
});
|
33
|
-
const pregradingAnnotations = getListOfAnnotations(answersAndScores, 'pregrading');
|
34
|
-
const censoringAnnotations = getListOfAnnotations(answersAndScores, 'censoring', pregradingAnnotations.length);
|
35
|
-
return pregradingAnnotations.length || censoringAnnotations.length ? (React.createElement("div", { className: "e-annotation-list e-columns e-mrg-t-2" }, singleGrading ? (React.createElement("div", { className: "e-column e-column--10" },
|
36
|
-
React.createElement(AnnotationListComponent, { annotations: pregradingAnnotations }))) : (React.createElement(React.Fragment, null,
|
37
|
-
React.createElement("div", { className: "e-column e-column--6" },
|
38
|
-
React.createElement(AnnotationListComponent, { i18nTitleKey: 'grading.pregrading-annotations', annotations: pregradingAnnotations })),
|
39
|
-
React.createElement("div", { className: "e-column e-column--6" },
|
40
|
-
React.createElement(AnnotationListComponent, { i18nTitleKey: 'grading.censor-annotations', annotations: censoringAnnotations })))))) : null;
|
41
|
-
}
|
42
|
-
export default React.memo(ResultsAnnotationList);
|
43
|
-
//# sourceMappingURL=AnnotationList.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"AnnotationList.js","sourceRoot":"","sources":["../../../../src/components/grading/internal/AnnotationList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAYxE,MAAM,cAAc,GAAG,CAAC,KAAY,EAAE,EAAE,uBACtC,OAAA,OAAO,CAAC,CAAA,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,WAAW,0CAAE,MAAM,MAAI,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,0CAAE,WAAW,0CAAE,MAAM,CAAA,CAAC,CAAA,EAAA,CAAA;AAE1F,MAAM,SAAS,GAAG,CAAC,OAAkB,EAAE,MAAe,EAAE,EAAE,CACxD,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAA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AAI,CACtG,CACL,CACJ,CACG,CACP,CAAC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
export interface QuestionAutoScoreProps {
|
3
|
-
score?: number;
|
4
|
-
maxScore?: number;
|
5
|
-
displayNumber?: string;
|
6
|
-
}
|
7
|
-
declare function QuestionAutoScore({ score, maxScore, displayNumber }: QuestionAutoScoreProps): JSX.Element;
|
8
|
-
declare const _default: React.MemoExoticComponent<typeof QuestionAutoScore>;
|
9
|
-
export default _default;
|
10
|
-
//# sourceMappingURL=QuestionAutoScore.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QuestionAutoScore.d.ts","sourceRoot":"","sources":["../../../../src/components/grading/internal/QuestionAutoScore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAKzC,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,iBAAS,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,sBAAsB,eAUpF;;AAED,wBAA4C"}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
2
|
-
import { useExamTranslation } from '../../../i18n';
|
3
|
-
import { QuestionContext } from '../../context/QuestionContext';
|
4
|
-
import ResultsExamQuestionScoresContainer from './QuestionScoresContainer';
|
5
|
-
function QuestionAutoScore({ score, maxScore, displayNumber }) {
|
6
|
-
const { answers } = useContext(QuestionContext);
|
7
|
-
const { t } = useExamTranslation();
|
8
|
-
const containerProps = { answers, displayNumber };
|
9
|
-
return (React.createElement(ResultsExamQuestionScoresContainer, { ...containerProps },
|
10
|
-
typeof score === 'number' ? React.createElement("b", null, score) : React.createElement("div", { className: "e-result-scorecount-empty" }),
|
11
|
-
' ',
|
12
|
-
maxScore ? `/ ${maxScore} ` : null,
|
13
|
-
" ",
|
14
|
-
t('points', { count: '' })));
|
15
|
-
}
|
16
|
-
export default React.memo(QuestionAutoScore);
|
17
|
-
//# sourceMappingURL=QuestionAutoScore.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QuestionAutoScore.js","sourceRoot":"","sources":["../../../../src/components/grading/internal/QuestionAutoScore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,kCAAkC,MAAM,2BAA2B,CAAA;AAQ1E,SAAS,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAA0B;IACnF,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAC/C,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAClC,MAAM,cAAc,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA;IACjD,OAAO,CACL,oBAAC,kCAAkC,OAAK,cAAc;QACnD,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,+BAAI,KAAK,CAAK,CAAC,CAAC,CAAC,6BAAK,SAAS,EAAC,2BAA2B,GAAG;QAAE,GAAG;QAC/F,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI;;QAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAmB,EAAE,CAAC,CAC9C,CACtC,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Score } from '../../../index';
|
3
|
-
export interface QuestionManualScoreProps {
|
4
|
-
scores?: Score;
|
5
|
-
maxScore?: number;
|
6
|
-
displayNumber?: string;
|
7
|
-
multilineAnswer?: boolean;
|
8
|
-
}
|
9
|
-
declare function QuestionManualScore({ scores, maxScore, displayNumber, multilineAnswer }: QuestionManualScoreProps): JSX.Element;
|
10
|
-
declare const _default: React.MemoExoticComponent<typeof QuestionManualScore>;
|
11
|
-
export default _default;
|
12
|
-
//# sourceMappingURL=QuestionManualScore.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QuestionManualScore.d.ts","sourceRoot":"","sources":["../../../../src/components/grading/internal/QuestionManualScore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAoD,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAKxF,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAQD,iBAAS,mBAAmB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,wBAAwB,eAiB1G;;AAoFD,wBAA8C"}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import classNames from 'classnames';
|
2
|
-
import React, { useContext } from 'react';
|
3
|
-
import { useExamTranslation } from '../../../i18n';
|
4
|
-
import { QuestionContext } from '../../context/QuestionContext';
|
5
|
-
import ResultsExamQuestionScoresContainer from './QuestionScoresContainer';
|
6
|
-
function QuestionManualScore({ scores, maxScore, displayNumber, multilineAnswer }) {
|
7
|
-
var _a, _b, _c, _d, _e;
|
8
|
-
const { answers } = useContext(QuestionContext);
|
9
|
-
const containerProps = { answers, displayNumber, multilineAnswer };
|
10
|
-
const shortCode = (_b = (_a = scores === null || scores === void 0 ? void 0 : scores.censoring) === null || _a === void 0 ? void 0 : _a.nonAnswerDetails) === null || _b === void 0 ? void 0 : _b.shortCode;
|
11
|
-
return (React.createElement(ResultsExamQuestionScoresContainer, { ...containerProps }, ((_c = scores === null || scores === void 0 ? void 0 : scores.pregrading) === null || _c === void 0 ? void 0 : _c.score) == null && !((_e = (_d = scores === null || scores === void 0 ? void 0 : scores.censoring) === null || _d === void 0 ? void 0 : _d.scores) === null || _e === void 0 ? void 0 : _e.length) ? (React.createElement(NoPregrading, { ...{ maxScore } })) : (React.createElement(React.Fragment, null,
|
12
|
-
renderNormalizedScores(scores, maxScore),
|
13
|
-
shortCode && React.createElement(NonAnswer, { shortCode: shortCode })))));
|
14
|
-
}
|
15
|
-
function renderNormalizedScores(scores, maxScore) {
|
16
|
-
const normalizedScores = [
|
17
|
-
scores.inspection && normalizeInspectionScore(scores.inspection),
|
18
|
-
...(scores.censoring ? normalizeCensoringScores(scores.censoring) : []),
|
19
|
-
scores.pregrading && normalizePregradingScore(scores.pregrading),
|
20
|
-
].filter(Boolean);
|
21
|
-
return normalizedScores.map((score, i) => React.createElement(ScoreRow, { key: i, ...score, latest: i === 0, maxScore: maxScore }));
|
22
|
-
}
|
23
|
-
function NoPregrading({ maxScore }) {
|
24
|
-
const { t } = useExamTranslation();
|
25
|
-
return (React.createElement(React.Fragment, null,
|
26
|
-
React.createElement("span", { className: "e-result-scorecount-empty" }),
|
27
|
-
maxScore && ` / ${maxScore} `,
|
28
|
-
t('points', { count: '' })));
|
29
|
-
}
|
30
|
-
function NonAnswer({ shortCode }) {
|
31
|
-
return (React.createElement("div", { className: "e-color-darkgrey e-columns e-columns--center-v" },
|
32
|
-
React.createElement("span", { className: "e-font-size-xxxl e-light e-mrg-r-1" }, "\u00D7"),
|
33
|
-
React.createElement("span", null, shortCode)));
|
34
|
-
}
|
35
|
-
function ScoreRow({ score, shortCode, type, maxScore, latest }) {
|
36
|
-
return (React.createElement("div", { className: latest ? 'e-color-black' : 'e-color-darkgrey e-font-size-xs' },
|
37
|
-
React.createElement(ScoreColumn, { className: classNames('e-nowrap', { 'e-font-size-m': latest }) },
|
38
|
-
latest ? React.createElement("b", null, score) : score,
|
39
|
-
latest && maxScore ? ` / ${maxScore}` : '',
|
40
|
-
` p.`),
|
41
|
-
React.createElement(ScoreColumn, { className: "e-result-scorecount-shortcode" }, shortCode),
|
42
|
-
React.createElement(ScoreColumn, { className: "e-mrg-r-0" }, type)));
|
43
|
-
}
|
44
|
-
function ScoreColumn({ className, children }) {
|
45
|
-
return React.createElement("span", { className: classNames('e-mrg-r-1 e-nowrap', className) }, children);
|
46
|
-
}
|
47
|
-
function normalizePregradingScore({ score }) {
|
48
|
-
return score !== undefined ? { score, shortCode: '', type: 'va' } : null;
|
49
|
-
}
|
50
|
-
function normalizeCensoringScores(score) {
|
51
|
-
return score.scores.map((s, i) => ({
|
52
|
-
score: s.score,
|
53
|
-
shortCode: s.shortCode || '',
|
54
|
-
type: `${score.scores.length - i}.s`,
|
55
|
-
}));
|
56
|
-
}
|
57
|
-
function normalizeInspectionScore(score) {
|
58
|
-
return { score: score.score, shortCode: score.shortCodes ? score.shortCodes.join(', ') : '', type: 'ta' };
|
59
|
-
}
|
60
|
-
export default React.memo(QuestionManualScore);
|
61
|
-
//# sourceMappingURL=QuestionManualScore.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QuestionManualScore.js","sourceRoot":"","sources":["../../../../src/components/grading/internal/QuestionManualScore.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,kCAAkC,MAAM,2BAA2B,CAAA;AAe1E,SAAS,mBAAmB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I,CAAe,CACnD,CACP,CAAA;AACH,CAAC;AAOD,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAoB;IAC5D,OAAO,8BAAM,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,IAAG,QAAQ,CAAQ,CAAA;AACxF,CAAC;AAED,SAAS,wBAAwB,CAAC,EAAE,KAAK,EAAmB;IAC1D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC1E,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAqB;IACrD,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACjC,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,EAAE;QAC5B,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI;KACrC,CAAC,CAAC,CAAA;AACL,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAsB;IACtD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAC3G,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
declare function QuestionScoresContainer({ answers, displayNumber, children, multilineAnswer, }: {
|
3
|
-
answers: Element[];
|
4
|
-
displayNumber?: string;
|
5
|
-
children: React.ReactNode;
|
6
|
-
multilineAnswer?: boolean;
|
7
|
-
}): JSX.Element;
|
8
|
-
declare const _default: React.MemoExoticComponent<typeof QuestionScoresContainer>;
|
9
|
-
export default _default;
|
10
|
-
//# sourceMappingURL=QuestionScoresContainer.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QuestionScoresContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/grading/internal/QuestionScoresContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,iBAAS,uBAAuB,CAAC,EAC/B,OAAO,EACP,aAAa,EACb,QAAQ,EACR,eAAe,GAChB,EAAE;IACD,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,eAiBA;;AAED,wBAAkD"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import classnames from 'classnames';
|
3
|
-
function QuestionScoresContainer({ answers, displayNumber, children, multilineAnswer, }) {
|
4
|
-
return (React.createElement("div", { className: classnames('e-result-scorecount', 'e-float-right', {
|
5
|
-
'e-result-scorecount-multiline-answer': multilineAnswer,
|
6
|
-
}) },
|
7
|
-
React.createElement("div", { className: "e-result-scorecount-border-wrap" },
|
8
|
-
answers.length > 1 && displayNumber && (React.createElement("sup", { className: "e-result-scorecount-sup e-mrg-r-1", "aria-hidden": "true" }, displayNumber)),
|
9
|
-
children)));
|
10
|
-
}
|
11
|
-
export default React.memo(QuestionScoresContainer);
|
12
|
-
//# sourceMappingURL=QuestionScoresContainer.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"QuestionScoresContainer.js","sourceRoot":"","sources":["../../../../src/components/grading/internal/QuestionScoresContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,SAAS,uBAAuB,CAAC,EAC/B,OAAO,EACP,aAAa,EACb,QAAQ,EACR,eAAe,GAMhB;IACC,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE,eAAe,EAAE;YAC5D,sCAAsC,EAAE,eAAe;SACxD,CAAC;QAEF,6BAAK,SAAS,EAAC,iCAAiC;YAC7C,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,IAAI,CACtC,6BAAK,SAAS,EAAC,mCAAmC,iBAAa,MAAM,IAClE,aAAa,CACV,CACP;YACA,QAAQ,CACL,CACF,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"editAnnotations.d.ts","sourceRoot":"","sources":["../src/editAnnotations.js"],"names":[],"mappings":"AAUA,wHA6PC;AAED,8EAqGC"}
|
package/dist/editAnnotations.js
DELETED
@@ -1,340 +0,0 @@
|
|
1
|
-
import $ from 'jquery';
|
2
|
-
import * as _ from 'lodash-es';
|
3
|
-
import * as Bacon from 'baconjs';
|
4
|
-
import * as answerAnnotationsRendering from './annotations-rendering';
|
5
|
-
$.fn.asEventStream = Bacon.$.asEventStream;
|
6
|
-
const ESC = 27;
|
7
|
-
const ENTER = 13;
|
8
|
-
let isMouseDown = false;
|
9
|
-
export function setupAnnotationEditing($containerElement, saveAnnotation, localize, isCensor) {
|
10
|
-
setupAnnotationAddition($containerElement);
|
11
|
-
setupAnnotationRemoval($containerElement);
|
12
|
-
function setupAnnotationRemoval($answers) {
|
13
|
-
$answers.on('mousedown', '.remove-annotation-area', (event) => {
|
14
|
-
removeAnnotation($(event.target).closest('.answerAnnotation'));
|
15
|
-
return false;
|
16
|
-
});
|
17
|
-
function removeAnnotation($annotationElem) {
|
18
|
-
// eslint-disable-line no-shadow
|
19
|
-
const $answerText = $annotationElem.closest('.answerText');
|
20
|
-
const annotationIndex = Number($annotationElem.data('index'));
|
21
|
-
const annotations = answerAnnotationsRendering.get($answerText);
|
22
|
-
const updatedAnnotations = _.without(annotations, annotations[annotationIndex]);
|
23
|
-
saveAnnotation(getAnswerId($answerText), updatedAnnotations);
|
24
|
-
answerAnnotationsRendering.renderAnnotationsForElement($answerText, updatedAnnotations);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
function setupAnnotationAddition($containerElement) {
|
28
|
-
preventDragSelectionFromOverlappingCensorAnswerText($containerElement);
|
29
|
-
$containerElement
|
30
|
-
.asEventStream('mouseup')
|
31
|
-
.filter(hasTextSelectedInAnswerText)
|
32
|
-
.map(() => {
|
33
|
-
$('.remove-annotation-popup').remove();
|
34
|
-
return getBrowserTextSelection().getRangeAt(0);
|
35
|
-
})
|
36
|
-
.filter((range) => {
|
37
|
-
if (selectionHasNothingToUnderline(range)) {
|
38
|
-
return false;
|
39
|
-
}
|
40
|
-
const $container = $(range.commonAncestorContainer);
|
41
|
-
return (!$container.hasClass('add-annotation-popup') &&
|
42
|
-
($container.hasClass('answerText') || $container.parents('div.answerText').toArray().length > 0) &&
|
43
|
-
!$container.parents('.answer').hasClass('autograded'));
|
44
|
-
})
|
45
|
-
.flatMapLatest(openPopupFromRange)
|
46
|
-
.onValue(addAnnotation);
|
47
|
-
$containerElement
|
48
|
-
.asEventStream('mousedown')
|
49
|
-
.filter((e) => !$(e.target).closest('.add-annotation-text').length && !$(e.target).closest('.annotation-message').length)
|
50
|
-
.merge($containerElement.asEventStream('keyup').filter((e) => e.keyCode === ESC))
|
51
|
-
.onValue(() => {
|
52
|
-
getBrowserTextSelection().removeAllRanges();
|
53
|
-
// Render annotations for all answers that have popup open. This clears the popup and annotation that was merged for rendering before opening popup.
|
54
|
-
$('.add-annotation-popup').each((index, popup) => {
|
55
|
-
answerAnnotationsRendering.renderAnnotationsForElement($(popup).closest('.answerText'));
|
56
|
-
});
|
57
|
-
});
|
58
|
-
$containerElement
|
59
|
-
.asEventStream('mousedown', 'img, .attachmentWrapper')
|
60
|
-
.filter((e) => e.button === 0)
|
61
|
-
.doAction(() => {
|
62
|
-
isMouseDown = true;
|
63
|
-
return false;
|
64
|
-
})
|
65
|
-
.flatMapLatest((se) => {
|
66
|
-
const $target = $(se.currentTarget);
|
67
|
-
// We have attached `mousedown` to `.attachmentWrapper` as well, so
|
68
|
-
// the target isn't necessarily the image itself.
|
69
|
-
const $image = $target.is('img') ? $target : $target.find('img');
|
70
|
-
const $targetAnswerText = $image.on('dragstart', false).closest('.answerText');
|
71
|
-
const attachmentIndex = $targetAnswerText.find('img').index($image);
|
72
|
-
// The event will come from the topmost `.answerText`, which isn't
|
73
|
-
// necessarily the correct one. So we need to find the correct
|
74
|
-
// `.answerText` to add the annotation to.
|
75
|
-
const $answerText = $targetAnswerText
|
76
|
-
.parent()
|
77
|
-
.children('.answerText' + (isCensor ? '.is_censor' : '.is_pregrading'));
|
78
|
-
const $attachmentWrapper = answerAnnotationsRendering.wrapAttachment($answerText.find(`img:eq(${attachmentIndex})`));
|
79
|
-
let $shape;
|
80
|
-
const bbox = $attachmentWrapper[0].getBoundingClientRect();
|
81
|
-
const startX = clamp((se.clientX - bbox.left) / bbox.width);
|
82
|
-
const startY = clamp((se.clientY - bbox.top) / bbox.height);
|
83
|
-
const lineThresholdPx = 10;
|
84
|
-
const mouseUpE = $(window)
|
85
|
-
.asEventStream('mouseup')
|
86
|
-
.doAction(() => {
|
87
|
-
isMouseDown = false;
|
88
|
-
});
|
89
|
-
return $(window)
|
90
|
-
.asEventStream('mousemove')
|
91
|
-
.takeUntil(mouseUpE)
|
92
|
-
.flatMapLatest((e) => {
|
93
|
-
const currentX = clamp((e.clientX - bbox.left) / bbox.width);
|
94
|
-
const currentY = clamp((e.clientY - bbox.top) / bbox.height);
|
95
|
-
const isVerticalLine = Math.abs(se.clientX - e.clientX) <= lineThresholdPx;
|
96
|
-
const isHorizontalLine = Math.abs(se.clientY - e.clientY) <= lineThresholdPx;
|
97
|
-
const type = isVerticalLine || isHorizontalLine ? 'line' : 'rect';
|
98
|
-
switch (type) {
|
99
|
-
case 'rect': {
|
100
|
-
return {
|
101
|
-
type: 'rect',
|
102
|
-
attachmentIndex,
|
103
|
-
x: Math.min(startX, currentX),
|
104
|
-
y: Math.min(startY, currentY),
|
105
|
-
width: Math.abs(currentX - startX),
|
106
|
-
height: Math.abs(currentY - startY),
|
107
|
-
};
|
108
|
-
}
|
109
|
-
case 'line': {
|
110
|
-
return {
|
111
|
-
type: 'line',
|
112
|
-
attachmentIndex,
|
113
|
-
x1: isVerticalLine ? startX : Math.min(startX, currentX),
|
114
|
-
y1: isHorizontalLine ? startY : Math.min(startY, currentY),
|
115
|
-
x2: isVerticalLine ? startX : Math.max(startX, currentX),
|
116
|
-
y2: isHorizontalLine ? startY : Math.max(startY, currentY),
|
117
|
-
};
|
118
|
-
}
|
119
|
-
}
|
120
|
-
})
|
121
|
-
.doAction((shape) => {
|
122
|
-
const doAppend = $shape == null;
|
123
|
-
$shape = answerAnnotationsRendering.renderShape(shape, $shape);
|
124
|
-
if (doAppend) {
|
125
|
-
$attachmentWrapper.append($shape);
|
126
|
-
}
|
127
|
-
})
|
128
|
-
.last()
|
129
|
-
.flatMapLatest((shape) => {
|
130
|
-
const $answerText = $attachmentWrapper.closest('.answerText');
|
131
|
-
const attachmentWrapperPosition = $attachmentWrapper.position();
|
132
|
-
const shapePosition = $shape.position();
|
133
|
-
const popupCss = {
|
134
|
-
position: 'absolute',
|
135
|
-
top: attachmentWrapperPosition.top + shapePosition.top + $shape.height() + 4,
|
136
|
-
left: attachmentWrapperPosition.left + shapePosition.left,
|
137
|
-
};
|
138
|
-
return openPopup($answerText, shape, '', popupCss);
|
139
|
-
});
|
140
|
-
})
|
141
|
-
.onValue(addAnnotation);
|
142
|
-
function clamp(n) {
|
143
|
-
return _.clamp(n, 0, 1);
|
144
|
-
}
|
145
|
-
function selectionHasNothingToUnderline(range) {
|
146
|
-
const contents = range.cloneContents();
|
147
|
-
let hasImages = _.includes(_.toArray(contents.childNodes).map((x) => x.tagName), 'IMG');
|
148
|
-
return contents.textContent.length === 0 && !hasImages;
|
149
|
-
}
|
150
|
-
function preventDragSelectionFromOverlappingCensorAnswerText($containerElem) {
|
151
|
-
if (isCensor) {
|
152
|
-
$containerElem.on('mousedown mouseup', (e) => {
|
153
|
-
$('.answerText.is_censor .answerAnnotation').toggleClass('no-mouse', e.type === 'mousedown');
|
154
|
-
});
|
155
|
-
}
|
156
|
-
}
|
157
|
-
function getPopupCss(range) {
|
158
|
-
const container = $(range.startContainer).closest('.answer-text-container').get(0);
|
159
|
-
const boundingRect = range.getBoundingClientRect();
|
160
|
-
if (container) {
|
161
|
-
const containerRect = container.getBoundingClientRect();
|
162
|
-
return {
|
163
|
-
position: 'absolute',
|
164
|
-
top: boundingRect.bottom - containerRect.top + 10,
|
165
|
-
left: boundingRect.left - containerRect.left,
|
166
|
-
};
|
167
|
-
}
|
168
|
-
else {
|
169
|
-
return {
|
170
|
-
position: 'absolute',
|
171
|
-
top: 0,
|
172
|
-
left: 0,
|
173
|
-
};
|
174
|
-
}
|
175
|
-
}
|
176
|
-
function openPopupFromRange(range) {
|
177
|
-
const popupCss = getPopupCss(range);
|
178
|
-
let $answerText = $(range.startContainer).closest('.answerText');
|
179
|
-
const annotationPos = answerAnnotationsRendering.calculatePosition($answerText, range);
|
180
|
-
if (isCensor && !$answerText.hasClass('is_censor')) {
|
181
|
-
// render annotations to censor answer text element even if event cought via double click
|
182
|
-
$answerText = $(range.startContainer).closest('.answer').find('.answerText.is_censor');
|
183
|
-
}
|
184
|
-
const messages = answerAnnotationsRendering.getOverlappingMessages($answerText, annotationPos.startIndex, annotationPos.length);
|
185
|
-
const renderedMessages = messages.reduceRight((msg, str) => `${str} / ${msg}`, '');
|
186
|
-
getBrowserTextSelection().removeAllRanges();
|
187
|
-
// Merge and render annotation to show what range it will contain if annotation gets added
|
188
|
-
// Merged annotation not saved yet, so on cancel previous state is rendered
|
189
|
-
const mergedAnnotations = answerAnnotationsRendering.mergeAnnotation($answerText, annotationPos);
|
190
|
-
answerAnnotationsRendering.renderGivenAnnotations($answerText, mergedAnnotations);
|
191
|
-
return openPopup($answerText, annotationPos, renderedMessages, popupCss);
|
192
|
-
}
|
193
|
-
function openPopup($answerText, annotation, message, popupCss) {
|
194
|
-
const $popup = localize($('<div class="popup add-annotation-popup"><input class="add-annotation-text" type="text" value=""/><i class="fa fa-comment"></i><button data-i18n="arpa.annotate">Merkitse</button></div>'));
|
195
|
-
$popup.get(0).firstChild.value = message;
|
196
|
-
$answerText.append($popup);
|
197
|
-
$popup.css(popupCss);
|
198
|
-
$popup.find('input').focus();
|
199
|
-
return $popup
|
200
|
-
.find('button')
|
201
|
-
.asEventStream('mousedown')
|
202
|
-
.merge($popup.asEventStream('keyup').filter((e) => e.keyCode === ENTER))
|
203
|
-
.map(() => {
|
204
|
-
const message = $('.add-annotation-text').val().trim();
|
205
|
-
return {
|
206
|
-
$answerText,
|
207
|
-
annotation: _.assign({}, annotation, { message }),
|
208
|
-
};
|
209
|
-
});
|
210
|
-
}
|
211
|
-
function addAnnotation(annotationData) {
|
212
|
-
if (annotationData.annotation.length > 0 || annotationData.annotation.type != null) {
|
213
|
-
const data = answerAnnotationsRendering.get(annotationData.$answerText);
|
214
|
-
const annotations = data
|
215
|
-
? answerAnnotationsRendering.mergeAnnotation(annotationData.$answerText, annotationData.annotation)
|
216
|
-
: [annotationData.annotation];
|
217
|
-
saveAnnotation(getAnswerId(annotationData.$answerText), annotations);
|
218
|
-
answerAnnotationsRendering.renderAnnotationsForElement(annotationData.$answerText, annotations);
|
219
|
-
}
|
220
|
-
}
|
221
|
-
}
|
222
|
-
}
|
223
|
-
export function setupAnnotationDisplaying($answers, isCensor) {
|
224
|
-
let fadeOutDelayTimeout = void 0;
|
225
|
-
$answers.on('mouseenter', '.answerAnnotation', (event) => {
|
226
|
-
const $annotation = $(event.target);
|
227
|
-
if (isMouseDown || addAnnotationPopupIsVisible() || hasTextSelectedInAnswerText()) {
|
228
|
-
return;
|
229
|
-
}
|
230
|
-
clearTimeout(fadeOutDelayTimeout);
|
231
|
-
if (popupAlreadyShownForCurrentAnnotation(event)) {
|
232
|
-
$annotation.find('.remove-annotation-popup').stop().show().css({ opacity: 1 });
|
233
|
-
}
|
234
|
-
else {
|
235
|
-
clearAllRemovePopups();
|
236
|
-
renderRemovePopup(event);
|
237
|
-
}
|
238
|
-
});
|
239
|
-
$answers.on('mouseleave', '.answerAnnotation', (event) => {
|
240
|
-
fadeOutDelayTimeout = setTimeout(() => {
|
241
|
-
removeRemovePopup(event);
|
242
|
-
}, 400);
|
243
|
-
});
|
244
|
-
function popupAlreadyShownForCurrentAnnotation(event) {
|
245
|
-
const mouseOverAnnotationElem = $(event.target).closest('.answerAnnotation')[0];
|
246
|
-
const popupsCurrentAnnotationElem = $('.remove-annotation-popup:visible').closest('.answerAnnotation')[0];
|
247
|
-
return (event &&
|
248
|
-
mouseOverAnnotationElem &&
|
249
|
-
popupsCurrentAnnotationElem &&
|
250
|
-
mouseOverAnnotationElem.isEqualNode(popupsCurrentAnnotationElem));
|
251
|
-
}
|
252
|
-
function addAnnotationPopupIsVisible() {
|
253
|
-
return $('.add-annotation-popup').is(':visible');
|
254
|
-
}
|
255
|
-
function clearAllRemovePopups() {
|
256
|
-
$('.remove-annotation-popup').remove();
|
257
|
-
}
|
258
|
-
function renderRemovePopup(event) {
|
259
|
-
const $annotation = $(event.currentTarget);
|
260
|
-
const $popup = popupWithMessage($annotation, $annotation.attr('data-message'));
|
261
|
-
$annotation.append($popup);
|
262
|
-
// Calculate limits for preventing overflow on either side
|
263
|
-
const left = inlineLeftOffset(event.currentTarget);
|
264
|
-
const pageMargin = 8;
|
265
|
-
const leftLimit = -left + pageMargin;
|
266
|
-
const rightLimit = $(window).width() - left - $popup.outerWidth() - pageMargin;
|
267
|
-
const css = {
|
268
|
-
left: Math.min(Math.max(mouseOffsetLeft(event) - $popup.outerWidth() / 2, leftLimit), rightLimit),
|
269
|
-
};
|
270
|
-
$popup.css(css);
|
271
|
-
$popup.fadeIn();
|
272
|
-
}
|
273
|
-
function removeRemovePopup(event) {
|
274
|
-
const $annotation = $(event.target).closest('.answerAnnotation');
|
275
|
-
const popup = $annotation.find('.remove-annotation-popup');
|
276
|
-
popup.fadeOut(100, () => {
|
277
|
-
popup.remove();
|
278
|
-
});
|
279
|
-
}
|
280
|
-
function popupWithMessage($annotation, message) {
|
281
|
-
const $messageContainer = $('<span class="popup remove-annotation-popup"><span class="annotation-message"></span></span>');
|
282
|
-
$messageContainer.find('.annotation-message').text(message || '-');
|
283
|
-
if (isAllowedToRemoveAnnotation($annotation)) {
|
284
|
-
$messageContainer.append('<i class="fa fa-times-circle remove-annotation-area"></i>');
|
285
|
-
}
|
286
|
-
return $messageContainer;
|
287
|
-
}
|
288
|
-
function isAllowedToRemoveAnnotation($annotation) {
|
289
|
-
return isPregradingAndScoringEnabled() || isCensorAndOwnAnnotation();
|
290
|
-
function isPregradingAndScoringEnabled() {
|
291
|
-
const $body = $('body');
|
292
|
-
return $body.hasClass('is_pregrading') && !$body.hasClass('preview');
|
293
|
-
}
|
294
|
-
function isCensorAndOwnAnnotation() {
|
295
|
-
return isCensor && $annotation.closest('.answerText').hasClass('is_censor');
|
296
|
-
}
|
297
|
-
}
|
298
|
-
function inlineLeftOffset(element) {
|
299
|
-
return $(element).offsetParent().offset().left + element.offsetLeft;
|
300
|
-
}
|
301
|
-
function mouseOffsetLeft(mousemove) {
|
302
|
-
const annotation = mousemove.target;
|
303
|
-
const annotationLeftOffsetFromPageEdge = inlineLeftOffset(annotation);
|
304
|
-
return mousemove.pageX - annotationLeftOffsetFromPageEdge;
|
305
|
-
}
|
306
|
-
}
|
307
|
-
function getAnswerId($answerText) {
|
308
|
-
return $answerText.closest('.answer').attr('data-answer-id');
|
309
|
-
}
|
310
|
-
function getBrowserTextSelection() {
|
311
|
-
return typeof window.getSelection !== 'undefined'
|
312
|
-
? window.getSelection()
|
313
|
-
: typeof document.selection !== 'undefined' && document.selection.type === 'Text'
|
314
|
-
? document.selection
|
315
|
-
: undefined;
|
316
|
-
}
|
317
|
-
function hasTextSelectedInAnswerText() {
|
318
|
-
const selection = getBrowserTextSelection();
|
319
|
-
return (selection && selectionInAnswerText(selection) && (isRangeSelection(selection) || textSelectedInRange(selection)));
|
320
|
-
function selectionInAnswerText(sel) {
|
321
|
-
if (sel.type === 'None' || sel.type === 'Caret' || sel.rangeCount === 0)
|
322
|
-
return false;
|
323
|
-
const $startContainer = $(sel.getRangeAt(0).startContainer);
|
324
|
-
return (sel.rangeCount &&
|
325
|
-
$startContainer.closest('.answerText').length === 1 &&
|
326
|
-
$startContainer.closest('.remove-annotation-popup').length === 0);
|
327
|
-
}
|
328
|
-
function isRangeSelection(sel) {
|
329
|
-
return _.get(sel, 'type', '') === 'Range';
|
330
|
-
}
|
331
|
-
function textSelectedInRange(sel) {
|
332
|
-
const range = sel.getRangeAt(0);
|
333
|
-
return (_.get(sel, 'rangeCount', 0) > 0 &&
|
334
|
-
(range.toString().length > 0 || isParentContainer(range.startContainer) || isParentContainer(range.endContainer)));
|
335
|
-
}
|
336
|
-
function isParentContainer(container) {
|
337
|
-
return container && container.classList && container.classList.contains('answerText');
|
338
|
-
}
|
339
|
-
}
|
340
|
-
//# sourceMappingURL=editAnnotations.js.map
|