Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is to be done in c++ Complete Program below using the guide above. #include #include #include #include #include #include using namespace std; #define NUM_CHOICES

This is to be done in c++

image text in transcribed

Complete Program below using the guide above.

#include #include #include #include #include #include

using namespace std;

#define NUM_CHOICES 4

struct Responses { string text[4]; string answer; bool shuffle; };

struct Question { string ID; string text; Responses responses; int points; };

struct Summary { string questionID; bool correct; bool skipped; string answer; string givenAnswer; int points; };

// This function reads all the questions from questions.txt into // the Question Bank. It returns the amount of questions in the // Question Bank.

int readQuestions (Question questionBank[]) {

return 0; }

// This function displays the contents of a question. It can // be used for debugging purposes to ensure that the data is // being read correctly from the file.

void displayQuestion (Question question) {

}

// This function returns true if the test already contains // the question with the given questionID and false, otherwise.

bool containsQuestion (Question test[], int numTestQuestions, string questionID) { return false; }

// This function returns true if the set of responses already // contains the given response, and false otherwise.

bool containsResponse (Responses responses, int numResponses, string response) { return false; }

// This function accepts the question passed as a parameter, // shuffles the responses if the responses should be shuffled, // and returns the modified question.

Question shuffleResponses (Question question) { return question; }

// This function creates the Test containing numTestQuestions, // where the questions are taken randomly from the Question Bank, // which contains numQuestions.Duplicate questions are not // allowed in the Test.

void prepareTest (Question questionBank[], int numQuestions, Question Test[], int numTestQuestions) {

}

// This function displays a question for the user to answer // while the test is in progress.

void displayTestQuestion (Question question) {

}

// After the test is prepared, this function presents the // questions on the test to the user, one by one. It also // records how the user responded to each question, for // the summary at the end.

void generateExam (Question exam[], int numExamQuestions, Summary summary[]) {

}

// This function displays a summary of the user's performance on // each question of the test, after the test is completed.

void displaySummary (Summary summary[], int numExamQuestions) {

}

// The main function calls readQuestions, prepareTest, // generateTest, and displaySummary to achieve the functionality // of Assignment 1.

int main () {

// Declarations for questionBank, test, and summary Question questionBank[100]; int numQuestions; Question test [50]; int numExamQuestions; Summary summary [50]; return 0; }

This assignment requires you to write a program to generate a multiple-choice exam. The file, questions.txt, contains a set of multiple-choice questions. Each question has exactly four responses. The following shows the layout of each item of data that is stored for a question: Data Item ID Text Responses Description Question ID (a string without spaces on a line by itself) The actual question on a line by itself (a string that could contain spaces) Four responses, each on a line by itself, followed by the correct response on a line by itself, followed by 1 or 0 where 1 indicates that the responses should be shuffled and O indicates otherwise. The amount of points gained if the question is correctly answered. Points For example, here is the data for one of the questions in questions.txt Data Popeye Which of the following gives Popeye his strength? Broccoli Spinach Fried chicken All of them. Spinach 1 1 Description ID of question Question text Choice 1 Choice 2 Choice 3 Choice 4 Correct answer 1: shuffle responses; O: don't shuffle If correctly answered, 1 mark is awarded Program Requirements Your program must provide the following functionality: (a) Read all the questions from the file, questions.txt, and store them in an array. This array is referred to as the Question Bank. The file contains no more than 100 questions. (b) Create an array of exam questions by randomly selecting M questions (specified by the user) from the Question Bank. The array of exam questions is referred to as the Exam. When a question is selected from the Question Bank, the four responses must be shuffled, if necessary. (c) Allow a user to take the exam by presenting the questions from the exam, one by one. Three actions are possible when a question is displayed to the user: (1) the user answers the question correctly (ii) the user answers the question incorrectly the user skips the question A record must be kept of the user's performance on each question. (d) At the end of the examination, a summary of the user's performance is given. The summary displays how many responses were correct or incorrect and how many questions were skipped. The total marks obtained by the user is also displayed. 1 This assignment requires you to write a program to generate a multiple-choice exam. The file, questions.txt, contains a set of multiple-choice questions. Each question has exactly four responses. The following shows the layout of each item of data that is stored for a question: Data Item ID Text Responses Description Question ID (a string without spaces on a line by itself) The actual question on a line by itself (a string that could contain spaces) Four responses, each on a line by itself, followed by the correct response on a line by itself, followed by 1 or 0 where 1 indicates that the responses should be shuffled and O indicates otherwise. The amount of points gained if the question is correctly answered. Points For example, here is the data for one of the questions in questions.txt Data Popeye Which of the following gives Popeye his strength? Broccoli Spinach Fried chicken All of them. Spinach 1 1 Description ID of question Question text Choice 1 Choice 2 Choice 3 Choice 4 Correct answer 1: shuffle responses; O: don't shuffle If correctly answered, 1 mark is awarded Program Requirements Your program must provide the following functionality: (a) Read all the questions from the file, questions.txt, and store them in an array. This array is referred to as the Question Bank. The file contains no more than 100 questions. (b) Create an array of exam questions by randomly selecting M questions (specified by the user) from the Question Bank. The array of exam questions is referred to as the Exam. When a question is selected from the Question Bank, the four responses must be shuffled, if necessary. (c) Allow a user to take the exam by presenting the questions from the exam, one by one. Three actions are possible when a question is displayed to the user: (1) the user answers the question correctly (ii) the user answers the question incorrectly the user skips the question A record must be kept of the user's performance on each question. (d) At the end of the examination, a summary of the user's performance is given. The summary displays how many responses were correct or incorrect and how many questions were skipped. The total marks obtained by the user is also displayed. 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions