State Quiz App tutorial - Question about JSON file

138 views
Skip to first unread message
Assigned to ewpa...@gmail.com by steve....@gmail.com

Callie Owens

unread,
Nov 7, 2018, 9:38:37 AM11/7/18
to MIT App Inventor Forum
I am a teacher and I am getting my students to complete an MIT tutorial that I found called "State Quiz App." When we try to use the GeoJSON file that it provides (add it as the source of the FeatureCollection1), App Inventor shows a message saying that an internal error has occurred. See screenshot attached. Does anyone know why this .json file won't work? It seems that it should work if it is provided by MIT. Thanks, Callie

internalerror.PNG


internalerror.PNG

SteveJG

unread,
Nov 7, 2018, 10:36:48 AM11/7/18
to MIT App Inventor Forum
The FeatureCollection feature is broken (or the JSON file provided).  The tutorial just does not work.
See MIT's comments regarding the FeatureCollection from an October Forum thread  where Evan said" Thanks for investigating this. I'll look into it and see what we can do to fix it. It's being tracked as issue #1387."

Unfortunately "seems that it should work if it is provided by MIT" is no guarentee.    I suspect this is related to the many changes MIT has had to make with respect to Google security issues but it may be something else.  


Regards,
Steve

Evan Patton

unread,
Nov 7, 2018, 11:11:20 AM11/7/18
to MIT App Inventor Forum
Hi Callie,

It appears as though Google Docs puts a byte order marker at the beginning of the GeoJSON file and that the JSON parser in Chrome doesn't handle this correctly. I've attached a version that should import into App Inventor correctly and filed a bug to address this issue.

Regards,
Evan
usa-new-england.geojson

SteveJG

unread,
Nov 7, 2018, 2:48:16 PM11/7/18
to mitappinv...@googlegroups.com
@Callie    use Evan's JSON file, place it in Media and use the file in the FeatureCollection  Source  property.  I tested the replacement file.  It works.  Does the tutorial work as expected now?  

Regards,
Steve

@Evan... thanks.

Callie Owens

unread,
Nov 7, 2018, 2:56:59 PM11/7/18
to MIT App Inventor Forum
There is no longer an error when I upload the file! My students aren't finished with the tutorial, but so far so good! (The internal error is gone)  Thank you @Evan and @Steve!

Evan Patton

unread,
Nov 7, 2018, 3:56:24 PM11/7/18
to MIT App Inventor Forum
I also put in a patch to fix this bug in general so the file doesn't have to be corrected (although it's actually invalid JSON because of the byte order marker). If testing goes well then I expect that it should be in the next release. Glad that the file workaround resolves the issue for you.

Regards,
Evan

Callie Owens

unread,
Nov 12, 2018, 9:37:29 AM11/12/18
to MIT App Inventor Forum
Do you happen to have this tutorial completed? I am having trouble debugging my students' code--I need an answer "key!" Does someone have this completed project file that I could look at?  Thanks!

SteveJG

unread,
Nov 12, 2018, 10:02:55 AM11/12/18
to MIT App Inventor Forum
MIT never posted an aia of the 'completed' tutorial Callie.  Evidently they forgot  http://appinventor.mit.edu/explore/ai2/state-geography-quiz.html .

What have your student's coded so far (post your aia)?  Someone could perhaps debug it .    MIT has been notified that there is no aia online.

Regards,
Steve

Callie Owens

unread,
Nov 12, 2018, 10:08:36 AM11/12/18
to MIT App Inventor Forum
I attached the project .aia file to be debugged. Do I need to start a new thread to see if someone can help?
StateQuizApp_ToBeDebugged.aia

SteveJG

unread,
Nov 12, 2018, 10:14:35 AM11/12/18
to MIT App Inventor Forum
Either someone from MIT will post a link to an aia or someone will look at your posting Callie.  You need to be patient.  MIT has been informed and others will see your post.  I guess this is a race between Forum users and MIT.  :)

