SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Kampala Uganda
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Help Me On This Please!

    Guess you know or hard of Cisco online examinations!

    In my project am to implement some thing of that kind! i have done most and one part still failing where i need you help!

    With lots of questions in a database each with a subject, 4 different objective answers,with the right Ans and a year of the question it was examined in an examination board. when some body selects the subject and year to do, then the respective questions are displayed using the while loop with for the sql statement
    PHP Code:
    $sql mysql_query("select * from questions where Subject = '$subject' and Year = '$year'"
    Well i can have all the questions displayed with there objective ans choices but after one submits the paper how should i start marking the questions to determine the right and wrongs meaning i can identify each question!

    Please Help me thanks
    And we know that all things work together for good
    To them that love God, to them who are the called
    According to his purpose. Romans 8:28

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly, you have a subject on the test, under the subject you have several questions, under each question you have 4 different possible answers, and your question is, "How can I tell with the PHP script and mySQL which answer is the RIGHT one."

    Do I understand you correctly?
    John

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Kampala Uganda
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right you do!
    And we know that all things work together for good
    To them that love God, to them who are the called
    According to his purpose. Romans 8:28

  4. #4
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright... Here is what I would do.
    One table for each; the subject, the questions, the answers:
    PHP Code:
    CREATE TABLE tblSubject (
    fldSubjectId SMALLINT(5AUTO_INCREMENT UNSIGNED ZEROFILL,
    fldSubject VARCHAR(the maximum length you think you will need),
    PRIMARY KEY (fldSubjectId));
     
    CREATE TABLE tblQuestions (
    fldQuestionId MEDIUMINT AUTO_INCREMENT UNSIGNED ZEROFILL,
    fldSubjectId SMALLINT(5UNSIGNED ZEROFILL,
    fldQuestion VARCHAR(the maximum length you think you will need),
    fldQuestionYear SMALLINT(4),
    PRIMARY KEY (fldQuestionId));
     
    CREATE TABLE tblAnswers (
    fldAnswerId MEDIUMINT AUTO_INCREMENT UNSIGNED ZEROFILL,
    fldQuestionId MEDIUMINT UNSIGNED ZEROFILL,
    fldAnswer VARCHAR(the maximum length you think you will need),
    fldCorrect ENUM('N','Y'),
    PRIMARY KEY (fldAnswerId)); 
    Then in the form, use the identification numbers from the records for the values on the test. Then to test for the corrrect answer on a question, you would run a query like this:
    PHP Code:
    SELECT fldCorrect FROM tblAnswer WHERE fldQuestionId = [whatever variable you use to assign the question id to]; 
    HTH
    John

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Kampala Uganda
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks John agreat deal!
    And we know that all things work together for good
    To them that love God, to them who are the called
    According to his purpose. Romans 8:28


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •