scripting the ability to add controls

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
dandun
Posts: 24
Joined: Thu Apr 10, 2014 3:41 pm

scripting the ability to add controls

Post by dandun » Wed Jun 18, 2014 2:58 pm

I have seen example on how to create a quiz where I define the question and answer if it is correct or wrong, etc. But is there an existing example out there of how to give the end user via script the ability to add controls i.e. buttons and fields to “create” a quiz on the fly?

Assume a teacher had the ability from an iPad to dynamically create a test for students as the curriculum changes.

1. Choose a type of question:
a.True/False
b. Multiple Choice (number of choices)
c. Numeric

2. Create the Question & answer

For some reason, this appears to be very simple, but can’t get my head around it.
Thanks for your help!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: scripting the ability to add controls

Post by dunbarx » Wed Jun 18, 2014 5:57 pm

Hi.

Check out the "create" command in the dictionary. In this way you could, er, create a new button and perhaps a new field.

The important next step is to understand LC properties. Do you have experience with this? For example. You could populate the field with text, by setting the "text" property of that field. You could place a handler in the new button, because the "script" of that button is a property of that button. So for example; (pseudocode):

create button "askQuestion"
create field "answerField"
set the script of button "askQuestion" to myQuestionScript
send "mouseUp" to button "askQuestion"
put theAnswer into field "answerField

Now all this is silly, in fact, though certainly doable. Why do you want to make new controls? For what I see as your project, these should all be premade and ready to work. If your interface requires that these controls appear and disappear, then do that, using the "hide" and "show" commands. Write back with your thoughts, or where I am missing your point.

Craig Newman

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: scripting the ability to add controls

Post by Klaus » Wed Jun 18, 2014 6:41 pm

Hi dandun,
dandun wrote:...Assume a teacher had the ability from an iPad to dynamically create a test for students as the curriculum changes.
if this is possible somehow, how do you want to distribute the new quiz (which will be a stack?) to the students?
You are not allowed to:
...
go url"http://www.server.com/a_new_quiz.livecode"
...
!


Best

Klaus

dandun
Posts: 24
Joined: Thu Apr 10, 2014 3:41 pm

Re: scripting the ability to add controls

Post by dandun » Thu Jun 19, 2014 5:09 am

Ok, Sorry. In my effort to be short and concise, I think I just confused the question for everyone but miswording and not giving enough detail.
I have provided some wireframes below to walk through the basic idea.

I am still in the early learning stages, but was thinking that there has to be a way to:
1. Teacher to Authenticate to MYSQL
2. Create a test (see attached wireframes)
3. Extract the correct data using a database record set and then
filing in a template to be used appropriately
4. Authenticated users can run the test

I am for now just playing around with the SQLite but an end application would obviously first need to move to MySQL so that multiple users can authenticate, save test, run test etc.
I was thinking a combination of a show/hide groups for the top progressive navigation as well as using Modal to force the data population and navigate through the question builds. And ultimately utilize a data grid to populate the questions with additional info to edit.

I hope this makes it more clear what I was trying to accomplish.
Thank you again for your help
Dan
Attachments
wireframe1.PNG
1 of 3
wireframe2.PNG
2 of 3
wireframe3.PNG
3 of 3

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: scripting the ability to add controls

Post by Simon » Thu Jun 19, 2014 6:44 am

Hi Dan,
This is for iPad/mobile so "modal" won't do anything for you, stacks take over the full screen on mobile.
Yes, everything you said can be done with liveCode.
Sorry, but I'm still not clear on the actual question.

Is it inserting data into SQL that you are unsure of?
Is it pulling data from a table?
Is it how to create a table?
i.e. buttons and fields to “create” a quiz on the fly?
Seems you have all the buttons and fields, just show/hide will work.
Oh, maybe it's show/hide a group? Just group everything in each modal window.

I guess lets start with 1 single direct question. eg How do I group controls?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dandun
Posts: 24
Joined: Thu Apr 10, 2014 3:41 pm

Re: scripting the ability to add controls

Post by dandun » Thu Jun 19, 2014 1:57 pm

Thanks Simon,

Good suggestion on 1 question at a time. Let me back up and start by asking a question about Navigation.

I did not realize that there was a limitation on modals for IPad. Let’s assume that the use case calls for a cross platform solution and is not locked down to an IPad.
If we take the wire-frames as an example, where the IA is trying to progress the user through the creation of at least one full record; is there a rule of thumb when creating a mobile app where it is better to use one solution over the other due to performance, ease of use or other maintaining as a cross platform app?

1. Using hide/ show groups on the same card for each step or
2. Create a background group and navigate across separate cards.
3. Other?

Best
Dan

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: scripting the ability to add controls

Post by Simon » Thu Jun 19, 2014 8:53 pm

Hi Dan,
When I started with liveCode everything had to be on a separate card, now I use as few cards as possible with most of the code in the stack script. Both work equally well, it's just now I only have to go to 1 place to work on code.
Performance?
I don't see that you are doing anything processor intensive mobile/desktop should handle it well.
1 card or multiple?
Up to you. (note you wouldn't use background for the UI except for possibly the 123 across the top)
Other?
Check out iPhone's setting page and see all the sliding controls. LiveCode can do that.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TerryL
Posts: 78
Joined: Sat Nov 23, 2013 8:57 pm

Re: scripting the ability to add controls

Post by TerryL » Fri Jun 20, 2014 8:28 pm

Hi Dan.

Here's a Quiz stack to look over for ideas, modify or use as-is.

All on one card, multiple choice or true/false. Instructor writes quiz text and answers key, distributes quiz to students. Student can take quiz only once. Self-scoring, password protected, optional timer, instructions. Terry
Attachments
StudentQuiz.zip
(3.54 KiB) Downloaded 219 times
Beginner Lab (LiveCode tutorial) and StarterKit (my public stacks)
https://tlittle72.neocities.org/info.html

dandun
Posts: 24
Joined: Thu Apr 10, 2014 3:41 pm

Re: scripting the ability to add controls

Post by dandun » Sun Jun 22, 2014 2:45 am

TerryL, Thank you very much!

JackieBlue
Posts: 32
Joined: Sun Jun 22, 2014 2:37 am

Re: scripting the ability to add controls

Post by JackieBlue » Sun Jun 22, 2014 5:40 am

I'm new to LiveCode. However, I have done similar things in vb as well as php. What I did was use a database and put the questions in a dynamic grid. The quiz (or interview questions in my case ) were all stored in the database. Each question had an answer type that dynamically determined what kind of answer key should b e displayed such as multiple choice, true/false, or entry. I don't see why a similar solution could not be done in LC.

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: scripting the ability to add controls

Post by SparkOut » Sun Jun 22, 2014 8:54 am

Hi Jackie
That is quite right. There is no reason at all that you could not use a database and take your approach. There are many ways to do things in different languages - but you will find that LiveCode has an amazing number of ways to skin the cat. The thread above just reflects the progression of questions and helping with some individual concepts before becoming a quiz sampler. It's great to see different ideas in use, there is usually never one "right" way, so please don't think you shouldn't use a database type solution. There may be certain concepts that don't translate from other languages without some kind of mindset change perhaps (eg object orientation versus message path event driven handlers) but mostly you are unrestricted in the way you choose to tackle a problem.
Welcome to LiveCode

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”