Commit b8c3f0c5 authored by 李维's avatar 李维

添加开放性回答,有内容就算对

parent 1a175f0c
...@@ -1452,9 +1452,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1452,9 +1452,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
result.detail.correctText = contentData.inputText; result.detail.correctText = contentData.inputText;
let right = false; let right = false;
// 判断是否启用关键词匹配
if(contentData.keyWordMatch) { if(contentData.keyWordMatch) {
// 关键词匹配,只有回答文字中包含全部关键词,就算对
right = this.fuzzyMatchingString(currentInputText, contentData.inputText) right = this.fuzzyMatchingString(currentInputText, contentData.inputText)
} else if(contentData.openAnswer) {
// 开放型回答 只要有内容就算对
right = currentInputText != ""
} else { } else {
right = currentInputText == contentData.inputText; right = currentInputText == contentData.inputText;
} }
...@@ -1905,7 +1908,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1905,7 +1908,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 判断是否启用关键词匹配 // 判断是否启用关键词匹配
if(contentData.keyWordMatch) { if(contentData.keyWordMatch) {
right = this.fuzzyMatchingString(recordText, evaText) right = this.fuzzyMatchingString(recordText, evaText)
} else { } else if(contentData.openAnswer) {
// 开放型回答 只要有内容就算对
right = recordText != ""
}else {
right = recordText == evaText; right = recordText == evaText;
} }
...@@ -2365,9 +2371,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -2365,9 +2371,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
fuzzyMatchingString(testString, matchString){ fuzzyMatchingString(testString, matchString){
matchString.replace(/,/g,","); matchString.replace(/,/g,",");
const keyWords = matchString.split(",") const _keyWords = matchString.split(",")
keyWords.forEach(item => { const keyWords = _keyWords.map(item => {
item.trim(); return item.trim();
}); });
const result = keyWords.find(key=>testString.toLocaleLowerCase().indexOf(key.toLocaleLowerCase()) == -1) const result = keyWords.find(key=>testString.toLocaleLowerCase().indexOf(key.toLocaleLowerCase()) == -1)
......
This diff is collapsed.
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