Commit 404a936f authored by limingzhe's avatar limingzhe

feat: 输入框

parents 37426945 2ff8f221
......@@ -23,6 +23,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
isCopy: true,
select: [
// {label: '评测', value: 'ai'},
{label: '日期', value: 'date'},
{label: '时间', value: 'time'},
{label: '人名', value: 'name'},
......
......@@ -844,6 +844,7 @@ export class RichTextOld extends Label {
export class RichText extends Label {
topH = 8;
disH = 10;
offW = 10;
private rowCount = 1;
......@@ -962,7 +963,7 @@ export class RichText extends Label {
this.rowCount = rows.length;
const x = 0;
const y = 0;
const y = this.topH;
if (this._outlineFlag) {
......
......@@ -584,7 +584,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
localStartTime = new Date().getTime();
gameStart() {
this.localStartTime = new Date().getTime();
console.log(' in gameStart ');
if (this.isTeacher) {
this.sendBtn.visible = false;
......@@ -693,19 +695,30 @@ export class PlayComponent implements OnInit, OnDestroy {
showSubmit() {
if (!this.submitBtn) {
return;
if(this.submitBtn){
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() {
if (!this.submitBtn) {
return;
if(this.submitBtn){
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 {
if (!arr) {
return;
}
const baseX = this.panel.width / 2 - 1000;
const baseX = this.panel.width / 2 - 1000 ;
let curY = 70 // this.canvasHeight / 2 - 110 * this.mapScale;
const disH = 70 * this.mapScale;
for (let i=0; i<arr.length; i++) {
......@@ -1631,13 +1644,20 @@ export class PlayComponent implements OnInit, OnDestroy {
okBtnClick() {
this.checkPanel.visible = false;
this.appRef.tick();
this.removeSubmit();
// this.appRef.tick();
this.canTouch = false;
setTimeout(() => {
// this.hideSubmit();
this.convertCanvasToImage();
// this.hideSubmit();
setTimeout(() => {
this.initResultView();
this.canTouch = true;
this.initResultView();
}, 1);
}, 500);
}, 500);
}
......@@ -1651,12 +1671,16 @@ export class PlayComponent implements OnInit, OnDestroy {
downFlag = false;
mapDown(event) {
if (!this.canTouch) {
return;
}
setTimeout(() => {
this.checkShowSubmit();
}, 100);
if (this.maskPic?.visible) {
return;
}
......@@ -1788,7 +1812,6 @@ export class PlayComponent implements OnInit, OnDestroy {
mapUp(event) {
this.checkShowSubmit();
if (this.resultPanel) {
this.resultSv.onTouchEnd(this.mx, this.my);
......@@ -1821,7 +1844,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.checkShowSubTemplateOne();
this.isUpdateStop = true;
// this.serverSendAnswer();
}
checkShowSubTemplateOne() {
......@@ -1961,6 +1983,12 @@ export class PlayComponent implements OnInit, OnDestroy {
this.addLabelMask(targetRect, label);
}
if (targetRect.label.isDefault) {
targetRect.label.text = '';
targetRect.label.fontColor = '#000000';
targetRect.label.isDefault = false;
}
if (true) {
const scale = 1 // this.mapScale;
......@@ -2125,7 +2153,8 @@ export class PlayComponent implements OnInit, OnDestroy {
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 {
// 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;
if (!result.right) {
......@@ -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) {
this.showBtnByText(emptyRect.label.text);
......@@ -2311,7 +2436,7 @@ export class PlayComponent implements OnInit, OnDestroy {
console.log('i: ', i);
console.log('arr[i]: ', arr[i]);
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();
return;
}
......@@ -2591,10 +2716,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
this.serverResultObj[key] = data;
this.serverResultObj.duration = new Date().getTime() - this.localStartTime;
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 {
setOneRect(data, index) {
const saveRect = data.rect;
const item = new ShapeRect(this.ctx);
item.setSize(saveRect.width, saveRect.height);
const item = new ShapeRectNew(this.ctx);
item.setSize(saveRect.width, saveRect.height, 5);
item.setOutLine('#dcc077', 2);
item.fill = false;
item.x = saveRect.x
item.y = saveRect.y
// item.setScaleXY(this.bg.scaleX);
item.fillColor = '#ff0000';
item.fillColor = '#dcc077';
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 subY = data.rect.y - this.bg.data.rect.y;
......@@ -2834,7 +2981,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// // item.y -= this.bg.height / 2;
// this.bg.addChild(item);
this.scrollView.addItem(item);
const circle = new ShapeCircle();
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