Results 1 to 6 of 6
  1. #1
    Vauntage's Avatar
    Join Date
    Jan 2018
    Gender
    male
    Posts
    580
    Reputation
    45
    Thanks
    58
    My Mood
    Hot

    I have no idea how to start on my assignment. Some help would be amazing.

    So, I'm supposed to create a dynamic website, where user can choose quiz questions from 3 sections [geography,history,literature]. After the user finishes a quiz attempt, I will have to do a point calculation. Then the user can be offered to attempt a quiz from another section, do the same section but different questions or exit.

    Where I'm stuck at, is this part. For every section should be at least 20 questions of which 10, by random choice, should be displayed to a user in every quiz attempt.

    My professor stated that the questions should be stored in a txt file, and the quiz has to be multiple choice.

    I have a txt file that has questions and is separated by PHP_EOL, and another txt file that has the options for the questions, also separated by PHP_EOL.

    How would I do it such that when I do randomize the question, the options follow the specific question? I was thinking of something along the lines of a pointer, but I don't think that will be possible.

    Any and all advice/help will be greatly appreciated.

  2. #2
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    it's possible, but can i ask if it's forced to be more textfiles?
    i would write everything in 1 File
    Code:
    <?php
    	$line = "Is this a Question?|Yes#No#Maybe|Yes"
    	$elemets = explode('|', $line, -1);
    	$object = (object) [
    		'question' => $elements[0],
    		'answers' => explode('#', $elements[1], -1),
    		'correct_answer' => $elements[2],
    	];
    	print_r($object->question);
    	print_r($object->answers);
    	print_r($object->correct_answer);
    ?>

  3. The Following User Says Thank You to MikeRohsoft For This Useful Post:

    Vauntage (02-13-2019)

  4. #3
    Vauntage's Avatar
    Join Date
    Jan 2018
    Gender
    male
    Posts
    580
    Reputation
    45
    Thanks
    58
    My Mood
    Hot
    Quote Originally Posted by MikeRohsoft View Post
    it's possible, but can i ask if it's forced to be more textfiles?
    i would write everything in 1 File
    Code:
    <?php
    	$line = "Is this a Question?|Yes#No#Maybe|Yes"
    	$elemets = explode('|', $line, -1);
    	$object = (object) [
    		'question' => $elements[0],
    		'answers' => explode('#', $elements[1], -1),
    		'correct_answer' => $elements[2],
    	];
    	print_r($object->question);
    	print_r($object->answers);
    	print_r($object->correct_answer);
    ?>
    I'm getting undefined offset on
    Code:
     'correct_answer' => $elements[2],
    . I don't understand what you mean by forced to be more text files? Did you mean all the different sections are all placed in the same file?

  5. #4
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    Quote Originally Posted by Vauntage View Post


    I'm getting undefined offset on
    Code:
     'correct_answer' => $elements[2],
    . I don't understand what you mean by forced to be more text files? Did you mean all the different sections are all placed in the same file?
    ye i mean that. i could not see why it's undefined btw, maybe you just add an | at the end and a # at the end.
    I'm not really a php programmer but you can just add all information of 1 Question in 1 Line and fill all question in one file.
    You can add fields for category aswell and so on, just by having a propper split- mechanic.

  6. The Following User Says Thank You to MikeRohsoft For This Useful Post:

    Vauntage (02-13-2019)

  7. #5
    Silent's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    5,070
    Reputation
    2172
    Thanks
    8,474
    My Mood
    Bitchy
    Quote Originally Posted by Vauntage View Post


    I'm getting undefined offset on
    Code:
     'correct_answer' => $elements[2],
    . I don't understand what you mean by forced to be more text files? Did you mean all the different sections are all placed in the same file?
    remove parameter 3 for the explode function
    Click Here to visit the official MPGH wiki! Keep up with the latest news and information on games and MPGH! To check out pages dedicated to games, see the links below!











    dd/mm/yyyy
    Member - 31/01/2015
    Premium - 12/09/2016
    Call of Duty minion - 05/11/2016 - 05/11/2019
    BattleOn minion - 28/02/2017 - 05/11/2019
    Battlefield minion - 30/05/2017 - 05/11/2019
    Other Semi-Popular First Person Shooter Hacks minion - 21/09/2017 - 17/09/2019
    Publicist - 07/11/2017 - 02/08/2018
    Cock Sucker - 01/12/2017 - Unknown
    Minion+ - 06/03/2018 - 05/11/2019
    Fortnite minion - 08/05/2018 - 05/11/2019
    Head Publicist - 08/10/2018 - 10/01/2020
    Developer Team - 26/10/2019 - 10/01/2020
    Former Staff - 10/01/2020



  8. The Following User Says Thank You to Silent For This Useful Post:

    Vauntage (02-13-2019)

  9. #6
    96neko's Avatar
    Join Date
    Nov 2015
    Gender
    male
    Location
    00:25:B5:AA:01:1F
    Posts
    768
    Reputation
    10
    Thanks
    142
    My Mood
    Angelic
    Quote Originally Posted by Vauntage View Post
    So, I'm supposed to create a dynamic website, where user can choose quiz questions from 3 sections [geography,history,literature]. After the user finishes a quiz attempt, I will have to do a point calculation. Then the user can be offered to attempt a quiz from another section, do the same section but different questions or exit.

    Where I'm stuck at, is this part. For every section should be at least 20 questions of which 10, by random choice, should be displayed to a user in every quiz attempt.

    My professor stated that the questions should be stored in a txt file, and the quiz has to be multiple choice.

    I have a txt file that has questions and is separated by PHP_EOL, and another txt file that has the options for the questions, also separated by PHP_EOL.

    How would I do it such that when I do randomize the question, the options follow the specific question? I was thinking of something along the lines of a pointer, but I don't think that will be possible.

    Any and all advice/help will be greatly appreciated.
    i'd go with naming each question with the section name and give a number in the end like
    q_geography_0 = "Which of these cities is not in Europe?"..etc just in 1 txt file
    then just read all of it and get the questions based on the section you need in ur loop and the number in the end of question name will be your trick for randomize the questions for each section , you simply do random number between two nums and then just loop through it and display the questions
    it may be hard talking about it but its the easy way to do it



Similar Threads

  1. [18+] I really have no Idea how to troll people.
    By Euphemistic in forum General
    Replies: 61
    Last Post: 07-22-2013, 06:14 AM
  2. No idea how to start the server.
    By BlazeADM in forum Realm of the Mad God Help & Requests
    Replies: 5
    Last Post: 06-12-2013, 02:32 PM
  3. [Info] who have an idea how to stuck salazar ?
    By mizi1997 in forum Mission Against Terror Hacks & Cheats
    Replies: 17
    Last Post: 12-04-2012, 07:21 PM
  4. I have no idea how to even begin hacking in combat arms
    By fpodd in forum Combat Arms Help
    Replies: 2
    Last Post: 04-03-2012, 09:04 PM
  5. ok help plz i have no idea how to hack i need help!!!
    By tt4life24 in forum WarRock - International Hacks
    Replies: 1
    Last Post: 07-07-2009, 12:36 AM