I'm creating a quiz game with 4 answers and I want to add score

I'm creating a quiz game with 4 answers and I want to add score

Content Index :

I'm creating a quiz game with 4 answers and I want to add score
Tag : ios , By : user130518
Date : November 26 2020, 01:01 AM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

android: How can I get the right list of answers in a quiz game with random questions and answers?

Tag : android , By : Ohad Barzilay
Date : March 29 2020, 07:55 AM
hope this fix your issue I would be surprised if this code would compile and/or run correctly at all. You are trying to use the content of a String as an variable name, cast that variable to an ArrayList and then to access the elements. This is wrong on so many levels that you should consider doing a few Java tutorials again.
If you do or feel that you can continue anyways, try this approach: You shouldn't store the questions and answers in a separate list, but together in a class.
class Question
    // maybe id and other stuff belonging to a question

    String questionText;

    // separate because you need to tell the correct answer apart from the wrong ones later
    // you could also just always use the first one in a set of answers.
    String correctAnswerText; 
    ArrayList<String> wrongAnswerTexts;
// set up ArrayList<Question> questions here

int nxt = rng.nextInt(6);

// make sure your list is actually long enough for the generated index

Question nextQuestion = questions.get(nxt);

// make sure the retrieved object is valid
// set the question text to nextQuestion.questionText;

ArrayList<String> allAnswers = new ArrayList<String>();



Adding a score in a quiz with php and mysql were answers heeft different points

Tag : php , By : gopal
Date : March 29 2020, 07:55 AM
will be helpful for those in need If you looked at the output html source code from your php code, you would have been able to see most of your errors.
First, you are wrapping each question/answer set in its own
, but your submit button is in a separate
, so none of your answers will be posted, as they are not in the form with the action and submit button.
$strSQL="select vraag, vraagnummer, image_1, image_2, image_3, image_4, punten, antwoord ".
"from tbvragen as v ".
"inner join tbpunten as p ".
"on v.id_ptn = p.id_ptn ".
"inner join tbantwoorden as a ".
"on v.id_antw=a.id_antw ";

$rs = mysql_query($strSQL, $db);

