MCPcopy
hub / github.com/ocsjs/ocsjs / workOrExam

Function workOrExam

packages/scripts/src/projects/cx.ts:741–988  ·  view source on GitHub ↗
(
	type: 'work' | 'exam' = 'work',
	{
		answererWrappers,
		period,
		thread,
		redundanceWordsText,
		answerSeparators,
		preview_mode
	}: CommonWorkOptions & {
		// 整卷预览模式
		preview_mode: boolean;
	}
)

Source from the content-addressed store, hash-verified

739});
740
741function workOrExam(
742 type: 'work' | 'exam' = 'work',
743 {
744 answererWrappers,
745 period,
746 thread,
747 redundanceWordsText,
748 answerSeparators,
749 preview_mode
750 }: CommonWorkOptions & {
751 // 整卷预览模式
752 preview_mode: boolean;
753 }
754) {
755 $message.info(`开始${type === 'work' ? '作业' : '考试'}`);
756
757 if (preview_mode) {
758 CommonProject.scripts.workResults.methods.init({
759 questionPositionSyncHandlerType: 'cx'
760 });
761 }
762
763 // 处理作业和考试题目的方法
764 const workOrExamQuestionTitleTransform = (titles: (HTMLElement | undefined)[]) => {
765 // 是否为多个小题的题目
766 const is_multiple_question = titles.length > 1;
767 const optimizationTitle = titles
768 .map((el, i) => {
769 if (el) {
770 const titleCloneEl = el.cloneNode(true) as HTMLElement;
771 const childNodes = titleCloneEl.childNodes;
772 // 一般多小题题目只有第一个 title 存在题型文本
773 if (i === 0) {
774 // 删除序号
775 childNodes[0]?.remove();
776 // 删除题型
777 childNodes[0]?.remove();
778 }
779 // 显示图片链接在题目中
780 return optimizationElementWithImage(titleCloneEl, true).innerText;
781 }
782 return '';
783 })
784 .join('\n');
785
786 return removeRedundantWords(
787 StringUtils.of(optimizationTitle)
788 .nowrap(is_multiple_question ? '\n' : ' ')
789 .nospace()
790 .toString()
791 .trim(),
792 redundanceWordsText.split('\n')
793 );
794 };
795
796 // 这里跟章节测试的连线题不一样,章节测试是新版连线题
797 /** 新建答题器 */
798 const worker = new OCSWorker({

Callers 1

oncompleteFunction · 0.70

Calls 10

doWorkMethod · 0.95
splitAnswerFunction · 0.90
getQuestionTypeFunction · 0.85
readerAndFillHandleFunction · 0.85
getNextBtnFunction · 0.70
initMethod · 0.65

Tested by

no test coverage detected