Report Group 4 C++
Report Group 4 C++
1. Overview:
The main objective of the C + + Project on Quiz System is to manage the details of
Students, Results, Marks manages all the information about Students, Papers, Marks,
Students. The project is totally built at administrative end and thus only the
administrator guaranteed the access. The purpose of the project is to build an
application program to reduce the manual work for managing the Students, Papers.
2. Description:
The Quiz System consists of 6 mini projects which are solved by the solution given
below. Quizzes consisting of multiple-choice questions, are a common way to assess
the performance of students in a class. This simple electronic quiz system is to make
quiz taking easier and the scoring faster.
Mini project 1: Build user account database stored in the “student.txt” which input
from GUI or console interface and login function. The function of this program is to
distinguish between student and lecturer.
Mini project 2: List all questions and add new question into the list.
Mini project 3: List all questions and modify an existing question.
Mini project 4: Search for a question from test bank using a phrase and remove it from
the database.
Mini project 5: List all questions in the database and add them into new a new quiz.
Mini project 6: Students answer a quiz. The results are stored in solutions.txt file.
3. Function:
Functionalities provided by C + + Project on Quiz System are as follows:
• Provides the searching facilities based on various factors.
• Tracks all the information of Papers, Results ect
• Manage the information of Lecturers
• Shows the information and description of the Students to increase efficiency of
managing the Students.
• It deals with monitoring the information and transactions of Results.
• Manage the information of Students
• Editing, adding and updating of Records is improved which results in proper
resource management of Students data.
• Integration of all records of Marks.
4. Application:
The project will do a big help for students and lecturers. Students can answer the
quizzes and submit them by their very names, while lecturers can list, add new, modify,
search for, remove questions or add into a new quiz.
II. Flowchart
struct student{
int accountID;
string name, password, role;
bool isSubmitted = 0;
};
struct question{
int questionsID;
string desc;
int correct;
};
struct quiz{
int quizID;
vector<int> questionID;
int dayDeadline, monthDeadline, yearDeadline;
};
2. QuizSystem.cpp
a. Code:
#include "QuizSystem.h"
while(!fi.eof ()){
getline (fi, tmp, ' ');
getline (fi, tmp);
stuTemp.accountID = stoi (tmp);
arrStu.push_back (stuTemp);
}
fi.close ();
}
do{
cout << "Password: ";
cin >> pass;
if(arr[k].password == pass)
return arr[k];
else{
cout << "Wrong password!!!\n";
}
} while(1);
}
do{
getline (fi, tmp);
desc = desc + tmp + "\n";
i++;
} while(i <= 4);
ques.desc = desc;
arrQues.push_back (quesTMP);
fi >> chr;
while(!fi.eof () && chr == '\n'){
getline (fi, tmp);
}
}
}
return ques;
}
ifstream fi (inFile);
question tmpQues = readOneQuestionFromFile (fi);
int i = 0;
for(i; i < arrQues.size (); i++)
if(arrQues[i].questionsID == id) break;
arrQues[i].desc = tmpQues.desc;
arrQues[i].correct = tmpQues.correct;
writeAllQuesToFile (outFile, arrQues);
cout << " Modify question successfully\n";
fi.close ();
}
arrQuiz.push_back (tmpQuiz);
fi >> chr;
while(!fi.eof () && chr == '\n'){
getline (fi, tmp);
}
}
fi.close ();
}
quiz temp;
temp.dayDeadline = day;
temp.monthDeadline = month;
temp.yearDeadline = year;
arrQuiz.resize (0);
srand (time (NULL));
temp.quizID = arrStudent[i].accountID;
}
arrQuiz.push_back (temp);
cout << "\n\n";
void test (vector<quiz> arrQuiz, vector<question> arrQues, student & stu, ofstream & fo){
quiz QUIZ;
bool check = 0;
for(int i = 0; i < arrQuiz.size (); i++)
if(arrQuiz[i].quizID == stu.accountID){
QUIZ = arrQuiz[i];
check = 1;
break;
}
if(!check){
cout << "No quiz for this student\n";
return;
}
if(stu.isSubmitted){
cout << "Did the quiz!\n";
return;
}
time_t now;
struct tm deadline;
time (&now); /* get current time; same as: now = time(NULL) */
vector<string> ans;
ans.resize (5);
if(seconds <= 0){
cout << "Late deadline\n";
return;
} else{
for(int i = 0; i < QUIZ.questionID.size (); i++){
for(int k = 0; k < arrQues.size (); k++)
if(arrQues[k].questionsID == QUIZ.questionID[i]){
cout << arrQues[k].desc;
break;
}
cout << "Correct: ";
cin >> ans[i];
}
stu.isSubmitted = 1;
}
3. Main.cpp
a. Code:
#include"QuizSystem.h"
using namespace std;
int mode;
student account;
system ("CLS");
do{
cout << "1.Login\n2.Create account\n";
cout << "Enter the function: ";
cin >> mode;
if(mode == 1){
account = login (arrStudent);
if(upcase (account.role) == "STUDENT"){
do{
system ("CLS");
cout << "Login successfully\n Enter 1 to answer the quiz: ";
cin >> mode;
if(mode == 1){
test (arrQuiz, arrQuestion, account, fileSolution);
break;
}
} while(1);
} else if(upcase (account.role) == "LECTURER"){
do{
system ("CLS");
cout << "\n1.Show all questions\n";
cout << "2.Add new question from file\n";
cout << "3.Add new question from console\n";
cout << "4.Modify question from file\n";
cout << "5.Modify question from console\n";
cout << "6.Search question\n";
cout << "7.Delete question\n";
cout << "8.Create quiz\n";
cout << "Enter the function: ";
cin >> mode;
cout << endl;
string inFile;
switch(mode){
case 1:
showAllQuestions (arrQuestion);
break;
case 2:
cout << "Enter file input: ";
cin.ignore (32767, '\n');
cin >> inFile;
addQuestionFromFile (inFile, arrQuestion, questionList);
break;
case 3:
addQuestionsFromConsole (arrQuestion, questionList);
break;
case 4:
modifyQuestionsFromFile (arrQuestion, questionList);
break;
case 5:
modifyQuestionsFromConsole (arrQuestion, questionList);
break;
case 6:
searchQuestions (arrQuestion, questionList);
break;
case 7:
cout << "Enter QuestionID: ";
int id;
cin >> id;
deleteQuestion (arrQuestion, id, questionList);
break;
case 8:
createQuiz (arrQuestion, arrQuiz, arrStudent, quizList);
break;
default:
break;
}
cout << "1.Continue to execute the function\n0.Logout\n";
cout << "Enter the function: ";
cin >> mode;
if(mode == 1) continue;
else break;
} while(true);
}
} else if(mode == 2){
account = createAcc (fileStudent, arrStudent);
break;
}
system ("CLS");
cout << "1.Login\\Create account\n0.Exit\n";
cout << "Enter the function: ";
cin >> mode;
if(mode != 1) break;
} while(true);
fileStudent.close ();
fileSolution.close ();
return 0;
}
b. Components:
• Declare variables (line 4-10)
• Open all the file (line 14-23)
• Check account which is a student or lecturer (line 25-44)
• Table of cases of lecturer (line 45-93)
• Choose the next step (continue or logout) (line 94-101)
• Create the account (line 102-105)
• Choose the next step (continue or exit) (line 106-111)
• Close the file (line 113-115)
IV. Result:
V. References
https://www.freeprojectz.com/c-projects-projects/c-project-multiple-choice-quiz-system
http://cppprojectcode.blogspot.com/2010/09/quiz-test.html