Commit ffded503 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

letter-in-word, remove 2 global variables, horizontally align text

parent 3bf64cc7
......@@ -51,10 +51,11 @@ Item {
z: (state == 'scaled') ? 1 : -1
//visible: index % 2 != 0 ? false : true
Row{
Row {
anchors.verticalCenter: cardImage.verticalCenter
Repeater{
anchors.horizontalCenter: cardImage.horizontalCenter
Repeater {
model: components
GCText {
id: textbox
......@@ -83,7 +84,8 @@ Item {
PropertyChanges {
target: cardItem
scale: /*carriageImage.scale * */ 1.2
z: 2}
z: 2
}
}
transitions: Transition {
......@@ -104,8 +106,8 @@ Item {
target: cardImage
easing.type: Easing.InOutQuad
property: "rotation"; to: -20
duration: 500 }
duration: 500
}
}
SequentialAnimation {
......@@ -153,11 +155,10 @@ Item {
components.clear();
var tempword;
var j = 0;
for(var i = 0; i < spelling.length; i++){
if(spelling.charAt(i) == Activity.currentLetter){
tempword = spelling.substring(j,i);
if(i!=j){
for(var i = 0; i < spelling.length; i++) {
if(spelling.charAt(i) == Activity.currentLetter) {
tempword = spelling.substring(j, i);
if(i != j) {
components.append({"textdata": tempword})
}
components.append({"textdata": Activity.currentLetter});
......@@ -165,7 +166,7 @@ Item {
j = i + 1;
}
}
if(j < spelling.length){
if(j < spelling.length) {
tempword = spelling.substring(j, spelling.length);
components.append({"textdata": tempword})
......
......@@ -232,7 +232,6 @@ ActivityBase {
font.weight: Font.DemiBold
color: "#2a2a2a"
text: items.question
}
PropertyAnimation {
......@@ -274,9 +273,8 @@ ActivityBase {
model: wordsModel
delegate: Card{
delegate: Card {
width: background.itemWidth
}
}
......
......@@ -28,8 +28,6 @@
.import "qrc:/gcompris/src/activities/lang/lang_api.js" as Lang
var url = "qrc:/gcompris/src/activities/letter-in-word/resource/"
var defaultLevelsFile = ":/gcompris/src/activities/letter-in-word/resource/levels/levels-en.json";
var maxLettersPerLine = 6;
var levels;
var currentLevel;
......@@ -37,7 +35,6 @@ var maxLevel;
var currentSubLevel;
var currentLetter;
var maxSubLevel;
var level;
var questions;
var words;
var items;
......@@ -120,7 +117,7 @@ function initLevel() {
var componentsArr;
items.bar.level = currentLevel + 1;
if (currentSubLevel == 0 && !incorrectFlag) {
level = levels[currentLevel];
var level = levels[currentLevel];
words = Lang.getLessonWords(dataset, level);
Core.shuffle(words);
var limit = Math.min(11, words.length)
......@@ -242,40 +239,31 @@ function nextSubLevel() {
function checkAnswer()
{
var checkFlag = false;
var hasWordNotFound = false;
var modelEntry;
for(var i = 0; i < words.length; i++){
for(var i = 0; i < words.length; i++) {
modelEntry = items.wordsModel.get(i);
for(var j = 0; j < modelEntry.spelling.length; j++){
if(currentLetter == modelEntry.spelling.charAt(j) && modelEntry.selected == false){
checkFlag = true;
break;
}
if(modelEntry.spelling.indexOf(currentLetter) != -1 && modelEntry.selected == false) {
hasWordNotFound = true;
break;
}
}
if(checkFlag == false){
if(hasWordNotFound == false) {
items.bonus.good("flower");
}
}
function checkWord(index)
{
var checkFlag = false;
var modelEntry = items.wordsModel.get(index);
for(var i = 0; i < modelEntry.spelling.length; i++){
if(currentLetter == modelEntry.spelling.charAt(i)){
items.wordsModel.setProperty(index, "selected", true);
checkAnswer();
checkFlag = true;
break;
}
}
if(checkFlag == true){
if(modelEntry.spelling.indexOf(currentLetter) != -1) {
items.wordsModel.setProperty(index, "selected", true);
checkAnswer();
return true;
}
else{
else {
items.bonus.bad("flower");
return false;
return false;
}
}
......
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