2016년 11월 15일 화요일

Help with Quizapp Lists and Database


Hello everyone,
After I have created my first App (and published it) I thought it was time to start a second one.
Until now I have more or less the layout and concept of the app worked out but I am kinda stuck how to proceed next. Let me tell you what it is about and where I need help.
Basically it is a pretty standard Quiz app which gives you a question (from a huge database - later more on that) and 5 answer possibilities (only one anser is correct)
All you have to do is choose a b c d or e and the app will tell you either that you are correct or show you the correct answer. Then move on to the next question.
Now that is per se not very difficult but I have several things I have not quite worked out yet:
1.) The questions screen has several "items" which should be left untouched when chancing the question/answering the question (things like buttons to cancel and a timer as well as a counter which shows you how many questions (out of X questions) you already solved)
2.) The Question Database: It is a huge database with several thousand questions I guess tinydb is not quite capable of managing this amount of information - is csv a possibility? Also I want the Questions be grouped in topics (for example if you want to train yourself you can choose Topic 1 and the app will only ask you questions from Topic 1) Splitting this up into different databases would be no problem for me.
3.) Sometimes there is a text applicable for several questions. So i need to be able to somehow show this text in addition to the question.

I hope i got my problems across and as always - i am not a native speaker so please forgive me my bad english - if anything is unclear, please let me know and I will do everything to clearify.

Thank you all for reading and helping me.

-- 
concerning the database, do you like to update the database regularly? If yes, then you could use a server database and download the questions and answers by topic

do the Pizza Party tutorial to learn how fusiontables work
alternatively you could use a MySQL database on a web server
in case the database is static and you do not plan to update it, then you could store the database locally.
a) you can use csv files and upload them from the assets into your app, then, convert them into lists and store them in TinyDB, or
b) use a SQlite database, see also SQlite Extension to access the local SQlite database

· How to work with Lists by Saj

· How to work with Lists and Lists of lists (pdf) by appinventor.org

-- 
Thank you so much Taifun! But I have a Problem since Pizza Party is basically the opposite way how I want to interact with the database (sorry I have not much experience with AppInventor and Databases in general)
Right now I have 3 Screens:
First Screen is basically the Main Menu, gives the User a Overview of the App, a Picture, a Text and 3 Buttons: 1.) Select the Category 2.) Example Exam 3.) End
This is the respective Blocks for the first screen
Here the Blocks
I'll show the picture (to make it easier to explain)

One Back button (To previous screen) Shown as "Zurück"
One Help Button (does't do anything yet - not sure if i even keep it) shown as "Hilfe) - Now that i think about it I will Change it to Next (to load the next question)
next to it is a counter (you will see how i made it in the blocks)
Text for Label3 is actually Named LCategory and if for example Herzkreislauf is picked it should show up as Herz (or Herzkreislauf)
The Textbox below should load a random Question from the Category Herz (if Herz is selected on the previous screen)
Antowort= Answer
The 5 Checkboxes are the 5 Answers and the Text for Checkboxes should be replaced by the Answers for the selected question)
The little Green box is an Empty Lablebox which should compare the selected Checkbox to the correct answer and then appear either Correct or incorrect.

However I run into a couple of problems:
1.) I can not get the Questions or anything to load from my Database (I have created a very simple sample database with 2 Questions and Answers (can be found here: https://www.google.com/fusiontables/DataSource?docid=1xqiqT1IzlqJPJuuVU611hEArinnaIG-KXKTv3yKM )
2.) How can I load a random question but make sure that question will not show up again
3.) I would like to include a counter which counts the Correct answers out of the total answered questions and which will show up at the end to give an overview.

I am very sorry that I am a frustrating new user please bear with me. I am a bit overwhelmed by all of this but i have to get through this :) (bare in mind i am a simple medical student not a it guy)
Thank you all so much.

-- 
in Screen2 instead of using 50 checkboxes, you could have used a listicker, listview or spinner...

see the following tips and in your case especially #3 and #4


2. follow these recommendations Using Images with App Inventor

3. avoid redundancy
probably it helps to read chapter 19 - 21 in Dave's book http://www.appinventor.org/book2 to get an idea how to do DRY programming with App Inventor https://en.wikipedia.org/wiki/Don%27t_repeat_yourself



6. Backup your project frequently, see also http://twodogapps.com/?page_id=686#BackupWork
the fusiontable component works asynchronously, which means, you will receive the result in the fusiontable control got result event!


just download all questions (of a specific topic) and the corresponding answers and store them locally in lists
you might want to take a look again at the already provided example

don't hesitate to adjust it to your needs

you might want to do some more tutorials first to understand the basics...

Taifun
PS: next time please ask shorter questions... it there someone who likes to read such loooooong questions?
also it might help to start a new thread for new questions...


--

Besides what Taifun told you, there are some more things you should know about Fusion Tables
(see my FAQ's Fusion Tables section for links): Fusion Tables fq

Each row has a unique extra column named ROWID that you can request in your query, to keep track of that row.
It is handy for adding to global lists you might find useful:
ALL_Unused_ROWIDs_IN_Category and
Already_Presented_ROWIDs.

There are three different queries relevant to your application, that you should handle
using different Fusion Tables Controls:
SELECT DISTINCT CATEGORY FROM .....     (fix the column name to match yours)
SELECT ROWID FROM ... WHERE CATEGORY = '(fill in this part)'
SELECT Question, Answer1, Answer2,...Answer5, ...  from ... WHERE ROWID = (pick this from your ALL_Unused_ROWIDs_IN_Category list)

The first query saves you from having to hardwire categories in your blocks.
The second query gets you a list of ROWIDs for a selected category
The third query is what you should have used for your single question/answer load.

As you use up a ROWID, remove it from ALL_Unused_ROWIDs_IN_Category.


Also, you are not using the Query attribute properly.
See the samples in the Fusion Tables section of the FAQ

-- 
Thank you guys for your kind help I know how frustrating it can be to help someone who is new to something! Thank you both!


--

댓글 없음:

댓글 쓰기