Commit 404a936f authored by limingzhe's avatar limingzhe

feat: 输入框

parents 37426945 2ff8f221
...@@ -23,6 +23,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -23,6 +23,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
isCopy: true, isCopy: true,
select: [ select: [
// {label: '评测', value: 'ai'},
{label: '日期', value: 'date'}, {label: '日期', value: 'date'},
{label: '时间', value: 'time'}, {label: '时间', value: 'time'},
{label: '人名', value: 'name'}, {label: '人名', value: 'name'},
......
...@@ -844,6 +844,7 @@ export class RichTextOld extends Label { ...@@ -844,6 +844,7 @@ export class RichTextOld extends Label {
export class RichText extends Label { export class RichText extends Label {
topH = 8;
disH = 10; disH = 10;
offW = 10; offW = 10;
private rowCount = 1; private rowCount = 1;
...@@ -962,7 +963,7 @@ export class RichText extends Label { ...@@ -962,7 +963,7 @@ export class RichText extends Label {
this.rowCount = rows.length; this.rowCount = rows.length;
const x = 0; const x = 0;
const y = 0; const y = this.topH;
if (this._outlineFlag) { if (this._outlineFlag) {
......
...@@ -584,7 +584,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -584,7 +584,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
localStartTime = new Date().getTime();
gameStart() { gameStart() {
this.localStartTime = new Date().getTime();
console.log(' in gameStart '); console.log(' in gameStart ');
if (this.isTeacher) { if (this.isTeacher) {
this.sendBtn.visible = false; this.sendBtn.visible = false;
...@@ -693,19 +695,30 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -693,19 +695,30 @@ export class PlayComponent implements OnInit, OnDestroy {
showSubmit() { showSubmit() {
if (!this.submitBtn) { if(this.submitBtn){
return; this.submitBtn.visible = true;
this.submitBtn.alpha = 1;
this.submitBtn.shadowSpr.visible = true;
this.submitBtn.shadowSpr.alpha = 1;
} }
this.submitBtn.visible = true;
this.submitBtn.shadowSpr.visible = true;
} }
hideSubmit() { hideSubmit() {
if (!this.submitBtn) { if(this.submitBtn){
return; this.submitBtn.visible = false;
this.submitBtn.alpha = 0;
this.submitBtn.shadowSpr.visible = false;
this.submitBtn.shadowSpr.alpha = 0;
}
}
removeSubmit() {
if(this.submitBtn){
this.submitBtn.parent.removeChild(this.submitBtn);
this.submitBtn.shadowSpr.parent.removeChild(this.submitBtn.shadowSpr);
this.submitBtn = null;
} }
this.submitBtn.visible = false;
this.submitBtn.shadowSpr.visible = false;
} }
...@@ -1301,7 +1314,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1301,7 +1314,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (!arr) { if (!arr) {
return; return;
} }
const baseX = this.panel.width / 2 - 1000; const baseX = this.panel.width / 2 - 1000 ;
let curY = 70 // this.canvasHeight / 2 - 110 * this.mapScale; let curY = 70 // this.canvasHeight / 2 - 110 * this.mapScale;
const disH = 70 * this.mapScale; const disH = 70 * this.mapScale;
for (let i=0; i<arr.length; i++) { for (let i=0; i<arr.length; i++) {
...@@ -1631,13 +1644,20 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1631,13 +1644,20 @@ export class PlayComponent implements OnInit, OnDestroy {
okBtnClick() { okBtnClick() {
this.checkPanel.visible = false; this.checkPanel.visible = false;
this.appRef.tick(); this.removeSubmit();
// this.appRef.tick();
this.canTouch = false;
setTimeout(() => { setTimeout(() => {
// this.hideSubmit();
this.convertCanvasToImage(); this.convertCanvasToImage();
// this.hideSubmit();
setTimeout(() => {
this.initResultView();
this.canTouch = true;
this.initResultView(); }, 500);
}, 1); }, 500);
} }
...@@ -1651,12 +1671,16 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1651,12 +1671,16 @@ export class PlayComponent implements OnInit, OnDestroy {
downFlag = false; downFlag = false;
mapDown(event) { mapDown(event) {
if (!this.canTouch) { if (!this.canTouch) {
return; return;
} }
setTimeout(() => {
this.checkShowSubmit();
}, 100);
if (this.maskPic?.visible) { if (this.maskPic?.visible) {
return; return;
} }
...@@ -1788,7 +1812,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1788,7 +1812,6 @@ export class PlayComponent implements OnInit, OnDestroy {
mapUp(event) { mapUp(event) {
this.checkShowSubmit();
if (this.resultPanel) { if (this.resultPanel) {
this.resultSv.onTouchEnd(this.mx, this.my); this.resultSv.onTouchEnd(this.mx, this.my);
...@@ -1821,7 +1844,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1821,7 +1844,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.checkShowSubTemplateOne(); this.checkShowSubTemplateOne();
this.isUpdateStop = true; this.isUpdateStop = true;
// this.serverSendAnswer();
} }
checkShowSubTemplateOne() { checkShowSubTemplateOne() {
...@@ -1961,6 +1983,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1961,6 +1983,12 @@ export class PlayComponent implements OnInit, OnDestroy {
this.addLabelMask(targetRect, label); this.addLabelMask(targetRect, label);
} }
if (targetRect.label.isDefault) {
targetRect.label.text = '';
targetRect.label.fontColor = '#000000';
targetRect.label.isDefault = false;
}
if (true) { if (true) {
const scale = 1 // this.mapScale; const scale = 1 // this.mapScale;
...@@ -2125,7 +2153,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2125,7 +2153,8 @@ export class PlayComponent implements OnInit, OnDestroy {
return; return;
} }
c.sendAnswer({resultData: this.userResultData, resultPic: this.userResultPic}); const duration = new Date().getTime() - this.localStartTime;
c.sendAnswer({resultData: this.userResultData, resultPic: this.userResultPic, duration});
} }
...@@ -2152,7 +2181,16 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2152,7 +2181,16 @@ export class PlayComponent implements OnInit, OnDestroy {
// answer = answer.replace(/\n/g," "); // answer = answer.replace(/\n/g," ");
const result = checkAnswer(data.selectType, answer, this.hotZoneArr[i].labelText || null); let result;
// if (data.selectType == 'ai') {
// this.serverTest(answer);
// } else {
result = checkAnswer(data.selectType, answer, this.hotZoneArr[i].labelText || null);
// }
this.hotZoneArr[i].result = result; this.hotZoneArr[i].result = result;
if (!result.right) { if (!result.right) {
...@@ -2169,6 +2207,93 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2169,6 +2207,93 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
serverTest(text) {
const c = window['courseware'];
if (!c) {
console.error('not found window.courseware')
return;
}
if (text) {
c.greadPapersForText(text, (res) => {
const resData = JSON.parse(res);
const sentsFeedback = resData.detail?.essayFeedback?.sentsFeedback
if (sentsFeedback) {
for (let i=0; i<sentsFeedback.length; i++) {
const {errorPosInfos, rawSent} = sentsFeedback[i];
if (!errorPosInfos || !rawSent) {
continue;
}
const baseIndex = text.indexOf(rawSent);
console.log('text: ', text);
console.log('rawSent: ', rawSent);
console.log('baseIndex: ', baseIndex);
for (let j=0; j<errorPosInfos.length; j++) {
const {reason, endPos} = errorPosInfos[j];
this.addIconData(baseIndex + endPos, {reason});
}
}
}
console.log('res : ', res);
console.log('iconData : ', this.iconData);
this.createResultTextArr(text);
// this.setComment(resData);
})
}
}
iconData;
addIconData(index, result) {
if (!this.iconData) {
this.iconData = {};
}
const key = index.toString();
if (!this.iconData[key]) {
this.iconData[key] = {dataArr: []};
}
this.iconData[key].dataArr.push(result)
}
resultTextArr = [];
createResultTextArr(text) {
const iconKeys = Object.keys(this.iconData);
iconKeys.sort((a, b) => {
return Number(a) - Number(b);
})
this.resultTextArr = [];
let curStartPos = 0;
for (let i=0; i<iconKeys.length; i++) {
const textData = this.iconData[iconKeys[i]];
const endPos = Number(iconKeys[i]);
textData['text'] = text.substring(curStartPos, endPos);
this.resultTextArr.push(textData)
curStartPos = endPos;
}
const textData = {dataArr: []}
textData['text'] = text.substring(curStartPos)
this.resultTextArr.push(textData)
console.log('text: ', text);
console.log('resultTextArr: ', this.resultTextArr);
}
removeRectText(emptyRect) { removeRectText(emptyRect) {
this.showBtnByText(emptyRect.label.text); this.showBtnByText(emptyRect.label.text);
...@@ -2311,7 +2436,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2311,7 +2436,7 @@ export class PlayComponent implements OnInit, OnDestroy {
console.log('i: ', i); console.log('i: ', i);
console.log('arr[i]: ', arr[i]); console.log('arr[i]: ', arr[i]);
if (arr[i].data.gIdx == '0') { if (arr[i].data.gIdx == '0') {
if (!arr[i].label || !arr[i].label.text) { if (!arr[i].label || !arr[i].label.text || arr[i].label.isDefault) {
this.hideSubmit(); this.hideSubmit();
return; return;
} }
...@@ -2591,10 +2716,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2591,10 +2716,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
this.serverResultObj[key] = data; this.serverResultObj[key] = data;
this.serverResultObj.duration = new Date().getTime() - this.localStartTime;
c.sendAnswer(this.serverResultObj); c.sendAnswer(this.serverResultObj);
console.log(' sendAnswer : ', this.serverResultObj);
console.log(' sendAnswer : ' + JSON.stringify( this.serverResultObj ));
} }
...@@ -2817,14 +2941,37 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2817,14 +2941,37 @@ export class PlayComponent implements OnInit, OnDestroy {
setOneRect(data, index) { setOneRect(data, index) {
const saveRect = data.rect; const saveRect = data.rect;
const item = new ShapeRect(this.ctx); const item = new ShapeRectNew(this.ctx);
item.setSize(saveRect.width, saveRect.height); item.setSize(saveRect.width, saveRect.height, 5);
item.setOutLine('#dcc077', 2);
item.fill = false;
item.x = saveRect.x item.x = saveRect.x
item.y = saveRect.y item.y = saveRect.y
// item.setScaleXY(this.bg.scaleX); // item.setScaleXY(this.bg.scaleX);
item.fillColor = '#ff0000'; item.fillColor = '#dcc077';
item['data'] = data; item['data'] = data;
item.alpha = 0; // item.alpha = 0;
this.scrollView.addItem(item);
const rectLabel = this.getFillLabel();
rectLabel.fontSize = this.inputFontSize;
rectLabel.disH = 0;
rectLabel.offW = 0;
rectLabel.textBaseline = 'top'
rectLabel.width = item.width;
rectLabel.fontSize *= (this.bg.scaleX);
// targetRect.label.x = ( targetRect.width / 2 )
item['label'] = rectLabel;
item.addChild(item['label']);
this.addLabelMask(item, rectLabel);
rectLabel.text = 'Please Enter ...';
rectLabel.fontColor = '#cccccc'
rectLabel['isDefault'] = true;
// const subX = data.rect.x - this.bg.data.rect.x; // const subX = data.rect.x - this.bg.data.rect.x;
// const subY = data.rect.y - this.bg.data.rect.y; // const subY = data.rect.y - this.bg.data.rect.y;
...@@ -2834,7 +2981,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2834,7 +2981,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// // item.y -= this.bg.height / 2; // // item.y -= this.bg.height / 2;
// this.bg.addChild(item); // this.bg.addChild(item);
this.scrollView.addItem(item);
const circle = new ShapeCircle(); const circle = new ShapeCircle();
circle.setRadius(20 * this.bg.scaleX); circle.setRadius(20 * this.bg.scaleX);
......
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