SteveJG

unread,
Nov 12, 2018, 10:57:19 AM11/12/18
to MIT App Inventor Forum
As far as I can tell, the problem is the FeatureCollection1.FeatureClick   'feature' is not responding as MIT expects.

How do I know?  Disable your existing blocks (that appear OK per the tutorial instructions) and add the colored blocks at the top as shown

featureCollectionFeatureClick.PNG


The state should display in the TitleBar, instead nothing displays.  This shows the component is not working properly.
This is a BUG.   You cannot complete the Project until MIT fixes this.


Regards,
Steve

Abraham Getzler

unread,
Nov 12, 2018, 2:49:55 PM11/12/18
to MIT App Inventor Forum
I took a look at the uploaded .aia file, and read it with fresh eyes,
having not used the map features yet.

I experienced index 0 errors when clicking on states
before picking a quiz.  I attributed this to some missing initialization,
and added a Screen1.Initialize event calling one of the
quiz selection button actions.  That seemed to clear this up.

None of the states were being recognized, so I read thru the feature.click event.
It works off one of the feature attributes for its state lookup.
However, the state features in the Designer, though well named
as Components, had blank Descriptions and Titles, thwarting 
the coded lookups based on those features.
I worked around that by adding a run time lookup procedure
mapping feature components into State names.

That works, at least in my emulator.

Updated source attached.

I did not have time to look at the tutorial, to see if
it was at fault, or if the student missed the feature
attribute setups.

By the way, I removed the GEOJSON and GEOJSON(1)
Media files,  They were not referenced, and the (1) is always troublesome at build time.

I saw no evidence of malfunction of the feature selection event,
though i noticed that I have forgotten my Eastern Seaboard lore.

ABG


blocks.png
StateQuizApp_ABG.aia
Capture.PNG

Abraham Getzler

unread,
Nov 12, 2018, 3:21:48 PM11/12/18
to MIT App Inventor Forum
Regarding the MIT quiz instructions and included materials,
I notice that the geojson file only had a title for Connecticut,
and no titles for any of the other states.

The quiz had no instructions for manually filling in the required Title attributes
and no run time code to pull in attributes from the Feature Collection naming that geojson file.

I am guessing the state features appeared in the Designer as a side effect from
AI2 when the geojson file was added to the parent Feature List in the Designer.
however, even Connecticut had no title attribute.  

So as far as I can tell, the tutorial is incomplete and its geojson file is incomplete.

ABG

SteveJG

unread,
Nov 12, 2018, 5:45:00 PM11/12/18
to MIT App Inventor Forum
After a bit more testing, it appears either the Polygon.Title  block is not working or the JSON file Evan provided is still not correct.  I thought the FeatureCollection.FeatureClick event handler is not working.   However it is working.  What is not working is either the Polygon.Title block is broke or it does work but the JSON file is still not 'correct'


Here is a work around you might use  I 'fixed' only the state portion of the quiz by creating a List of the Features and providing a default state values.

All the changes are in the FeatureCollection1.FeatureClick .  Also, several variables were added as shown. (all the stuff in fuchsia)  What was taken out is the x'ed blocks

StateMapFix.PNG



Remember, only the states works; write similar code for the capitals or wait until MIT provides a real fix.  Good luck.



Regards,
Steve

StateQuizApp_partiallyDebugged.aia

Evan Patton

unread,
Nov 13, 2018, 12:57:21 PM11/13/18
to MIT App Inventor Forum
The problem here is a known bug that prevents the feature Title from being populated from the GeoJSON file. The bug has been fixed and will be part of the Thanksgiving release. Attached is a complete project with the titles prepopulated. I've also passed some information along to the education team to improve the tutorial.

Regards,
Evan

StateQuiz.aia

Callie Owens

unread,
Nov 13, 2018, 1:26:09 PM11/13/18
to MIT App Inventor Forum
Thank you!
Reply all
Reply to author
Forward
0 new messages