[gcompris] explore activity, improved the data loading, better error reporting, added missing translation call.



commit 5c052d474f0b22b113717e5382d20bdc70d6adbd
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sun Sep 9 21:46:04 2012 +0200

    explore activity, improved the data loading, better error reporting, added missing translation call.

 src/explore-activity/explore.py                    |   50 ++++++++------------
 .../explore_farm_animals/content.desktop.in        |    8 ++--
 .../explore_world_animals/content.desktop.in       |    6 +-
 .../explore_world_music/content.desktop.in         |    8 ++--
 4 files changed, 31 insertions(+), 41 deletions(-)
---
diff --git a/src/explore-activity/explore.py b/src/explore-activity/explore.py
index a21d76e..35f9adc 100644
--- a/src/explore-activity/explore.py
+++ b/src/explore-activity/explore.py
@@ -59,8 +59,6 @@ class Gcompris_explore:
 
         self.numLocations = 0 # the total number of locations in this activity
 
-        self.sectionsAnsweredCorrectly = []
-
         self.remainingItems = [] # list of all items still to be played during level 2 and 3
         self.allSoundClips = []  # list of sounds be played extracted from content.desktop.in
         self.allTextPrompts = [] # list of text be played extracted from content.desktop.in
@@ -135,8 +133,6 @@ class Gcompris_explore:
                                                 200, 480, 400, 25,
                                                 len(self.data.sections()) - 1 )
 
-                self.sectionsAnsweredCorrectly = []
-
                 if level == 2 and self.gcomprisBoard.maxlevel == 3:
 
                     self.remainingItems = self.allSoundClips[:]
@@ -295,7 +291,7 @@ class Gcompris_explore:
               use_markup=True
               )
 
