Commit 3c618f37 authored by Tt's avatar Tt

表单完成

parent f2bf7b06
export const defaultData = { export const defaultData = { "questions": [{ "parts": [{ "id": "166668702213640281", "answer": "freedow", "options": [{ "blocks": [{ "type": "img", "txt": "", "line": "", "img": "", "tag": "", "image": "http://staging-teach.cdn.ireadabc.com/19ac75d2de5455d268eaef8184bf805b.png" }] }, { "blocks": [{ "type": "line", "txt": "", "line": 5, "img": "", "tag": "" }, { "type": "txt", "txt": "", "line": "", "img": "", "tag": "", "text": "do you go to the park?" }] }, { "blocks": [{ "type": "txt", "txt": "", "line": "", "img": "", "tag": "", "text": "On saturdays freedow" }] }] }, { "id": "1666687612725869271", "answer": "fish", "options": [{ "blocks": [{ "type": "img", "txt": "", "line": "", "img": "", "tag": "", "image": "http://staging-teach.cdn.ireadabc.com/3f0f2572da257eedbec51f8d05e2a7d8.png" }] }] }, { "id": "1666687632465177361", "answer": "want", "options": [{ "blocks": [{ "type": "txt", "txt": "", "line": "", "img": "", "tag": "", "text": "Dave" }, { "type": "line", "txt": "", "line": 5, "img": "", "tag": "" }, { "type": "txt", "txt": "", "line": "", "img": "", "tag": "", "text": "want" }] }] }, { "id": "1666687646496548891", "answer": "red", "options": [{ "blocks": [{ "type": "txt", "txt": "", "line": "", "img": "", "tag": "", "text": "The fish color is " }] }, { "blocks": [{ "type": "line", "txt": "", "line": 5, "img": "", "tag": "" }, { "type": "txt", "txt": "", "line": "", "img": "", "tag": "", "text": "answer red." }] }] }] }], "title": "单词填空", "imgAni": { "ske": { "url": "http://staging-teach.cdn.ireadabc.com/4ec3da85d888ad3c5c57e10fca728499.json", "name": "鱼1_ske.json" }, "tex": { "url": "http://staging-teach.cdn.ireadabc.com/2c52380a3f3cdd3f5d38870bee2c9ffd.json", "name": "鱼1_tex.json" }, "png": { "url": "http://staging-teach.cdn.ireadabc.com/3ca112e3bb312d5e9b7182bbb97c616d.png", "name": "鱼1_tex.png" } }, "startAudio": "http://staging-teach.cdn.ireadabc.com/e587cf79c91d1cc4339540bb04b2aad0_l.mp3", "blockStruct": [{ "pId": "166668702213640281", "point": { "x": 3, "y": 6 }, "answer": "freedow" }, { "pId": "1666687612725869271", "point": { "x": 0, "y": 0 }, "answer": "fish" }, { "pId": "1666687632465177361", "point": { "x": 2, "y": 2 }, "answer": "want" }, { "pId": "1666687646496548891", "point": { "x": 3, "y": 4 }, "answer": "red" }, { "pId": "1666690945919654191", "point": { "x": 6, "y": 0 }, "answer": "" }, { "pId": "1666690947164283561", "point": { "x": 7, "y": 0 }, "answer": "" }, { "pId": "1666690948198775141", "point": { "x": 8, "y": 0 }, "answer": "" }, { "pId": "1666690949365322761", "point": { "x": 9, "y": 0 }, "answer": "" }, { "pId": "1666690950490929471", "point": { "x": 10, "y": 0 }, "answer": "" }, { "pId": "1666690951587641301", "point": { "x": 11, "y": 0 }, "answer": "" }, { "pId": "1666691011251823481", "point": { "x": 1, "y": 2 }, "answer": "" }, { "pId": "1666691012456843041", "point": { "x": 0, "y": 2 }, "answer": "" }, { "pId": "1666691014542512891", "point": { "x": 4, "y": 0 }, "answer": "" }, { "pId": "1666691015690655041", "point": { "x": 5, "y": 0 }, "answer": "" }, { "pId": "1666691022128352361", "point": { "x": 6, "y": 4 }, "answer": "" }, { "pId": "1666691023272815341", "point": { "x": 7, "y": 4 }, "answer": "" }, { "pId": "1666691024581239481", "point": { "x": 6, "y": 5 }, "answer": "" }, { "pId": "1666691025624146431", "point": { "x": 5, "y": 5 }, "answer": "" }, { "pId": "1666691027374885051", "point": { "x": 5, "y": 7 }, "answer": "" }, { "pId": "1666691030049556651", "point": { "x": 6, "y": 7 }, "answer": "" }, { "pId": "1666691031985800491", "point": { "x": 4, "y": 8 }, "answer": "" }, { "pId": "1666691033412905401", "point": { "x": 0, "y": 8 }, "answer": "" }], "blocks": [[{ "val": "f" }, { "val": "i" }, { "val": "s" }, { "val": "h" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "w" }, { "val": "a" }, { "val": "n" }, { "val": "t" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "r" }, { "val": "e" }, { "val": "d" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "f" }, { "val": "r" }, { "val": "e" }, { "val": "e" }, { "val": "d" }, { "val": "o" }, { "val": "w" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }], [{ "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }, { "val": "" }]], "audioName": "" }
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png", \ No newline at end of file
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
...@@ -65,10 +65,11 @@ export class ComponentBase { ...@@ -65,10 +65,11 @@ export class ComponentBase {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key, it = this.item,audioName) { onAudioUploadSuccess(e, key, it = this.item, audioName) {
let url = e.url; let url = e.url;
it[key] = url; it[key] = url;
it[audioName] = e.name || ""; it[audioName] = e.audioName || "";
console.log(JSON.stringify(e));
this.save(); this.save();
} }
......
This diff is collapsed.
...@@ -11,27 +11,39 @@ import { ComponentBase } from './ComponentBase'; ...@@ -11,27 +11,39 @@ import { ComponentBase } from './ComponentBase';
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy { export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "ngt10_tydh"; saveKey = "ngt14_czm";
// 储存对象 // 储存对象
item: any = { item: any = {
questions: [{
parts: [],
}],
title: '单词填空',
imgAni: { imgAni: {
ske: {}, ske: {},
tex: {}, tex: {},
png: {} png: {}
}, },
tipSwitch: 1,//提示功能开关
startAudio: "", startAudio: "",
audioName: "", blockStruct: [
title: "听音对话", // {
//1 ~ 6 个 // pId: null,
questions: [], // point: { x: 0, y: 0 }
// }
],
blocks: [
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }],
[{ val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }, { val: '' }]]
}; };
// item: any = { init() {
// title: '幸运大转盘', this.autoBlocks();
// questionText: "亲爱的小玩家,游戏马上就要开始啦!请动动手指转动转盘,当转盘停止,注意观察指针指向的魔法图片,并大声说出魔法咒语,魔法咒语正确,你就可以获得一张魔法卡牌。 游戏结束后,根据获得的魔法卡牌数量,你将获得相应的能量石奖励!开始挑战吧!", }
// questionTextAudio: "http://staging-teach.cdn.ireadabc.com/18ebee93b3eabcd55649a01366431af7.mp3",
// questions: [],
// };
isVisible = false; isVisible = false;
deleteTitle = "是否删除题目"; deleteTitle = "是否删除题目";
...@@ -49,19 +61,18 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -49,19 +61,18 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.handleCancel(); this.handleCancel();
} }
deleteBgAudio() {
this.item.bgAudio = "";
this.item.audioBgName = "";
this.save();
}
//题---question 块--part 条---option 节点---block
addQuestion() { addQuestion() {
if (this.item.questions.length == 6) return;
this.item.questions.push({ this.item.questions.push({
type: 'img', parts: [],
audio: '',
text: '',
image: '',
time: null,
audioName: "",
}); });
this.save(); this.save();
} }
removeQuestion(idx) { removeQuestion(idx) {
this.openDelete("确定删除题目?", () => { this.openDelete("确定删除题目?", () => {
this.item.questions.splice(idx, 1); this.item.questions.splice(idx, 1);
...@@ -74,25 +85,144 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -74,25 +85,144 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.save(); this.save();
} }
addOption(idx) { addPart(idx) {
if (this.item.questions[idx].options.length == 4) return; let count = 0;
this.item.questions[idx].options.push({ function randId() {
text: '', count++;
audio: '', let time = new Date().getTime();
image: '', let rand = Math.floor(Math.random() * 100000);
word: '', return `${time}${rand}${count}`
time: '', }
this.item.questions[idx].parts.push({
id: randId(),
answer: '',
options: [],
}); });
this.save(); this.save();
} }
removePart(idx, pdx) {
this.openDelete("确定删除块?", () => {
this.item.questions[idx].parts.splice(pdx, 1);
this.save();
})
}
copyPart(idx, pdx) {
let data = this.item.questions[idx].parts[pdx]
this.item.questions[idx].parts.push(JSON.parse(JSON.stringify(data)));
this.save();
}
removeOption(idx, n) { addOption(idx, pdx) {
this.item.questions[idx].parts[pdx].options.push({
blocks: []
})
this.save();
}
removeOption(idx, pdx, n) {
this.openDelete("确定删除选项?", () => { this.openDelete("确定删除选项?", () => {
this.item.questions[idx].options.splice(n, 1); this.item.questions[idx].parts[pdx].options.splice(n, 1);
this.save(); this.save();
}) })
} }
addBlock(idx, pdx, odx, type) {
this.item.questions[idx].parts[pdx].options[odx].blocks.push({
type: type,
txt: '',//文本内容 line中的正确答案
line: '',
img: '',
tag: ''
})
}
removeBlock(idx, pdx, odx) {
this.openDelete("确定删除块?", () => {
this.item.questions[idx].parts[pdx].options[odx].blocks.pop();
this.save();
})
}
autoBlocks() {
let self = this;
function searchWord(x, y) {
let word = '';
self.item.blockStruct.forEach(struct => {
if (struct.point.y != y) return;//不是一行
if (struct.point.x <= x && struct.point.x + struct.answer.length - 1 >= x) {
word = struct.answer[x - struct.point.x];
}
})
return word;
}
let blocks = [];
for (let y = 0; y < 9; y++) {
const line = [];
for (let x = 0; x < 12; x++) {
let val = searchWord(x, y);
line.push({ val: val })
}
blocks.push(line);
}
this.item.blocks = blocks;
}
onSelectBlock(e, x, y, val, block) {
if (this.item.blockStruct.some(bs => bs.pId == val.id)) {
alert("此题已设置");
return
}
if (x + val.answer.length > 12) {
alert("长度不足,应向前移动" + Math.abs((12 - x - val.answer.length)) + "");
return;
}
this.item.blockStruct.push({
pId: val.id,
point: { x, y },
answer: val.answer
})
this.autoBlocks();
this.save();
}
onSelectBlockHide(e, x, y, block) {
if (block.val) return;
let count = 0;
function randId() {
count++;
let time = new Date().getTime();
let rand = Math.floor(Math.random() * 100000);
return `${time}${rand}${count}`
}
this.item.blockStruct.push({
pId: randId(),
point: { x, y },
answer: ''
})
this.autoBlocks();
this.save();
}
onSelectBlockClear(e, x, y, block) {
if (!block.val) return;
const self = this;
function searchBlock(x, y) {
let rblock = null;
self.item.blockStruct.forEach(struct => {
if (struct.point.y != y) return;//不是一行
if (struct.point.x <= x && struct.point.x + struct.answer.length - 1 >= x) {
rblock = struct
}
})
return rblock;
}
let val = searchBlock(x, y)
if (!val) return;
this.item.blockStruct = this.item.blockStruct.filter(bs => bs.pId != val.pId)
this.autoBlocks();
this.save();
}
ngChange() {
this.save();
}
onDragonBoneSave(e, item) { onDragonBoneSave(e, item) {
console.log(e); console.log(e);
this.save(); this.save();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment