Can someone help me please? (QUIZ)

Hi everyone , I have made 1 board game with pawn’s and i have to add MCQ’s in so that when pawn’s moves on one of the place’s like (PHP, PYTHON, JAVA) it has to show automatically the questions and answers one by one.
about one of them. for example if pawn’s moves on Python it has to show me python mcq like 1 question and 4 answer that one of them. i have also questions and also answers but i have no idea how can i set this in my boardgame . can u please help me ?
Because i am a new use i can not put a image.jpeg here
the links below is my board game and my code .

Thank U

Hey, welcome to the forum!

Great to have you here!

Please post your entire code as text, not as an image.

Best is when you have a list that represents one

multiple choice question

as you can see the questions and answers and correct answer number are separated by #

you can use split() to split it up to an array

When you have a list for your board, you want to have one line of the list associated with a cell in the board

String[] listMCQ = 
  {
  "Who has...?#Frank#Paul#Ann#Mary#2#", 
  "Where is...?#France#Brasil#Italy#UK#3#", 
  "When......#  #  #  # ......."
};

Chrisir

Thanx for your advise , can i send my code as txt ? because its too long and i have 4 of them
btw i use python

you can post your code here and select it and click </> in the small command bar

from coords import coordinates
from js_coordinates import jsCoordinates
from php_coordinates import phpCoordinates
from python_coordinates import pythonCoordinates

diceNumber = 0
currentlyPlaying = "PHP"
currentLanguage = 'Start'
teamPosition = {
    "PHP": coordinates[0],
    "JS": coordinates[0],
    "Python": coordinates[0],
    "D-State": coordinates[0]
}

def setup():
    size(1412,1000)
    
def draw():
    global diceNumber, currentPosition
    img = loadImage("board1.jpg")
    background(img)
    
    # Dice Box
    fill(255,255,255)
    rect(1000, 750, 200, 200)
    
    fill(0,0,0)
    textSize(100)
    text(diceNumber, 1068, 885)
    
    # Pawn PHP
    x, y = teamPosition["PHP"].split(',')
    fill(148,0,211)
    noStroke()
    circle(int(x) + 42, int(y) + 50, 75)
    fill(255,255,255)
    textSize(26)
    text("PHP", int(x) + 20, int(y) + 58)
    
    # Pawn JS
    x, y = teamPosition["JS"].split(',')
    fill(255,255,0)
    noStroke()
    circle(int(x) + 46, int(y) + 50, 75)
    fill(255,255,255)
    textSize(26)
    text("JS", int(x) + 35, int(y) + 58)
    
    # Pawn Python
    x, y = teamPosition["Python"].split(',')
    fill(65,105,225)
    noStroke()
    circle(int(x) + 50, int(y) + 50, 75)
    fill(255,255,255)
    textSize(18)
    text("Python", int(x) + 25, int(y) + 58)
    
    # Pawn D-State
    x, y = teamPosition["D-State"].split(',')
    fill(220,20,60)
    noStroke()
    circle(int(x) + 54, int(y) + 50, 75)
    fill(255,255,255)
    textSize(16)
    text("D-State", int(x) + 22, int(y) + 58)

def mousePressed():
    global diceNumber, currentlyPlaying, currentLanguage
    if 1000 < mouseX < 1000 + 200 and 750 < mouseY < 750 + 200 :
        diceNumber = int(random(1, 7))
        oldPosition = coordinates.index(teamPosition[currentlyPlaying])
        if oldPosition + diceNumber >= len(coordinates):
            tempNewPosition = oldPosition + diceNumber
            teamPosition[currentlyPlaying] = coordinates[tempNewPosition - len(coordinates)]
        else:
            teamPosition[currentlyPlaying] = coordinates[oldPosition + diceNumber]
            
#cardselecter                        
        if currentlyPlaying == "PHP":
            if teamPosition['PHP'] in phpCoordinates:
                currentLanguage = 'PHP'
            elif teamPosition['PHP'] in jsCoordinates:
                currentLanguage = 'JS'
            elif teamPosition['PHP'] in pythonCoordinates:
                currentLanguage = "Python" 
        
        elif currentlyPlaying == "JS":
            if teamPosition['JS'] in phpCoordinates:
                currentLanguage = 'PHP'
            elif teamPosition['JS'] in jsCoordinates:
                currentLanguage = 'JS'
            elif teamPosition['JS'] in pythonCoordinates:
                currentLanguage = "Python" 
                
        elif currentlyPlaying == "D-State":
            if teamPosition['D-State'] in phpCoordinates:
                currentLanguage = 'PHP'
            elif teamPosition['D-State'] in jsCoordinates:
                currentLanguage = 'JS'
            elif teamPosition['D-State'] in pythonCoordinates:
                currentLanguage = "Python" 
                
        elif currentlyPlaying == "Python":
            if teamPosition['Python'] in phpCoordinates:
                currentLanguage = 'PHP'
            elif teamPosition['Python'] in jsCoordinates:
                currentLanguage = 'JS'
            elif teamPosition['Python'] in pythonCoordinates:
                currentLanguage = "Python" 
        print(currentLanguage)