-            text = self.data.get(sectionNum, '_text')
+            text = _(self.data.get(sectionNum, '_text'))
             t = goocanvas.Text(
               parent=rootitem,
               x=120,
@@ -328,7 +324,6 @@ class Gcompris_explore:
         '''
         if target.get_data('sectionNum') == self.currentSelection[1] and \
             self.currentSelection in self.remainingItems:
-            self.sectionsAnsweredCorrectly.append(target.get_data('sectionNum'))
             self.remainingItems.remove(self.currentSelection)
             self.progressBar.success()
             if len(self.remainingItems):
@@ -414,11 +409,11 @@ class Gcompris_explore:
         y = event.y
         self.data.set(str(self.numLocations), 'x', int(x))
         self.data.set(str(self.numLocations), 'y', int(y))
-        self.data.set(str(self.numLocations), '_title', _('Location Title Here'))
-        self.data.set(str(self.numLocations), '_text', _('location text here'))
-        self.data.set(str(self.numLocations), 'image', _('image filepath here, located in resources/name_of_activity/'))
-        self.data.set(str(self.numLocations), 'music', _('music file name here'))
-        self.data.set(str(self.numLocations), '_shortPrompt', _('enter text for child to match to the location'))
+        self.data.set(str(self.numLocations), '_title', 'Location Title Here')
+        self.data.set(str(self.numLocations), '_text', 'location text here')
+        self.data.set(str(self.numLocations), 'image', 'image filepath here, located in resources/name_of_activity/')
+        self.data.set(str(self.numLocations), 'music', 'music file name here')
+        self.data.set(str(self.numLocations), '_shortPrompt', 'enter text for child to match to the location')
 
         # draw small elipse on screen to show developer where they clicked
         goocanvas.Ellipse(parent=self.rootitem,
@@ -471,46 +466,43 @@ class Gcompris_explore:
         extract the data from the content file
         '''
         self.sectionNames = []
+        errors = []
         for section in self.data.sections():
             if section == 'common':
                 try: self.credits = self.data.get('common', 'credits')
                 except: self.credits = ''
                 try: self.background = self.data.get('common', 'background')
-                except:  gcompris.utils.dialog(_("Cannot find background in \
-                content.desktop.in"), None, None)
+                except: errors.append("Missing 'background' key")
                 try: self.author = self.data.get('common', 'author')
                 except: self.author = ''
                 try: self.locationPic = self.activityDataFilePath + self.data.get('common', 'locationpic')
-                except:
-                    print "ERROR: missing 'locationpic' in the data file"
-                    return
-                try: self.generalText = self.data.get('common', 'GeneralText')
-                except:pass
-                try: self.SoundMatchingGameText = self.data.get('common', 'SoundMatchingGameText')
+                except: errors.append("Missing 'locationpic' key")
+                try: self.generalText = _(self.data.get('common', '_GeneralText'))
+                except: errors.append("Missing '_GeneralText' key")
+                try: self.SoundMatchingGameText = _(self.data.get('common', '_SoundMatchingGameText'))
                 except:pass
-                try: self.TextMatchingGameText = self.data.get('common', 'TextMatchingGameText')
+                try: self.TextMatchingGameText = _(self.data.get('common', '_TextMatchingGameText'))
                 except:pass
                 try: self.backgroundx = int(self.data.get('common', 'backgroundx'))
-                except:
-                    print "ERROR: missing 'backgroundx' in the data file"
-                    return
+                except: errors.append("Missing 'backgroundx' key")
                 try: self.backgroundy = int(self.data.get('common', 'backgroundy'))
-                except:
-                    print "ERROR: missing 'backgroundy' in the data file"
-                    return
+                except: errors.append("Missing 'backgroundy' key")
                 try: self.textBoxX = int(self.data.get('common', 'textBoxX'))
                 except:pass
                 try: self.textBoxY = int(self.data.get('common', 'textBoxY'))
                 except:pass
             else:
                 try:
-                    self.allSoundClips.append((self.data.get(section, 'music'), section))
+                    self.allSoundClips.append( (self.data.get(section, 'music'), section))
                 except:
                     pass
-                self.allTextPrompts.append((self.data.get(section, '_shortPrompt'), section))
+                self.allTextPrompts.append( ( _(self.data.get(section, '_shortPrompt')), section))
 
                 self.sectionNames.append(section)
 
+            if len(errors):
+                gcompris.utils.dialog( "\n".join(errors), None)
+
     def end(self):
         '''
         write locations and common template to content.desktop.in
@@ -518,8 +510,6 @@ class Gcompris_explore:
         if RECORD_LOCATIONS:
             try: self.data.set('common', 'credits', 'enter a list of credits and links to resources you used here')
             except: pass
-            try: self.data.set('common', 'creator', 'enter your name here!')
-            except: pass
             try: self.data.set('common', 'locationpic', 'enter the filename of the picture you would like to use to identify items to click on your background image')
             except: pass
             try: self.data.set('common', 'generalText', 'enter the text to appear on your image for textMatchingGame')
diff --git a/src/explore_farm_animals-activity/resources/explore_farm_animals/content.desktop.in b/src/explore_farm_animals-activity/resources/explore_farm_animals/content.desktop.in
index 529825d..c41dd1b 100644
--- a/src/explore_farm_animals-activity/resources/explore_farm_animals/content.desktop.in
+++ b/src/explore_farm_animals-activity/resources/explore_farm_animals/content.desktop.in
@@ -1,13 +1,13 @@
+# Created by Beth Hadley
 [common]
 background = farm-animals.jpg
 backgroundx = 50
 backgroundy = 5
 credits = Public domain animal sounds: http://www.animal-sounds.org/index.html, Public domain animal pictures: http://commons.wikimedia.org/wiki/Main_Page
-creator = Beth Hadley
 locationpic = questionpic.png
-generalText = Click on the questions to explore each farm animal.
-SoundMatchingGameText = Click on the farm animal that makes the sound you hear.
-TextMatchingGameText = Click the animal that matches the description.
+_generalText = Click on the questions to explore each farm animal.
+_SoundMatchingGameText = Click on the farm animal that makes the sound you hear.
+_TextMatchingGameText = Click the animal that matches the description.
 textBoxX = 200
 textBoxY = 150
 
diff --git a/src/explore_world_animals-activity/resources/explore_world_animals/content.desktop.in b/src/explore_world_animals-activity/resources/explore_world_animals/content.desktop.in
index b48411d..f0ddd04 100644
--- a/src/explore_world_animals-activity/resources/explore_world_animals/content.desktop.in
+++ b/src/explore_world_animals-activity/resources/explore_world_animals/content.desktop.in
@@ -1,12 +1,12 @@
+# Created by Christina Hadley (with help from Beth Hadley)
 [common]
 background = world.jpg
 backgroundx = 10
 backgroundy = 10
 credits = http://aliciac.hubpages.com, http://www.public-domain-image.com, http://www.publicdomainpictures.net
-creator = Christina Hadley (with help from Beth Hadley)
 locationpic = tux.png
-generalText = Explore exotic animals from around the world.
-TextMatchingGameText = Click on location where the given animal lives.
+_generalText = Explore exotic animals from around the world.
+_TextMatchingGameText = Click on location where the given animal lives.
 textBoxX =105
 textBoxY = 180
 
diff --git a/src/explore_world_music-activity/resources/explore_world_music/content.desktop.in b/src/explore_world_music-activity/resources/explore_world_music/content.desktop.in
index 3ae2f24..37cecd5 100644
--- a/src/explore_world_music-activity/resources/explore_world_music/content.desktop.in
+++ b/src/explore_world_music-activity/resources/explore_world_music/content.desktop.in
@@ -1,13 +1,13 @@
+# Created by Beth Hadley
 [common]
 background = worldmap.jpg
 backgroundx = 10
 backgroundy = 10
 credits =  http://commons.wikimedia.org/wiki, http://archive.org
-creator = Beth Hadley
 locationpic = suitcase.png
-generalText = Explore world music! Click on the suitcases.
-SoundMatchingGameText = Click on the location that matches the music you hear.
-TextMatchingGameText = Click on the location that matches the text.
+_generalText = Explore world music! Click on the suitcases.
+_SoundMatchingGameText = Click on the location that matches the music you hear.
+_TextMatchingGameText = Click on the location that matches the text.
 textBoxX = 300
 textBoxY = 350
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]