Commit 98e170df authored by limingzhe's avatar limingzhe

feat: 暂时定稿

parent 56b9009f
...@@ -59,6 +59,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni ...@@ -59,6 +59,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
name: '填过程按钮', name: '填过程按钮',
rect: true, rect: true,
}, },
{
name: '过程展示区域',
rect: true,
},
]; ];
testValue = '123'; testValue = '123';
......
...@@ -310,6 +310,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -310,6 +310,7 @@ export class PlayComponent implements OnInit, OnDestroy {
templateQuesType; templateQuesType;
isFirstQues;
TYPE_SHORT_ANSWER = 'short_answer'; TYPE_SHORT_ANSWER = 'short_answer';
TYPE_SINGLE_CHOICE = 'single_choice'; TYPE_SINGLE_CHOICE = 'single_choice';
initData() { initData() {
...@@ -334,14 +335,18 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -334,14 +335,18 @@ export class PlayComponent implements OnInit, OnDestroy {
this.renderArr = []; this.renderArr = [];
this.topArr = []; this.topArr = [];
this.userResultPic = null;
this.userResultData = null; this.isFirstQues = true;
console.log(' in initData', this.data); console.log(' in initData', this.data);
this.userResultPic = null;
this.userResultData = null;
this.templateQuesType = this.data.contentObj.ques_type; this.templateQuesType = this.data.contentObj.ques_type;
this.quesNum = 0;
this.uploadUrl = (<any> window).courseware.uploadUrl(); this.uploadUrl = (<any> window).courseware.uploadUrl();
...@@ -942,6 +947,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -942,6 +947,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
showWriteBtn() { showWriteBtn() {
console.log( ' in showWriteBtn')
if (this.writeBtn) { if (this.writeBtn) {
this.writeBtn.visible = true; this.writeBtn.visible = true;
...@@ -2172,7 +2179,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2172,7 +2179,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.answerRectClick(); this.answerRectClick();
return; return;
} }
if (this.checkClickTarget(this.writeBtn)) { if (this.writeBtn.visible && this.checkClickTarget(this.writeBtn)) {
this.writeBtnClick(); this.writeBtnClick();
return; return;
} }
...@@ -2211,10 +2218,53 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2211,10 +2218,53 @@ export class PlayComponent implements OnInit, OnDestroy {
if (!courseware) { if (!courseware) {
return; return;
} }
// const data = {"msg":"success","url":"https://staging-teach.cdn.ireadabc.com/a509c85b5730a8459381551f926fd90e.png","ppt_html":"https://staging-teach.cdn.ireadabc.com/ppt/a509c85b5730a8459381551f926fd90e/index.html"}
// this.setWriteAreaPic(data);
courseware.activeWhiteBoard((data) => { courseware.activeWhiteBoard((data) => {
// TODO 公式编辑器返回的结果 // TODO 公式编辑器返回的结果
console.log('activeWhiteBoard data: ', data); const dataObj = JSON.parse(data);
console.log('activeWhiteBoard data: ', dataObj);
this.setWriteAreaPic(dataObj);
});
}
setWriteAreaPic(data) {
if (!data.url) {
return;
}
this.writeBtn.visible = false;
const writeAreaRect = this.writeAreaRect;
let pic = writeAreaRect.pic
if (!pic) {
pic = new MySprite();
writeAreaRect.addChild(pic);
pic.x = writeAreaRect.width / 2;
pic.y = writeAreaRect.height / 2;
}
pic.load(data.url).then(img => {
const sx = writeAreaRect.width / pic.width;
const sy = writeAreaRect.height / pic.height;
const s = Math.min(sx, sy);
pic.setScaleXY(s);
}); });
writeAreaRect.pic = pic;
writeAreaRect.visible = true;
} }
videoBtnClick() { videoBtnClick() {
...@@ -2236,6 +2286,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2236,6 +2286,14 @@ export class PlayComponent implements OnInit, OnDestroy {
return; return;
} }
if (this.answerRect.isClicked) {
return
}
this.answerRect.isClicked = true;
courseware.activeFormulaBoard((data) => { courseware.activeFormulaBoard((data) => {
// TODO // TODO
console.log('in activeFormulaBoard data 1 : ', data); console.log('in activeFormulaBoard data 1 : ', data);
...@@ -2255,6 +2313,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2255,6 +2313,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// } // }
// this.setShortAnswerData(data); // this.setShortAnswerData(data);
} }
setShortAnswerData(data) { setShortAnswerData(data) {
...@@ -2268,20 +2327,34 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2268,20 +2327,34 @@ export class PlayComponent implements OnInit, OnDestroy {
const s = Math.min(sx, sy); const s = Math.min(sx, sy);
labelPic.setScaleXY(s); labelPic.setScaleXY(s);
labelPic.x = labelPic.width / 2 * labelPic.scaleX + 10; labelPic.x = labelPic.width / 2 * labelPic.scaleX + 10;
labelPic.y = this.answerRect.height * this.answerRect.scaleY / 2; labelPic.y = this.answerRect.y;
}); });
this.quesNum ++;
this.canTouch = false;
if (formula && false) { const isRight = this.answerRectNode.data.mathLabel == formula
if (formula && isRight) {
this.changeAnswerBg('rightPic'); this.changeAnswerBg('rightPic');
} else { } else {
this.changeAnswerBg('wrongPic'); this.changeAnswerBg('wrongPic');
setTimeout(() => {
// this.changeChoiceArea(this.data.contentObj.choice_obj); if (!this.isFirstQues) {
return;
}
this.isFirstQues = false;
setTimeout(() => {
this.canTouch = true;
this.changeChoiceArea(this.data.contentObj.choice_obj);
}, 2000); }, 2000);
} }
} }
...@@ -2349,14 +2422,24 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2349,14 +2422,24 @@ export class PlayComponent implements OnInit, OnDestroy {
if (this.videoBtn) { if (this.videoBtn) {
this.videoBtn.visible = false; this.videoBtn.visible = false;
} }
if (this.writeAreaRect) {
this.writeAreaRect.visible = false;
}
if (this.writeBtn) {
this.writeBtn.visible = false;
}
} }
curOpItem; curOpItem;
quesNum;
optionItemClick(opItem) { optionItemClick(opItem) {
console.log('opItem: ', opItem); console.log('opItem: ', opItem);
const data = opItem.data; const data = opItem.data;
this.curOpItem = opItem; this.curOpItem = opItem;
this.changeAllOpItem(); this.changeAllOpItem();
this.quesNum ++;
if (data.is_right) { if (data.is_right) {
this.optionRight(opItem); this.optionRight(opItem);
} else { } else {
...@@ -2367,14 +2450,29 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2367,14 +2450,29 @@ export class PlayComponent implements OnInit, OnDestroy {
optionRight(opItem) { optionRight(opItem) {
this.changeOpItemBg(opItem, 'rightPic'); this.changeOpItemBg(opItem, 'rightPic');
this.canTouch = false;
if (this.data.contentObj.ques_type == this.TYPE_SHORT_ANSWER) {
setTimeout(() => {
this.canTouch = true;
this.cleanSmallTitle();
this.changeAnswerArea();
}, 2000);
}
} }
optionWrong(opItem) { optionWrong(opItem) {
this.changeOpItemBg(opItem, 'wrongPic'); this.changeOpItemBg(opItem, 'wrongPic');
this.canTouch = false; this.canTouch = false;
if (this.quesNum >= 3) {
return;
}
setTimeout(() => { setTimeout(() => {
this.canTouch = true; this.canTouch = true;
...@@ -3482,7 +3580,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3482,7 +3580,7 @@ export class PlayComponent implements OnInit, OnDestroy {
case "2": // 简答问题 case "2": // 简答问题
return this.setOneShortAnswerPic(data); return this.setOneShortAnswerPic(data);
case "3": // 简答题答案区 case "3": // 简答题答案区 和 内容
return this.setOneShortAnswerRect(data); return this.setOneShortAnswerRect(data);
...@@ -3491,6 +3589,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3491,6 +3589,9 @@ export class PlayComponent implements OnInit, OnDestroy {
case "5": // 书写过程按钮 case "5": // 书写过程按钮
return this.setOneBtnWrite(data); return this.setOneBtnWrite(data);
case "6": // 书写过程展示区域
return this.setOneWriteArea(data);
} }
...@@ -3498,6 +3599,66 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3498,6 +3599,66 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
writeAreaRect;
setOneWriteArea(data) {
console.log('setOneBtn data: ', data)
const saveRect = data.rect;
const item = new MySprite();
item.width = saveRect.width;
item.height = saveRect.height;
item.x = saveRect.x
item.y = saveRect.y
item['data'] = data;
this.writeAreaRect = item;
// item.alpha = 0;
// item.visible = false;
// const w = item.width;
// const h = item.height;
// const subH = h / 6;
// const ques = this.getMySprite(this.data.contentObj.ques_pic_url);
// const sx = w / ques.width;
// const sy = subH * 1.5 / ques.height;
// ques.setScaleXY(Math.min(sx, sy));
// ques.x = w / 2;
// ques.y = subH;
// item.addChild(ques);
// this.optionItemArr = [];
// const optionArr = this.data.contentObj.optionArr;
// const baseY = subH * 2.5;
// for (let i=0; i<4; i++) {
// if (optionArr[i]) {
// const opItem = this.getOneOpItem(optionArr[i]);
// const sx = w / opItem.width;
// const sy = subH / opItem.height;
// opItem.setScaleXY(Math.min(sx, sy));
// opItem.y = baseY + i * subH;
// opItem.x = w / 2;
// item.addChild(opItem);
// this.optionItemArr.push(opItem);
// }
// }
// this.curAreaItem = item;
this.renderArr.push(item);
return item;
}
videoBtn; videoBtn;
setOneBtnVideo(data) { setOneBtnVideo(data) {
console.log('setOneBtnVideo data: ', data) console.log('setOneBtnVideo data: ', data)
...@@ -3606,6 +3767,60 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3606,6 +3767,60 @@ export class PlayComponent implements OnInit, OnDestroy {
item.visible = false; item.visible = false;
this.answerRectNode = item; this.answerRectNode = item;
this.answerRect = this.setAnswerRect(item, saveRect);
// const answerNormal = this.getMySprite('answer_normal');
// const sx = saveRect.width / answerNormal.width;
// const sy = saveRect.height / answerNormal.height;
// const s = Math.min(sx, sy);
// answerNormal.setScaleXY(s);
// answerNormal.x = answerNormal.width / 2 * answerNormal.scaleX;
// answerNormal.y = item.height / 2;
// item.addChild(answerNormal);
// item['normalPic'] = answerNormal;
// this.answerRectNode.curRes = 'normalPic';
// const answerRight = this.getMySprite('answer_right');
// answerRight.setScaleXY(s);
// answerRight.x = answerNormal.x;
// answerRight.y = answerNormal.y;
// item.addChild(answerRight);
// item['rightPic'] = answerRight;
// answerRight.visible = false;
// const rightIcon = this.getMySprite('icon_right');
// rightIcon.x = answerRight.width / 2;
// answerRight.addChild(rightIcon)
// const answerWrong = this.getMySprite('answer_wrong');
// answerWrong.setScaleXY(s);
// answerWrong.x = answerNormal.x;
// answerWrong.y = answerNormal.y;
// item.addChild(answerWrong);
// item['wrongPic'] = answerWrong;
// answerWrong.visible = false;
// const wrongIcon = this.getMySprite('icon_wrong');
// wrongIcon.x = answerWrong.width / 2;
// answerWrong.addChild(wrongIcon)
// this.answerRect = answerNormal;
const labelPic = new MySprite();
item.addChild(labelPic);
this.answerLabelPic = labelPic;
// labelPic.load(url).then(img => {
// });
this.renderArr.push(item);
return item;
}
setAnswerRect(item, saveRect) {
const answerNormal = this.getMySprite('answer_normal'); const answerNormal = this.getMySprite('answer_normal');
const sx = saveRect.width / answerNormal.width; const sx = saveRect.width / answerNormal.width;
...@@ -3613,43 +3828,34 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3613,43 +3828,34 @@ export class PlayComponent implements OnInit, OnDestroy {
const s = Math.min(sx, sy); const s = Math.min(sx, sy);
answerNormal.setScaleXY(s); answerNormal.setScaleXY(s);
answerNormal.x = answerNormal.width / 2 * answerNormal.scaleX; answerNormal.x = answerNormal.width / 2 * answerNormal.scaleX;
answerNormal.y = answerNormal.height / 2 * answerNormal.scaleY; answerNormal.y = item.height / 2;
item.addChild(answerNormal); item.addChild(answerNormal);
item['normalPic'] = answerNormal; item['normalPic'] = answerNormal;
this.answerRectNode.curRes = 'normalPic'; this.answerRectNode.curRes = 'normalPic';
const answerRight = this.getMySprite('answer_right'); const answerRight = this.getMySprite('answer_right');
answerRight.setScaleXY(s); answerRight.setScaleXY(s);
answerRight.x = answerRight.width / 2 * answerRight.scaleX; answerRight.x = answerNormal.x;
answerRight.y = answerRight.height / 2 * answerRight.scaleY; answerRight.y = answerNormal.y;
item.addChild(answerRight); item.addChild(answerRight);
item['rightPic'] = answerRight; item['rightPic'] = answerRight;
answerRight.visible = false; answerRight.visible = false;
const rightIcon = this.getMySprite('icon_right');
rightIcon.x = answerRight.width / 2;
answerRight.addChild(rightIcon)
const answerWrong = this.getMySprite('answer_wrong'); const answerWrong = this.getMySprite('answer_wrong');
answerWrong.setScaleXY(s); answerWrong.setScaleXY(s);
answerWrong.x = answerWrong.width / 2 * answerWrong.scaleX; answerWrong.x = answerNormal.x;
answerWrong.y = answerWrong.height / 2 * answerWrong.scaleY; answerWrong.y = answerNormal.y;
item.addChild(answerWrong); item.addChild(answerWrong);
item['wrongPic'] = answerWrong; item['wrongPic'] = answerWrong;
answerWrong.visible = false; answerWrong.visible = false;
const wrongIcon = this.getMySprite('icon_wrong');
wrongIcon.x = answerWrong.width / 2;
answerWrong.addChild(wrongIcon)
this.answerRect = answerNormal; return answerNormal;
const labelPic = new MySprite();
item.addChild(labelPic);
this.answerLabelPic = labelPic;
// labelPic.load(url).then(img => {
// });
this.renderArr.push(item);
return item;
} }
...@@ -3769,35 +3975,36 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3769,35 +3975,36 @@ export class PlayComponent implements OnInit, OnDestroy {
// item.visible = false; // item.visible = false;
this.answerRectNode = item; this.answerRectNode = item;
this.answerRect = this.setAnswerRect(item, saveRect);
const answerNormal = this.getMySprite('answer_normal');
const sx = saveRect.width / answerNormal.width; // const answerNormal = this.getMySprite('answer_normal');
const sy = saveRect.height / answerNormal.height; // const sx = saveRect.width / answerNormal.width;
const s = Math.min(sx, sy); // const sy = saveRect.height / answerNormal.height;
answerNormal.setScaleXY(s); // const s = Math.min(sx, sy);
answerNormal.x = answerNormal.width / 2 * answerNormal.scaleX; // answerNormal.setScaleXY(s);
answerNormal.y = answerNormal.height / 2 * answerNormal.scaleY; // answerNormal.x = answerNormal.width / 2 * answerNormal.scaleX;
item.addChild(answerNormal); // answerNormal.y = answerNormal.height / 2 * answerNormal.scaleY;
item['normalPic'] = answerNormal; // item.addChild(answerNormal);
this.answerRectNode.curRes = 'normalPic'; // item['normalPic'] = answerNormal;
// this.answerRectNode.curRes = 'normalPic';
const answerRight = this.getMySprite('answer_right');
answerRight.setScaleXY(s); // const answerRight = this.getMySprite('answer_right');
answerRight.x = answerRight.width / 2 * answerRight.scaleX; // answerRight.setScaleXY(s);
answerRight.y = answerRight.height / 2 * answerRight.scaleY; // answerRight.x = answerRight.width / 2 * answerRight.scaleX;
item.addChild(answerRight); // answerRight.y = answerRight.height / 2 * answerRight.scaleY;
item['rightPic'] = answerRight; // item.addChild(answerRight);
answerRight.visible = false; // item['rightPic'] = answerRight;
// answerRight.visible = false;
const answerWrong = this.getMySprite('answer_wrong');
answerWrong.setScaleXY(s); // const answerWrong = this.getMySprite('answer_wrong');
answerWrong.x = answerWrong.width / 2 * answerWrong.scaleX; // answerWrong.setScaleXY(s);
answerWrong.y = answerWrong.height / 2 * answerWrong.scaleY; // answerWrong.x = answerWrong.width / 2 * answerWrong.scaleX;
item.addChild(answerWrong); // answerWrong.y = answerWrong.height / 2 * answerWrong.scaleY;
item['wrongPic'] = answerWrong; // item.addChild(answerWrong);
answerWrong.visible = false; // item['wrongPic'] = answerWrong;
// answerWrong.visible = false;
this.answerRect = answerNormal;
// this.answerRect = answerNormal;
const labelPic = new MySprite(); const labelPic = new MySprite();
...@@ -3817,6 +4024,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -3817,6 +4024,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.resetAnswerArea() this.resetAnswerArea()
this.showWriteBtn();
} }
...@@ -4237,6 +4446,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -4237,6 +4446,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (callback) { if (callback) {
audio.onended = () => { audio.onended = () => {
callback(); callback();
audio.onended = null;
}; };
} }
audio.play(); audio.play();
......
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