#Turn switch 
        if currentlyPlaying == "PHP":
            currentlyPlaying = "JS"
        elif currentlyPlaying == "JS":
            currentlyPlaying = "Python"
        elif currentlyPlaying == "Python":
            currentlyPlaying = "D-State"
        elif currentlyPlaying == "D-State":
            currentlyPlaying = "PHP"

    #currentlanguage
        


        
  
coordinates = [
    "3,6", #start
    "116,6", #python
    "229,6", 
    "342,6", #php
    "453,6", #python
    "566,6",
    "679,6", #php
    "679,111", #python
    "793,111", #js
    "906,111", #php
    "906,216", #python
    "906,320", #js
    "793,320", #php
    "680,320", #python
    #"906,425", 
    #"906,530",
    #"906,630",
    #"1019,630",
    #"1132,630",
    "680,425", #js
    "680,525", #php
    "680,625", #python
    "567,625", #js
    "567,730", #php
    "567,830", #shortcut
    "453,830", #js
    "338,830", #php
    "223,830", #python
    "108,830", #js
    "108,724", #php
    "108,619", #python
    "108,522", #js
    "108,422", #php
    "220,422", #python
    "335,422", #js
    "447,422", #php
    "447,310", #python
    "447,220", #js
    "332,220", #php
    "217,220", #python
    "102,220", #js
    "3,220", #php
    "3,113", #death
]
jsCoordinates = [
    "229,6", #js
    "566,6", #js
    "793,111", #js
    "906,320", #js
    "680,425", #js
    "567,625", #js
    "453,830", #js
    "108,830", #js
    "108,522", #js
    "335,422", #js
    "447,220", #js
    "102,220", #js
]
phpCoordinates = [
    "342,6", #php
    "679,6", #php
    "906,111", #php
    "793,320", #php
    "680,525", #php
    "567,730", #php
    "338,830", #php
    "108,724", #php
    "108,422", #php
    "447,422", #php
    "332,220", #php
    "3,220", #php
]
pythonCoordinates = [
    "116,6", #python
    "453,6", #python
    "679,111", #python
    "906,216", #python
    "680,320", #python
    "680,625", #python
    "223,830", #python
    "108,619", #python
    "220,422", #python
    "447,310", #python
    "217,220", #python
]

Thank you.
I cannot help you, I don’t know python.

But my idea should help you. Just make a list, couple it with the image grid and parse each line that is the current question

I mean a list with multiple lines

  • each line is a set of questions and answer. Each line you have to split().

Alternatively you can make a 2D grid where you have a list A of lists B

and B is a list like Questions, answer1, answer 2 etc.

and then you show only ONE list B from the list A (and A receives its index from the image grid)

Hello,

Your subject clearly states homework and QUIZ.

Were you taking a quiz (academic that will be graded) and asking us for help?

Be honest…

if i had coaching or some help about my subject, believe me i would never ask here !
and + i am a beginner and its my first project . Do u remember your self when u write the first if statement?
iam in that time :wink:

here is my example

String[] listMCQ = 
  {
  "Who has...?#Frank#Paul#Ann#Mary#2#", 
  "Where is...?#France#Brasil#Italy#UK#3#", 
  "When......# 1981 # 1891 # 387 # 1492 #4#"
};

int numberQuestion = 0; 

// ----------------------------------------------------
// main funcs 

void setup() {
  size(1100, 1000);
  background(0);
}

void draw() {
  background(0);

  text ("Question #"+numberQuestion+": ", 200, 200);

  String[] thisQuestionData = split(listMCQ[numberQuestion], "#"); 

  // Question 
  text( thisQuestionData[0], 200, 230); 

  // possible answers 
  for (int i = 1; i<thisQuestionData.length-2; i++) {
    noFill();
    stroke(255); 
    rect(230, 270+i*22-14, 200, 20); 
    fill(255); 
    text( thisQuestionData[i], 260, 270+i*22);
  }

  // Correct number 
  text( thisQuestionData[5], 422, 270+6*22);

  text( "Hit Space Bar to go on", width-222, 270+6*22);
}

// ----------------------------------------------------------------

void keyPressed() {

  if (key==' ') {
    numberQuestion++;
  }
  if (numberQuestion>=listMCQ.length)
    numberQuestion=0;

  // test
  println (listMCQ[numberQuestion]);
}
//