## Discuss Scratch

-Polka-Dots-
Scratcher
14 posts

### How to make results for a quiz?

So I was making an elemental quiz and when it finally came to the results part, I was stumped. I wanted to do something but then Scratch wouldn't let me put a variable in the green operator block so yeah. How would you do it so that it says: If fire > water and nature and ice and wind and earth then blah blah blah. I don't know how to do that though. Can someone help?

Check Out This Studio!

Have a Cookie and A Good Day!

©This signature is sprayed with kumquats disinfectant. I am now attacked by evil loquats though…
deenfoxx
Scratcher
100+ posts

### How to make results for a quiz?

Is this it? https://scratch.mit.edu/projects/151013564/

Looks like you are storing numerical integer values in each of the variables; earth, fire, ice, nature, water, wind… so it is simply a matter of comparing them to each other. I'm assuming you want to figure out which has the highest number of points?

From your current setup, the easiest would be to create a sorted list like this…

(1) Create a list
(2) Use the value of each PLUS 1 as the index (since Scratch lists are 1-based, not zero-based)
(3) If an index already has a value, then you can either throw it away or append to it.
(4) When done… take the last value… that is your highest element (or elements)

Last edited by deenfoxx (March 20, 2017 05:38:48)

deenfoxx
Scratcher
100+ posts

### How to make results for a quiz?

Got a better solution for your CURRENT settings. See here…

https://scratch.mit.edu/projects/151127379/

Granted, I would have started with the list in the first place, and store the data directly to the list instead of variables. However, I'm not here to refactor your project, only to answer your current question. See Inside, then go to the You Are… Sprite to see the script. It should be pretty self explanatory. It just runs through each of your six variables and puts them into the list if they are of EQUAL value to the highest (so far found) score. When it comes across a higher score, it dumps the list and starts over with this new highest score… until it reaches the end. This way the final list contains one (or more) best element match. It will be up to you to determine if one or the other wins out in a tie.
deenfoxx
Scratcher
100+ posts

### How to make results for a quiz?

I don't understand why my replies keep getting deleted! It's really annoying, Scratch!

Anyway… Go here… I made a remix solution to your issue. This one is even better than I described in the post above…

https://scratch.mit.edu/projects/151127379/

Since I already wrote a lot which was deleted, I'll just keep it simple… It keeps a list of only the top scoring elements. Go See Inside and look at your “You Are…” sprite for the script code I added.

Last edited by deenfoxx (March 20, 2017 06:32:46)

-Polka-Dots-
Scratcher
14 posts

### How to make results for a quiz?

Thank you! I kinda have another problem though… heh… How would you do it so that if you get fire or something, it switches to a certain backdrop? Sorry for all the questions that may be stupid, I'm not that good at programming

Check Out This Studio!

Have a Cookie and A Good Day!

©This signature is sprayed with kumquats disinfectant. I am now attacked by evil loquats though…
deenfoxx
Scratcher
100+ posts

### How to make results for a quiz?

I see my deleted post is back again, sorry for the duplicate.

To answer your new question… Simple, if you keep the backdrop name the same as the element name and you don't care about tie breakers…

`  switch backdrop to (item (2) of [bestMatches v] :: list)`

Otherwise you'll have to have a bunch of these…

`if < (item (2) of [bestMatches v] :: list) = [fire]> then  switch backdrop to [name_of_fire_backdrop v]`

If you do want to do a special backdrop for tie-breakers, you'd have to do something like this…

`  set (backdrop) to (item (2) of [bestMatches v] :: list)if <(length of [bestMatches v] :: list) > [2]>  set (backdrop) to (join (join (backdrop) [-]) (item (3) of [bestMatches v] :: list))end  switch backdrop to (backdrop)`

The above code would create strings combining doublet tie-breaking possibilities, if they occur… which means you'd have to make a lot of backdrops… in this order (meaning, it will always be “earth-fire”, never “fire-earth”), if following the code I wrote.

earth
fire
ice
nature
water
wind
earth-fire
earth-ice
earth-nature
earth-water
earth-wind
fire-ice
fire-nature
fire-water
fire-wind
ice-nature
ice-water
ice-wind
nature-water
nature-wind
water-wind

…and that doesn't even include the triplet tie-breakers, which are currently a possibility.

A better option would be to fine-tune your scoring using floating point values to try and prevent tie-breakers from occurring at all.
KellsOfKells
Scratcher
5 posts

### How to make results for a quiz?

WWWWWWHHHHHHHHAAAAAATTTTTT?????????
-Polka-Dots-
Scratcher
14 posts

### How to make results for a quiz?

KellsOfKells wrote:

WWWWWWHHHHHHHHAAAAAATTTTTT?????????
Please do not put unnecessary posts in this thread. This is only for if you have an idea to help me. I don't really understand what you are confused by. ?

Check Out This Studio!

Have a Cookie and A Good Day!

©This signature is sprayed with kumquats disinfectant. I am now attacked by evil loquats though…
deenfoxx
Scratcher
100+ posts

### How to make results for a quiz?

Ignore it… notice KellsOfKells is a Scratcher with only 2 posts (this was this first)… someone's just messing around.