我有一个由“|”分隔的字符串组成的数组:
LOG: 380|2|choice|Question_8_13240_1351170102936|||incorrect|2012-10-25T15:01:13|1|<ln>380|2|choice|Question_10_13280_1351170102995|||incorrect|2012-10-25T15:01:17|1|
并且需要从每个字符串中获取 Question_8_13240_1351170102936 以便我可以查看是否有任何重复的问题,因此第三次出现“|”之后的字符串 4号之前
构建数组的代码:
AssessmentManager.prototype.submit = function () {
assessData = "";
assessmentItemsLength = this.assessmentItems.length;
for (i = 0; i < this.assessmentItems.length; i++) {
if (!this.assessmentItems[i].getSubmitted()) {
assessmentFlatDataItem = this.assessmentItems[i].getFlatData();
if (assessmentFlatDataItem.length > 0) {
if (assessData.length > 0)
assessData += "<ln>";
assessData += assessmentFlatDataItem;
}
}
}
}
然后GetFlatdata:
AssessmentItem.prototype.getFlatData = function () {
result = _userScormModuleId + "|";
if (this._interactionIdx)
result += this._interactionIdx;
result += "|";
if (this._interactionType)
result += this._interactionType
result += "|";
if (this._interactionId)
result += this._interactionId
result += "|";
if (this._learnerResponse)
result += this._learnerResponse
result += "|";
if (this._correctResponse)
result += this._correctResponse
result += "|";
if (this._result)
result += this._result
result += "|";
if (this._timeStamp)
result += this._timeStamp
result += "|";
if (this._weighting)
result += this._weighting
result += "|";
if (this._description)
result += this._description
return result;
}
我将如何实现这一目标?谢谢
我现在有这个:
learnerResponsesArray.push({
key: j,
value: this.assessmentItems.split('<ln>')
});
然后循环通过 learnerResponsesArray?