// check to see if they submitted their quiz
// a variable for total points
$totaalpunten = 0;
while ($r = mysql_fetch_array($rs))
      // give the question number
    echo "Vraag ".$r["vraagnummer"])." - ";
      // check if their reply is the same as the correct answer
    if ($_POST["antwoord".$r["vraagnummer"]]==$r["antwoord"]) {
             // echo the points they got for this question
            echo $r["punten"]." puntens<br />";
             // add the points to the total points
            $totaalpunten += $r["punten"];
    else {   
            // if wrong show 0 points
            echo "0 puntens<br />";
 // give their total score
echo "je hebt ".$totaalpunten." punten";

 // if the quiz was not submitted, show the quiz
else { ?>
<form name="quiz" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
while ($r = mysql_fetch_array($rs))
{ ?>
      <h3>Vraag <?php echo($r["vraagnummer"]);?>  <?php echo($r["vraag"]);?><span>(<?echo($r["punten"]); ?> punten)</span></h3>
          <li><img src="images/<?echo($r["image_1"]); ?>"  /><input type="radio" name="antwoord<?php echo($r["vraagnummer"]);?>" value="A" /><label>A</label></li>
          <li><img src="images/<?echo($r["image_2"]); ?>" /><input type="radio" name="antwoord<?php echo($r["vraagnummer"]);?>" value="B" /><label>B</label></li>
          <li><img src="images/<?echo($r["image_3"]); ?>" /><input type="radio" name="antwoord<?php echo($r["vraagnummer"]);?>" value="C"/><label>C</label></li>
          <li><img src="images/<?echo($r["image_4"]); ?>" /><input type="radio" name="antwoord<?php echo($r["vraagnummer"]);?>" value="D" /><label>D</label></li>            
<?php  }    ?>
<input type="submit" class="button" value="verstuur je antwoorden" name="verstuur" />

Super simple quiz program. My answers are not validating and score isn't ++ either

Tag : javascript , By : Tim Tyrrell
Date : March 29 2020, 07:55 AM
will be helpful for those in need I am writing this super simple javascript quiz for practice. I am frustrated because I think my code is correct, but my code is not working. , for validation part:
  for (var i = 0; i <= questionArray.length; i++)
  for (var i = 0; i < questionArray.length; i++)
 for (var j = 0; j <= total.length; j++)
 for (var j = 0; j < answers.length; j++)

Quiz How to submit answers and score it

Tag : php , By : Navin
Date : March 29 2020, 07:55 AM
it helps some times Assuming that the questions are using select menus as you sort of suggested then this should help - though it is not tested...
    /* quizer.php */
        /* select correct answers from db */
        $sql='select * from `quiz`';
        $res=mysql_query( $sql, $con );

        /* store answers in an array for marking */

        /* populate the answers array */
        while( $rs=mysql_fetch_object( $res ) ){

        /* mark the answers */
        foreach( $_POST as $question => $answer ){
            echo $question.' '.$answer;
            if( $answer === $answers[ $index ] ) $score++;
        /* update the db */
        $sql="update `user` set `score`=$score where `username`='$username';"; /* etc */

<form action="quizer.php" method="post">
    <!-- assume select menus for questions and possible answers -->
    <label for='q1'>what is your name? 
        <select name='q1'>
            <option value="a">rolex</option>
            <option value="b">wales</option>
            <option value="c">israel</option>
            <option value="d">ade</option>

    <br />

    <label for='q2'>is nigeria a country?
        <select name='q2'>
            <option value="a">no</option>
            <option value="b">yes</option>

    <br />

    <input type="submit" value='Submit Quiz'>

Javascript Quiz - How to tally score from answers in multiple select elements?

Tag : javascript , By : Sumedh
Date : March 29 2020, 07:55 AM
help you fix your problem I believe the following function will make your quiz code more reusable. It takes into account the number of questions when calculating the percentage of correct answers. In order to add a question you will just have add the class question to each of select statements that will become a question.
live demo: http://codepen.io/larryjoelane/pen/ZQrKjY
function finalScore(){//begin function

  //initialize the correct variable
  var correct = 0;

  var selectValue;

  //store the collection of elements with the class name question
  var questions = document.getElementsByClassName("question");

  //the number of questions(elements with a class name of question)
  var numOfQuestions = questions.length;

//loop through the collection of elements with a question class
for(var i = 0; i < questions.length; i++ ){//begin for loop

 //get the value of the select element
 selectValue =  questions[i].options[questions[i].selectedIndex].value;

  //if the value equals right
  if(selectValue === "right"){//begin if then

    //increment the correct variable

  }//end if then

}//end for loop

//get the percentage of correct answers
document.getElementById("scoreDisplay").innerHTML = (100/numOfQuestions) * correct;  

}//end function
     <select class ="question" id="testValues1">
       <option value="right">a</option>
       <option value="wrong">b</option>
       <option value="wrong">c</option>
    <select class="question" id="testValues2">
       <option value="wrong">a</option>
       <option value="right">b</option>
       <option value="wrong">c</option>
    <select class="question" id="testValues3">
       <option value="wrong">a</option>
       <option value="wrong">b</option>
       <option value="right">c</option>

<button type="button" onclick="finalScore()">Submit</button>

<div id="scoreDisplay">score goes here</div>
Related Posts Related QUESTIONS :
  • iOS Unity Firebase Messenger Xcode Compile Error: FIRDynamicLinks
  • Firebase Storage Image Cache not updating SWIFT
  • unhandled js exception: application main has not been registered expo TestFlight
  • App freezes on IOS when navigate to another screen - React Navigation
  • How to create haptic feedback for a Button in SwiftUI?
  • How can I achieve automatic scrolling in my text view when text comes down to the keyboard level in Swift?
  • how to get the location with the CLLocationManager every 10 secondes?
  • Calling completion handler of a function from Timer selector function Swift
  • How to make SwiftUI view fullscreen?
  • RAM, JSC, Views, UI and JS usage table appearing whenever I launch my react native app. How to remove this table?
  • Change status bar background color using UIStatusBarManager
  • Should we make tapGesture component an IBAction or IBOutlet to capture the tap event?
  • Iframe automatically goes full screen using Ionic 3.9.2 on iOS
  • How to calculate score out of 1000 given some seconds (In Double)
  • How to calculate time (minutes) between two dates in swift?
  • There was problem loading requested app.it looks like you may be using LAN URL
  • Swift circular corners doesn't work properly on different screen sizes
  • How change .navigationBarTitle font in SwiftUI?
  • What happens if `MPSCNNConvolutionDataSource` protocol's `load` method return false?
  • Why does the UIBarButtonItem not show up when I create it with code?
  • How to prevent following view controller inheriting navigation view controller bar?
  • What does it mean when .xcodeproj files are shown in red in Xcode?
  • Xcode SwiftUI how to scroll the Preview Canvas?
  • Expand tableview and increase scrollview content size by an appropriate difference on clicking a button inside a table c
  • xcodebuild failed with return code: 65 - using CLI/Appcenter but no error messages
  • "'isDeveloperModeEnabled' is deprecated: This no longer needs to be set during development. " What is isDevelo
  • Right click in UIKit for Mac
  • How we Support Dark Mode in Current iOS App with iOS 13?
  • Security vulnerablility issue in ios mobile app
  • How to set a background color for the viewController in swiftUI?
  • SwiftUI : Segue navigation
  • iOS 13 Custom UISearchBar _searchField crash
  • USDZ models have holes in SceneKit but not QuickLook
  • Why does iOS Password Autofill not prompt to save password on keychain?
  • Pushing information to firebase after event is created(Firebase-Realtime-Database)
  • Xcode 11 Beta and Carthage bootstrap
  • How to change the status bar background color and text color on iOS 13?
  • Using Core Data with SwiftUI
  • How should I do to wait all the data downloaded completely and show on TableView?
  • Can we specify the number of rows that can be shown in each section of a collection view
  • Why sometimes completion handler not called?
  • Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements
  • In UIKit we can set label.numberOfLines = 0 when we do not know how many lines the text will take? What is the alternati
  • Swift ISO8601 format to Date returning fatal error
  • SwiftUI Login Page Layout
  • Xcode: Could not locate installed application. Install claimed to have succeeded, but application could not be found on
  • See the TestFlight crash log in the Xcode
  • Why does zero UIView's CALayer.speed stops UIAlertController's buttons from working?
  • Firestore collectionGroup query returns empty result
  • Modify text in SwiftUI
  • CNCopyCurrentNetworkInfo with iOS 13
  • WWDC 2019 - iOS13 April 2020 requirement
  • Nativescript IPhone X - How to "hide" home indicator behind two swipes to go to home screen
  • Should I use a singleton location manager in Swift?
  • Accessibility problem in reusable TableViewCell
  • Remove top line containing Done button from Keyboard Using Storyboard or in Swift
  • Swift Storyboard - Centring an Icon and multi-line text horizontally
  • viewDidAppear is delayed by 0.5 sec
  • Pass URL values to SecondView Controller WebView (WKWebView)
  • How to upload images faster on iOS, when using takePictureAsync?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com