Commit f75b271b authored by 李维's avatar 李维

添加排序题

parent 1fab9d5d
......@@ -483,7 +483,7 @@
},
{
"__type__": "cc.Node",
"_name": "word",
"_name": "_word",
"_objFlags": 0,
"_parent": {
"__id__": 11
......
......@@ -29,8 +29,9 @@ cc.Class({
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
currentInputIndex: 0,
currentInputIndex: null,
start () {
this.currentInputIndex = 0;
this.initEventListener();
},
......@@ -45,7 +46,8 @@ cc.Class({
okBtn.on("click", ()=>{
const selectedContainer = cc.find("mainContainer/selected", this.node);
const allData = [];
selectedContainer.children.forEach(child=>{
selectedContainer.children.forEach((child, index)=>{
child.myData.currentIndex = index;
allData.push(child.myData)
})
this.node.emit("onEnter", allData);
......@@ -58,16 +60,16 @@ cc.Class({
},
show(options) {
this.node.opacity = 0;
this.node.opacity = 255;
this.node.x = 0;
this.node.y = 0;
this.node.active = true;
const template = cc.find("mainContainer/options/word", this.node);
const template = cc.find("mainContainer/options/_word", this.node);
const optionsContainer = cc.find("mainContainer/options", this.node);
const selectedContainer = cc.find("mainContainer/selected", this.node);
options.forEach(item => {
const newWord = cc.instantiate(template);
newWord.name = "word";
newWord.getComponent(cc.Label).string = item.word;
newWord.active = true;
newWord.myData = {
......@@ -79,16 +81,14 @@ cc.Class({
optionsContainer.addChild(newWord);
newWord.on("click", ()=>{
if(newWord.selected) {
if(newWord.myData.selected) {
selectedContainer.removeChild(newWord)
optionsContainer.addChild(newWord)
newWord.myData.selected = false;
ewWord.myData.currentIndex = -1;
} else {
optionsContainer.removeChild(newWord)
selectedContainer.addChild(newWord)
newWord.myData.selected = true;
newWord.myData.currentIndex = this.currentInputIndex++;
}
})
});
......@@ -99,10 +99,17 @@ cc.Class({
},
hide() {
const optionsContainer = cc.find("mainContainer/options", this.node);
const selectedContainer = cc.find("mainContainer/selected", this.node);
this.node.opacity = 255;
cc.tween(this.node).to(0.1, {opacity: 0}).call(()=>{
this.node.x = 5000;
this.node.active = false;
optionsContainer.children.forEach(child=>{
if(child.name != "_word") {
child.destroy();
}
})
selectedContainer.removeAllChildren();
}).start();
}
// update (dt) {},
......
......@@ -2881,7 +2881,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "8cJEY1+WlLn7+Ees86mvmp"
"_id": "f3EiGLz1NDc4D8RdALWpcl"
},
{
"__type__": "cc.Node",
......@@ -2948,7 +2948,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "2dytsJT51DPpQxEOL5WgfY"
"_id": "1dzmvk2WNLybGOFWu+bkme"
},
{
"__type__": "cc.Sprite",
......@@ -2980,7 +2980,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "00pf/LUbhOB4LiEJEj7cvA"
"_id": "cfK116pA5E3rJPBTkQXbhd"
},
{
"__type__": "cc.BlockInputEvents",
......@@ -2990,7 +2990,7 @@
"__id__": 60
},
"_enabled": true,
"_id": "30jJaNpKlLyo2TLbUHgwz2"
"_id": "754BzPZlxJgYZwyfK9VeV5"
},
{
"__type__": "cc.PrefabInfo",
......@@ -3068,7 +3068,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "65woOMq3ZN37z1Xp8U4RV8"
"_id": "57hZXsIzZIioUCR8w+iTOC"
},
{
"__type__": "cc.Node",
......@@ -3135,7 +3135,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "570ZJcch9IWKgt1rMU3yMf"
"_id": "e5DKi46NdM363yZ0bToDkN"
},
{
"__type__": "cc.Widget",
......@@ -3162,7 +3162,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "05BVea+OlM16R05XeYpNz5"
"_id": "e1fgau3adEKIPfOYgZ0KdO"
},
{
"__type__": "cc.Layout",
......@@ -3194,7 +3194,7 @@
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_id": "bfB5MPc0NFEZCPEAqQp6lO"
"_id": "27AqdDVU5Cr4ZonWIZ17gu"
},
{
"__type__": "cc.PrefabInfo",
......@@ -3276,11 +3276,11 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "2a7Hud0/xCiLXnK66ah5wm"
"_id": "af7LcdiRNEu6OIKQtyY4qy"
},
{
"__type__": "cc.Node",
"_name": "word",
"_name": "_word",
"_objFlags": 0,
"_parent": {
"__id__": 69
......@@ -3343,7 +3343,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "f1jffZE21FvJp+FYVnGRpF"
"_id": "24la8mlS1Kv56l3T0Ja1Jh"
},
{
"__type__": "cc.Label",
......@@ -3376,7 +3376,7 @@
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "a9ULDPLjJAL4ByC5ghW/qP"
"_id": "67CcGsSLtGZbHjRFHCZps1"
},
{
"__type__": "cc.Button",
......@@ -3444,7 +3444,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "6aDnDBQ4BLp5qAcUldLhqV"
"_id": "63+3E4GyVKMYbR+2yeTuhD"
},
{
"__type__": "cc.PrefabInfo",
......@@ -3482,7 +3482,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "dbeUV0oAdMkoUX7whT39g6"
"_id": "7bBkLt755MLbXHGoJM4q8Q"
},
{
"__type__": "cc.Layout",
......@@ -3514,7 +3514,7 @@
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_id": "faXxKgaaVL35pkDm3g8E3J"
"_id": "c6mk63Ne5M0KZ5M8Exwf1I"
},
{
"__type__": "cc.PrefabInfo",
......@@ -3610,7 +3610,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "6a+9q2JdVKWorw6Tdjdmpq"
"_id": "a7rCwj+WxDpZffmGLFrFRp"
},
{
"__type__": "cc.Node",
......@@ -3677,7 +3677,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "201ygQsTBLPqWoIAPTrF3e"
"_id": "8aFT0yjrhOM6YkkP+l+1RA"
},
{
"__type__": "cc.Sprite",
......@@ -3709,7 +3709,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "66AgH7wFxFoJVsZBUXaShb"
"_id": "08WztnS9lGjIUZHeWrgNGP"
},
{
"__type__": "cc.Button",
......@@ -3777,7 +3777,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "77AAijsM1Mu7STJKA5kLiV"
"_id": "bf1OUxMdtK4br9YG+smHT+"
},
{
"__type__": "cc.PrefabInfo",
......@@ -3855,7 +3855,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "e52OcTCZ9DWKQ69/QEdQ+j"
"_id": "9616fFlYxFBLgyg2A5NYDn"
},
{
"__type__": "cc.Sprite",
......@@ -3887,7 +3887,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "41HajXuhFFLZJ/8t/SWtH/"
"_id": "4fk1UrqZpDCall8r89ssFN"
},
{
"__type__": "cc.Button",
......@@ -3955,7 +3955,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "1d/eTvKPhIA6IgQHl62p3b"
"_id": "7bsIwp83xN9qIshem+89wq"
},
{
"__type__": "cc.PrefabInfo",
......@@ -3998,7 +3998,7 @@
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_id": "47qbtGqlBAlr4hz+Lu4DgK"
"_id": "f28JAhwDFHp6Y8EaYUQFod"
},
{
"__type__": "cc.Widget",
......@@ -4025,7 +4025,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "e2voxEJAdBI4uUPgSePbQF"
"_id": "d5ecb59A1OqJ4xwxu00AJU"
},
{
"__type__": "cc.PrefabInfo",
......@@ -4046,7 +4046,7 @@
"__id__": 59
},
"_enabled": true,
"_id": "d6ACvoJspN8LxPPh7gIGJT"
"_id": "6a6qCSGUVO4bu3dozn7odA"
},
{
"__type__": "cc.Widget",
......@@ -4073,7 +4073,7 @@
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "9eUm8aLA5ERrjo+cVhnuDj"
"_id": "72o40ck/BHKp2Gv5BcAgFh"
},
{
"__type__": "cc.PrefabInfo",
......
......@@ -20,6 +20,7 @@ const CONNECTION = "6";
const PRONUNCIATION_ASSESSMENT = "7";
const RIGHT_OR_WRONG = "8";
const CROSSWORD_PUZZLE = "9";
const SORT_WORDS = "10";
const layer_1 = 5
const layer_2 = 10
......@@ -64,12 +65,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initScorePanel();
this.initActionButton();
this.initScoreShow();
setTimeout(() => {
this.sortWords.emit("show", [
{word: "Fine"}, {word: "thank"}, {word: "you"}
])
}, 1000);
}
// 初始化屏幕储存
......@@ -389,6 +384,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
case CROSSWORD_PUZZLE:
validater = this.setCrosswordPuzzleInput(configItem, isDebug);
this.scoreValidater.push(validater);
break;
// 文字排序
case SORT_WORDS:
validater = this.setSortWords(configItem, this.data.hotZoneItemArr[configItem.linkHotZoneIndex], isDebug);
this.scoreValidater.push(validater);
break;
}
});
......@@ -1287,6 +1288,122 @@ export default class SceneComponent extends MyCocosSceneComponent {
return validater
}
// 设置单词排序题
setSortWords(contentData, hotZoneItemData, debugMode=false) {
// 该题型需要配置一个显示正确错误符号的热区
const resultIconShowData = this.data.hotZoneItemArr[contentData.linkResultShowHotZoneIndex];
const resultIconRect = this.newRectNode(resultIconShowData, layer_2, debugMode);
this.newDecorativeFrame(hotZoneItemData, layer_1, "#FFFFFF", "#6dbef6", debugMode);
const rect = this.newRectNode(hotZoneItemData, layer_3, debugMode);
// 选项列表
const optionList = [];
// 已选的单词列表
let sortedList = [];
// 正确校验方法 - 默认返null
let validater = () => {
const result = {
detail: {
contentType: SORT_WORDS,
configIndex: contentData.index,
contentIndex: -1,
optionList: [],
sortedList: [],
right: true
},
configIndex: contentData.index,
rect: resultIconRect,
allRight: true,
score: -1
}
result.detail.optionList = optionList;
result.detail.sortedList = sortedList;
if(optionList.length != sortedList.length) {
// 如果选项长度和选择的长度不等,则判定为没有完成所有选项
// 错误
result.allRight = false;
result.detail.right = false;
return [result]
}
// 遍历选择的列表 判断是否和设定一致 注意:设定的序号从1开始
let hasWrong = false;
sortedList.forEach(word => {
if((Number(word.currentIndex) + 1) != Number(word.option.sortIndex)) {
hasWrong = true;
}
})
if(!hasWrong) {
// 正确 返回分数
result.score = contentData.score && !isNaN(Number(contentData.score)) ? Number(contentData.score) : 0;
return [result]
} else {
// 错误
result.allRight = false;
result.detail.right = false;
return [result]
}
};
contentData.contentList.forEach((option, index) => {
optionList.push({
word: option.text,
index: index,
sortIndex: option.sortIndex
})
});
rect.on("click", async () => {
if(this.submitted) {
return;
}
this.currentInputTarget = rect;
// 取得上次输入文字 传到键盘中 作为默认显示 - 清空当前文字节点
let lastText = "";
if(rect.cleanLast) {
lastText = rect.cleanLast()
}
let text = ""
sortedList = await this.asyncShowSortWordsModal(optionList);
if(sortedList == undefined) {
// 点击了取消 还原上次显示
text = lastText;
} else {
const textArr = [];
sortedList.forEach(word=>{
textArr.push(word.option.word);
})
text = textArr.join(" ");
}
const inputLabel = this.newInputTextNode(text, 0);
inputLabel.x = rect.width / 2;
inputLabel.y = rect.height / 2;
currentInputText = text;
// 更新清除方法
rect.cleanLast = () => {
inputLabel.destroy();
return text;
}
// 校验必须在上面更新了校验器之后进行 否则本次选择不会生效
this.checkCanSubmit();
rect.addChild(inputLabel);
})
return validater
}
// 设置选项菜单热区 [已修改]
setTextOptionList(contentData, debugMode=false) {
// 存放子校验器
......@@ -1925,6 +2042,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
}
// 同步方式显示单词排序框
asyncShowSortWordsModal(options) {
return new Promise((resovle, reject) => {
this.sortWords.emit("show", options);
this.onSortWordsEndCallback = (target, e) => {
resovle(e);
}
})
}
onDestroy() {
cc.audioEngine.stop(this.currentAudioPlay);
}
......
This diff is collapsed.
......@@ -52,8 +52,10 @@
<nz-option [nzValue]="CONNECTION" nzLabel="连线组"></nz-option>
<nz-option [nzValue]="RIGHT_OR_WRONG" nzLabel="判断对错"></nz-option>
<nz-option [nzValue]="CROSSWORD_PUZZLE" nzLabel="纵横字谜"></nz-option>
<nz-option [nzValue]="SORT_WORDS" nzLabel="单词排序"></nz-option>
<nz-option [nzValue]="IMAGE_SELECT" nzLabel="图片选项" nzDisabled></nz-option>
<nz-option [nzValue]="PRONUNCIATION_ASSESSMENT" nzLabel="语音评测" nzDisabled></nz-option>
</nz-select>
<div *ngIf="it.hotZoneType != '' && it.hotZoneType != AUDIO_PLAY && it.hotZoneType != TEXTINPUT && it.hotZoneType != PRONUNCIATION_ASSESSMENT" style="padding: 10px 0 10px 150px;">
<div style="margin-bottom: 16px;">
......@@ -421,6 +423,49 @@
</tr>
</tbody>
</nz-table>
<!-- 单词排序 -->
<nz-table *ngIf="it.hotZoneType == SORT_WORDS" #contentTable [nzData]="it.contentList" [nzShowPagination]="false">
<thead>
<tr>
<th nzWidth="100px" nzAlign="center">序号</th>
<th nzWidth="100px">正确序号</th>
<th>文字</th>
<th nzWidth="150px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of contentTable.data; let i = index;">
<ng-container *ngIf="!(editCache[data.uuid] && editCache[data.uuid].edit); else editTemplate">
<td nzWidth="100px" nzAlign="center">{{ i + 1 }}</td>
<td nzWidth="100px">
{{ data.sortIndex }}
</td>
<td>{{ data.text }}</td>
<td nzWidth="150px">
<a (click)="startHotZoneConfigEdit(data.uuid, data)">编辑</a>
<nz-divider nzType="vertical"></nz-divider>
<a nz-popconfirm nzPopconfirmTitle="删除后不可恢复,确定删除吗?" (nzOnConfirm)="deleteHotZoneConfigItem(it, i)">删除</a>
</td>
</ng-container>
<ng-template #editTemplate>
<td nzWidth="100px" nzAlign="center">{{ i + 1 }}</td>
<td nzWidth="100px">
<input type="text" nz-input [(ngModel)]="editCache[data.uuid].data.sortIndex" />
</td>
<td>
<input type="text" nz-input [(ngModel)]="editCache[data.uuid].data.text" />
</td>
<td nzWidth="150px">
<a (click)="saveHotZoneConfigEdit(data.uuid, it)" class="save">保存</a>
<nz-divider nzType="vertical"></nz-divider>
<a nz-popconfirm nzPopconfirmTitle="确定取消?" (nzOnConfirm)="cancelHotZoneConfigEdit(data.uuid, data)">取消</a>
</td>
</ng-template>
</tr>
</tbody>
</nz-table>
</div>
<div *ngIf="it.hotZoneType == AUDIO_PLAY" style="padding: 10px 0 10px 100px;">
<app-audio-recorder
......@@ -465,7 +510,7 @@
</nz-select>
</div>
<div *ngIf="it.hotZoneType == HOT_ZONE_RADIO || it.hotZoneType == HOT_ZONE_CHECKBOX || it.hotZoneType == CONNECTION || it.hotZoneType == RIGHT_OR_WRONG || it.hotZoneType == CROSSWORD_PUZZLE" style="margin: 10px 10px;">
<div *ngIf="it.hotZoneType == HOT_ZONE_RADIO || it.hotZoneType == HOT_ZONE_CHECKBOX || it.hotZoneType == CONNECTION || it.hotZoneType == RIGHT_OR_WRONG || it.hotZoneType == CROSSWORD_PUZZLE || it.hotZoneType == SORT_WORDS" style="margin: 10px 10px;">
<span style="display: inline-block; text-align: right; width: 150px;">检查结果显示热区:</span>
<nz-select nzShowSearch nzAllowClear [(ngModel)]="it.linkResultShowHotZoneIndex" style="width: 300px;" (ngModelChange)="save()">
<nz-option *ngFor="let itOption of item.hotZoneItemArr" [nzValue]="itOption.index" [nzLabel]="itOption.itemName"></nz-option>
......
......@@ -48,6 +48,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
PRONUNCIATION_ASSESSMENT = "7";
RIGHT_OR_WRONG = "8";
CROSSWORD_PUZZLE = "9";
SORT_WORDS = "10";
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef, private nzMessageService: NzMessageService, private modal: NzModalService) {
......
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