Commit 3f8f5b41 authored by Li MingZhe's avatar Li MingZhe

feat: 添加评测功能

parent bb533d70
No preview for this file type
This diff is collapsed.
......@@ -112,9 +112,8 @@ cc.Class({
},
getDefaultData() {
const dataJson = '{"groupArr":[{"ques":"Who","optionArr":[],"question":"aaaa aaaa a a aaaaa a aaaaa aaa","answer":"bbb bbbbb b b bbbb bbbbbb","pic_url":"http://staging-teach.cdn.ireadabc.com/7709a0ddfde321cb70fc3099da32c35b.png"},{"ques":"","optionArr":[],"question":"ccccccc","answer":"ddddddddddd ddddddd ddd dddddd dddd","pic_url":"http://staging-teach.cdn.ireadabc.com/7b18a7931d64f7b9e8b7ecd25cb5e3d4.png"}],"title_1":"Abc ddd","title_2":"Efff aaa bbb","title_audio_url":"http://staging-teach.cdn.ireadabc.com/83513f8d6083ebe072e3f9e47a21558a.mp3"}';
const data1 = JSON.parse(dataJson);
return data1;
const data = {"groupArr":[{"ques":"Who","optionArr":[],"question":"What's your name?","answer":"bbb bbbbb b b bbbb bbbbbb","pic_url":"http://staging-teach.cdn.ireadabc.com/7709a0ddfde321cb70fc3099da32c35b.png"},{"ques":"","optionArr":[],"question":"How are you.","answer":"ddddddddddd ddddddd ddd dddddd dddd","pic_url":"http://staging-teach.cdn.ireadabc.com/7b18a7931d64f7b9e8b7ecd25cb5e3d4.png"}],"title_1":"Abc ddd","title_2":"Efff aaa bbb","title_audio_url":"http://staging-teach.cdn.ireadabc.com/83513f8d6083ebe072e3f9e47a21558a.mp3"};
return data;
},
......@@ -193,6 +192,13 @@ cc.Class({
console.log(' in addServerListener 2 : ', this.isTeacher);
c.onEvent('show_score', (data, next) => {
console.log('in show_score event', data);
this.showScore(data.score);
next();
});
if (this.isTeacher) {
c.onEvent('show_cap', (data, next) => {
......@@ -262,6 +268,49 @@ cc.Class({
},
showScore(score) {
console.log('in show score : ', score);
score = Math.round(score);
const sPanel = this.studentPanel;
const labelNode = new cc.Node();
labelNode.parent = sPanel;
labelNode.zIndex = 5;
labelNode.x = -sPanel.width / 2 + 70;
labelNode.y = sPanel.height / 2;
const label = labelNode.addComponent(cc.Label);
label.font = cc.find('Canvas/res/font/MMTextBook-Bold').getComponent(cc.Label).font;
label.string = "+" + score;
label.fontSize = 70;
label.lineHeight = 70;
const color = new cc.Color();
cc.Color.fromHEX(color, "#9ad37e");
labelNode.color = color;
const labelShadow = labelNode.addComponent(cc.LabelShadow);
labelShadow.offset = new cc.Vec2(0, -4);
const shadowColor = new cc.Color();
cc.Color.fromHEX(shadowColor, "#8ec773");
labelShadow.color = shadowColor;
cc.tween(labelNode)
.to(0.7, {y: labelNode.y + 100, opacity: 255}, {easing: "cubicOut"})
.delay(0.5)
.to(0.3, {opacity: 0})
.call(() => {
labelNode.removeFromParent();
})
.start();
},
historyData: null,
initHistoryData(user_aspect) {
......@@ -347,6 +396,7 @@ cc.Class({
maskLayer: null,
groupIndex: null,
historyData: null,
initData() {
// this.penguinPool = [];
......@@ -360,6 +410,8 @@ cc.Class({
this.maskLayer = cc.find('Canvas/mask')
this.initPosArr();
this.historyData = {};
},
posData: null,
......@@ -418,30 +470,28 @@ cc.Class({
// this.initBtn();
// this.showSoundBtn();
this.test();
this.initSSG();
// this.curBottle = this.bottleArr[0];
// this.changeLayer();
},
engine: null,
test() {
engineInitSuccess: null,
initSSG() {
//初始化先生评测
const engineFirstInitDone = () => {
this.engineInitSuccess = true;
console.log('引擎初始化成功回调 !');
}
const engineBackResultDone = () => {
console.log('引擎返回结果成功回调');
}
const engineBackResultFail = () => {
console.log('引擎返回结果失败回调');
}
const JSSDKNotSupport = () => {
console.log('sdk不支持当前浏览器回调');
}
const params = {
......@@ -449,34 +499,39 @@ cc.Class({
engineBackResultDone,
engineBackResultFail,
JSSDKNotSupport,
applicationId: 'a721',
userId: 'guest'
"applicationId": "a721",
"userId": "iplayabc",
"warrantId": "6073c7fa4dbaa4d1fad6d62f2de3dab2c"
}
this.engine = new window.EngineEvaluat(params)
},
recordStart() {
recordStart(refText) {
console.log(' start record')
const params = {
if (!this.engineInitSuccess) {
console.error("评测初始化异常");
}
console.log("refText: ", refText);
const params = {
coreType: 'en.word.score',
refText:'word',
refText,
precision:0.5
}
const done = () => {
console.log('~~~~~ done');
const done = (e) => {
// console.log('~~~~~ done: ', e);
const res = JSON.parse(e);
const score = res.result.overall;
console.log('score: ', score);
this.sendServerEvent('show_score', {score})
}
const fail = () => {
console.log('~~~~ fail');
}
this.engine.startRecord(params, done, fail);
},
recordStop() {
console.log(' stop record')
this.engine.stopRecord();
},
......@@ -544,8 +599,6 @@ cc.Class({
canvas.off(cc.Node.EventType.MOUSE_LEAVE, mouseUp)
}
this.removeHtmlTouchEnd();
this.recordStop();
}
const mouseUp = (e) => {
......@@ -712,7 +765,6 @@ cc.Class({
this.role.hand.active = false;
playAudio(this.clickClip);
this.recordStart();
})
},
......@@ -1053,13 +1105,15 @@ cc.Class({
showSpeakIconLight() {
this.speakBtn.opacity = 100;
this.speakBtn.isSHow = true;
this.speakBtn.animaNode.active = true;
this.speakBtn.isShow = true;
},
hideSpeakIconLight() {
this.speakBtn.opacity = 255;
this.speakBtn.isSHow = false;
this.speakBtn.animaNode.active = false;
this.speakBtn.isShow = false;
},
......@@ -1078,6 +1132,11 @@ cc.Class({
this.appear(this.speakIcon, 0.5)
playAudio(this.speakClip);
const quesText = this.curBottle.data.question;
this.recordStart(quesText);
// if (this.speakTween) {
// this.speakTween.stop();
......@@ -1095,6 +1154,7 @@ cc.Class({
this.disappear(this.speakIcon, 0.3, () => {
this.speakIcon.active = false;
})
this.recordStop();
},
appear(node, time) {
......@@ -1302,6 +1362,7 @@ cc.Class({
const speak = getSprNode('btn_speak');
this.speakBtn = speak;
speak.parent = this.studentPanel;
speak.zIndex = 1;
speak.x = -this.studentPanel.width / 2 + speak.width / 2 + 28;
speak.y = this.studentPanel.height / 2 + 2;
this.addBtnClickFunc(speak, () => {
......@@ -1315,6 +1376,15 @@ cc.Class({
}
})
const speakAnimaNode = new cc.Node();
speakAnimaNode.parent = speak.parent;
speakAnimaNode.x = speak.x;
speakAnimaNode.y = speak.y;
speakAnimaNode.active = false;
speak.animaNode = speakAnimaNode;
this.updateSpeakAnimaNode();
let offX = -20 * this._mapScaleMin;
let offY = 0;
const right = getSprNode('btn_right');
......@@ -1369,6 +1439,28 @@ cc.Class({
},
updateSpeakAnimaNode() {
const speakAnimaNode = this.speakBtn.animaNode;
const speakCircle = getSprNode("bg_speak");
speakCircle.parent = speakAnimaNode;
speakCircle.scale = 0.8;
cc.tween(speakCircle)
.to(2.5, {opacity: 0, scale: 1.5}, {easing: "cubicOut"})
.call(() => {
speakCircle.removeFromParent();
})
.start();
this.delayCall(0.5, () => {
this.updateSpeakAnimaNode();
})
},
addBtnClickFunc(node, cb) {
node.addComponent(cc.Button);
node.on(cc.Node.EventType.TOUCH_START, () => {
......
{
"ver": "1.1.0",
"uuid": "032f922b-6bff-4ad3-9a3b-1212d5394c42",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "c4d7bfb4-e710-4120-aa28-920ff602d8cb",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 106,
"height": 108,
"platformSettings": {},
"subMetas": {
"bg_speak": {
"ver": "1.0.4",
"uuid": "d99112a9-ea14-4d67-b22e-48df5bb695f8",
"rawTextureUuid": "c4d7bfb4-e710-4120-aa28-920ff602d8cb",
"trimType": "custom",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 106,
"height": 108,
"rawWidth": 106,
"rawHeight": 108,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
No preview for this file type
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