Commit fa0a16f7 authored by 李维's avatar 李维

添加区分大小写选项

parent 2874ed85
...@@ -1713,12 +1713,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1713,12 +1713,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
let right = false; let right = false;
if(contentData.keyWordMatch) { if(contentData.keyWordMatch) {
// 关键词匹配,只有回答文字中包含全部关键词,就算对 // 关键词匹配,只有回答文字中包含全部关键词,就算对
right = this.fuzzyMatchingString(currentInputText, contentData.inputText) right = this.fuzzyMatchingString(currentInputText, contentData.inputText, contentData.isCaseInsensitive)
} else if(contentData.openAnswer) { } else if(contentData.openAnswer) {
// 开放型回答 只要有内容就算对 // 开放型回答 只要有内容就算对
right = currentInputText != "" right = currentInputText != ""
} else { } else {
right = currentInputText == contentData.inputText; if(contentData.isCaseInsensitive) {
// 不区分大小写
right = currentInputText.toLocaleLowerCase() == contentData.inputText.toLocaleLowerCase();
} else {
// 区分大小写 完全相等
right = currentInputText == contentData.inputText;
}
} }
if(right) { if(right) {
...@@ -2188,12 +2194,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -2188,12 +2194,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
let right = false; let right = false;
// 判断是否启用关键词匹配 // 判断是否启用关键词匹配
if(contentData.keyWordMatch) { if(contentData.keyWordMatch) {
right = this.fuzzyMatchingString(recordText, evaText) right = this.fuzzyMatchingString(recordText, evaText, contentData.isCaseInsensitive)
} else if(contentData.openAnswer) { } else if(contentData.openAnswer) {
// 开放型回答 只要有内容就算对 // 开放型回答 只要有内容就算对
right = recordText != "" right = recordText != ""
}else { }else {
right = recordText == evaText; if(contentData.isCaseInsensitive) {
// 不区分大小写
right = recordText.toLocaleLowerCase() == evaText.toLocaleLowerCase();
} else {
// 区分大小写 完全相等
right = recordText == evaText;
}
} }
if(right) { if(right) {
...@@ -2650,7 +2662,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -2650,7 +2662,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
// 模糊匹配字符串 1,2,3 // 模糊匹配字符串 1,2,3
fuzzyMatchingString(testString, matchString){ fuzzyMatchingString(testString, matchString, isCaseInsensitive){
matchString.replace(/,/g,","); matchString.replace(/,/g,",");
const _keyWordGroup = matchString.split("|"); // 大的分组 任何一个组匹配了 都算对 const _keyWordGroup = matchString.split("|"); // 大的分组 任何一个组匹配了 都算对
...@@ -2669,7 +2681,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -2669,7 +2681,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
// console.log(key) // console.log(key)
// console.log(testString.toLocaleLowerCase()) // console.log(testString.toLocaleLowerCase())
// console.log(testString.toLocaleLowerCase().indexOf(key.toLocaleLowerCase())) // console.log(testString.toLocaleLowerCase().indexOf(key.toLocaleLowerCase()))
return testString.toLocaleLowerCase().indexOf(key.toLocaleLowerCase()) == -1 if(isCaseInsensitive) {
// 不区分大小写
return testString.toLocaleLowerCase().indexOf(key.toLocaleLowerCase()) == -1
} else {
// 区分大小写
return testString.indexOf(key) == -1
}
}) })
if(result == undefined) { if(result == undefined) {
rightInGroup = true; rightInGroup = true;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -461,6 +461,7 @@ ...@@ -461,6 +461,7 @@
<span style="display: inline-block; text-align: right; width: 150px;">正确文字:</span> <span style="display: inline-block; text-align: right; width: 150px;">正确文字:</span>
<input type="text" nz-input [(ngModel)]="it.inputText" (blur)="save()" style="display: inline-block; width: 300px;"> <input type="text" nz-input [(ngModel)]="it.inputText" (blur)="save()" style="display: inline-block; width: 300px;">
<label nz-checkbox [(ngModel)]="it.keyWordMatch" (ngModelChange)="save()" style="margin-left: 10px;">关键词匹配</label> <label nz-checkbox [(ngModel)]="it.keyWordMatch" (ngModelChange)="save()" style="margin-left: 10px;">关键词匹配</label>
<label nz-checkbox [(ngModel)]="it.isCaseInsensitive" (ngModelChange)="save()" style="margin-left: 10px;">不区分大小写</label>
<label nz-checkbox [(ngModel)]="it.openAnswer" (ngModelChange)="save()" style="margin-left: 10px;">开放性答案</label> <label nz-checkbox [(ngModel)]="it.openAnswer" (ngModelChange)="save()" style="margin-left: 10px;">开放性答案</label>
</div> </div>
......
...@@ -108,6 +108,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni ...@@ -108,6 +108,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
rightOrWrongStyleType: "symbol", rightOrWrongStyleType: "symbol",
inputText: "", inputText: "",
keyWordMatch: false, keyWordMatch: false,
isCaseInsensitive: true,
openAnswer: false, openAnswer: false,
useSelectOptionList: false, useSelectOptionList: false,
selectOptionList: [ selectOptionList: [
......
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