@hongtangyun/puzzle-libs
v0.2.12
Published
``` import {TestPaper, TypeEnum} from '@hongtangyun/puzzle-libs' import '@hongtangyun/puzzle-libs/dist/styles.css'
Downloads
18
Readme
import {TestPaper, TypeEnum} from '@hongtangyun/puzzle-libs'
import '@hongtangyun/puzzle-libs/dist/styles.css'
1. 编辑组件
1. 题目编辑
import { HTMLEditorLibs } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';
<HTMLEditorLibs.EditorQ
upConfig={upConfig}
data={initData}
bigQType={initData?.type ? initData?.type : undefined}
onOk={async (data) => {
await handleSave(data);
}}
onCancel={() => {
}}
onGetUpConfig={async () => {
const _up = await getStorageConfig('COS');
return {
type: _up.type,
cosCof: {
bucket: _up.data.bucket,
region: _up.data.region,
startTime: _up.data.startTime,
expiredTime: _up.data.expiredTime,
prefix: _up.data.prefix,
tmpSecretKey: _up.data.credentials.tmpSecretKey,
tmpSecretId: _up.data.credentials.tmpSecretId,
sessionToken: _up.data.credentials.sessionToken,
},
};
}}
/>
2. 题目预览
import { HtmlPaperLibs } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';
<HtmlPaperLibs.ExpandedRowRenderQ
data={record.sourceData}
/>
3. 试卷编辑
import { EditorPaper } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';
<EditorPaper
type="HTML"
config={{
initData: initData,
onGetUpConfig: async () => {
const _up = await getStorageConfig('COS');
return {
type: _up.type,
cosCof: {
bucket: _up.data.bucket,
region: _up.data.region,
startTime: _up.data.startTime,
expiredTime: _up.data.expiredTime,
prefix: _up.data.prefix,
tmpSecretKey: _up.data.credentials.tmpSecretKey,
tmpSecretId: _up.data.credentials.tmpSecretId,
sessionToken: _up.data.credentials.sessionToken,
},
};
},
onChagne: (data) => {
setEditorData(data);
},
getTopicList: async (page, pageSize, params?: any) => {
return await getPuzzlesTopic({
...params,
page,
pageSize,
});
},
onTopicTags: async (page, pageSize, params?: any) => {
return await getPuzzlesTagsTopic({
...params,
page,
pageSize,
});
},
}}
/>
4. 试卷预览
import { TestPaper, TypeEnum } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';
<TestPaper
layout="all"
answer={
{
// '2ec9b9c187beaae90fc558a056ebbc30': ['ccc'],
// '5b576156cc3228a511ded14589ea859b': ['xxx'],
// '3fee91715e83e61acbffad2889bbde0a': ['1234'],
// '54c8a4770e2d88d19644a3d6163ef5c9': [
// 'https://hongtangyun-1252095557.cos.ap-chengdu.myqcloud.com/hongtangyun_access/room/625e56bef7e409145c6d882b/1/2022_12_07_18/ac64cf03820a8b8b55f681020938b170.wav',
// ],
}
}
watermark="测试用户-预览"
width={windowSize.width}
height={windowSize.height}
currentPaper={initData}
readonly={true}
showTip={true}
onChange={async (changeValue, allValue, paperInfo) => {}}
onSubmit={async (data) => {
console.log('onSubmit: ', data);
}}
onBack={() => {}}
/>
5. 试卷做答
import { TestPaper, TypeEnum } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';
<TestPaper
layout="all"
answer={
{
// '2ec9b9c187beaae90fc558a056ebbc30': ['ccc'],
// '5b576156cc3228a511ded14589ea859b': ['xxx'],
// '3fee91715e83e61acbffad2889bbde0a': ['1234'],
// '54c8a4770e2d88d19644a3d6163ef5c9': [
// 'https://hongtangyun-1252095557.cos.ap-chengdu.myqcloud.com/hongtangyun_access/room/625e56bef7e409145c6d882b/1/2022_12_07_18/ac64cf03820a8b8b55f681020938b170.wav',
// ],
}
}
watermark="测试用户-预览"
width={windowSize.width}
height={windowSize.height}
currentPaper={initData}
readonly={false}
showTip={false}
onChange={async (changeValue, allValue, paperInfo) => {}}
onSubmit={async (data) => {
console.log('onSubmit: ', data);
}}
onBack={() => {}}
/>
6. 试卷阅卷
import { TestPaper, TypeEnum } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';
<TestPaper
layout="all"
/**
* 批改试卷
*/
isCorrection?: boolean;
/**
* 批改试卷回调
* @param data
* @returns
*/
onCorrection?: (
data:
| Array<{ score: number; question: SubItem }>
| { score: number; question: SubItem },
) => Promise<boolean>;
/**
* 获取当前用户批改试卷分数
* @param id 题目id
* @returns
*/
onGetCorrectionScore?: (id: string) => Promise<number | undefined>;
answer={
{
// '2ec9b9c187beaae90fc558a056ebbc30': ['ccc'],
// '5b576156cc3228a511ded14589ea859b': ['xxx'],
// '3fee91715e83e61acbffad2889bbde0a': ['1234'],
// '54c8a4770e2d88d19644a3d6163ef5c9': [
// 'https://hongtangyun-1252095557.cos.ap-chengdu.myqcloud.com/hongtangyun_access/room/625e56bef7e409145c6d882b/1/2022_12_07_18/ac64cf03820a8b8b55f681020938b170.wav',
// ],
}
}
watermark="测试用户-预览"
width={windowSize.width}
height={windowSize.height}
currentPaper={initData}
readonly={true}
showTip={true}
onChange={async (changeValue, allValue, paperInfo) => {}}
onSubmit={async (data) => {
console.log('onSubmit: ', data);
}}
onBack={() => {}}
/>
7. 参数
upConfig = {
type: _up.type,
cosCof: {
bucket: _up.data.bucket,
region: _up.data.region,
startTime: _up.data.startTime,
expiredTime: _up.data.expiredTime,
prefix: _up.data.prefix,
tmpSecretKey: _up.data.credentials.tmpSecretKey,
tmpSecretId: _up.data.credentials.tmpSecretId,
sessionToken: _up.data.credentials.sessionToken,
},
}
utils
import { utils } from '@hongtangyun/puzzle-libs';
// class100题目导入
utils.class100QInput
// class100题目导出
utils.class100QExport
// class100试卷导入
utils.class100PaperInput
// class100试卷导出
utils.class100PaperExport
// 编辑器试卷转class100试卷
utils.editorPaperToClass100Paper
// 试卷值转class100值
utils.editorValuesToClass100Values
// 试卷标记转class100标记
utils.editorFlagsToClass100Flags
// 提交试卷 - 检测 必答是否完成
utils.checkPaperAnswerInComplete
// class100提交试卷 - 检测 必答是否完成
utils.checkPaperAnswerIsCompleteForClass100
// 判断富文本为空
utils.isContentEmpty