Git commit 3e5c365ed01716dd22d89903ff8a9248ad07b01b by Bruno Coudoin. Committed on 19/12/2014 at 21:58. Pushed by bcoudoin into branch 'devel2'. imageid, uppon error the word is reproposed at the end of the list M +2 -0 src/activities/imageid/Imageid.qml M +19 -3 src/activities/imageid/imageid.js http://commits.kde.org/gcompris/3e5c365ed01716dd22d89903ff8a9248ad07b01b diff --git a/src/activities/imageid/Imageid.qml b/src/activities/imageid/Im= ageid.qml index 67b7785..5dfc9e5 100644 --- a/src/activities/imageid/Imageid.qml +++ b/src/activities/imageid/Imageid.qml @@ -76,6 +76,7 @@ ActivityBase { property alias wordListModel: wordListModel property alias parser: parser property variant goodWord + property int goodWordIndex = function playWord() { activity.audioVoices.append(ApplicationInfo.getAudioFilePa= th(goodWord.voice)) @@ -178,6 +179,7 @@ ActivityBase { = textLabel: word isCorrectAnswer: word =3D=3D=3D items.goodWord.transla= tedTxt + onIncorrectlyPressed: Activity.badWordSelected(items.g= oodWordIndex); onCorrectlyPressed: Activity.nextSubLevel(); } } diff --git a/src/activities/imageid/imageid.js b/src/activities/imageid/ima= geid.js index e5d9138..e0dddb4 100755 --- a/src/activities/imageid/imageid.js +++ b/src/activities/imageid/imageid.js @@ -36,6 +36,7 @@ var baseUrl =3D "qrc:/gcompris/src/activities/imageid/res= ource/"; var dataset =3D null; var lessons var wordList +var subLevelsLeft = function init(items_) { items =3D items_; @@ -68,14 +69,23 @@ function initLevel() { = maxSubLevel =3D wordList.length; items.score.numberOfSubLevels =3D maxSubLevel; + items.score.visible =3D true = + subLevelsLeft =3D [] + for(var i in wordList) + subLevelsLeft.push(i) initSubLevel() } = function initSubLevel() { // initialize sublevel - items.score.currentSubLevel =3D currentSubLevel + 1; - items.goodWord =3D wordList[currentSubLevel] + if(items.score.currentSubLevel < items.score.numberOfSubLevels) + items.score.currentSubLevel =3D currentSubLevel + 1; + else + items.score.visible =3D false + + items.goodWordIndex =3D subLevelsLeft.pop() + items.goodWord =3D wordList[items.goodWordIndex] = var selectedWords =3D [] selectedWords.push(items.goodWord.translatedTxt) @@ -112,9 +122,15 @@ function previousLevel() { } = function nextSubLevel() { - if( ++currentSubLevel >=3D maxSubLevel) { + ++currentSubLevel + if(subLevelsLeft.length =3D=3D=3D 0) { items.bonus.good("smiley") } else { initSubLevel(); } } + +// Append to the queue of words for the sublevel the error +function badWordSelected(wordIndex) { + subLevelsLeft.unshift(wordIndex) +}