Using MySQL create a schema name it Assignment10 then create a table named Quiz
ID: 3753649 • Letter: U
Question
Using MySQL create a schema name it Assignment10 then create a table named Quiz as follows:
Create table Quiz( questionId int, question varchar(4000), choicea varchar(1000), choiceb varchar(1000), choicec varchar(1000), choiced varchar(1000), answer varchar(5));
The Quiz table stores multiple-choice questions. Suppose the multiple-choice questions are stored in the attached text file Quiz.text in the following format:
question1
choice a
choice b
choice c
choice d
Answer: cd
question2
choice a
choice b
choice c
choice d
Answer: a
…..
Write a program that reads the data from the file and populate it into the Quiz table. SHOW CODE COMMENTS!
The Questions and Answers for the Quiz:
1. ________ is the physical aspect of the computer that can be seen.
a. Hardware
b. Software
c. Operating system
d. Application program
Answer:a
2. __________ is the brain of a computer.
a. Hardware
b. CPU
c. Memory
d. Disk
Answer:b
3. The speed of CPU is measured in __________.
public class A {
}
a. megabytes
b. gigabytes
c. megahertz
d. gigahertz
Answer:cd
4. Why do computers use zeros and ones?
a. because combinations of zeros and ones can represent any numbers and
characters.
b. because digital devices have two stable states and it is natural to
use one state for 0 and the other for 1.
c. because binary numbers are simplest.
d. because binary numbers are the bases upon which all other number
systems are built.
Answer:b
5. One byte has ________ bits.
a. 4
b. 8
c. 12
d. 16
Answer:b
6. A 3.5-inch floppy can hold up to _________ bytes.
a. 0.5 MB.
b. 1.44 MB.
c. 10 MB.
d. 100 MB.
Answer:b
7. A regular CD-ROM can hold up to _________ bytes.
a. 100 MB.
b. 700 MB.
c. 1 GB.
d. 10 GB.
Answer:b
8. ____________ is a device to connect a computer to a local area network
(LAN).
a. regular modem
b. DSL
c. Cable modem
d. NIC
Answer:d
9. ____________ are instructions to the computer.
a. Hardware
b. Software
c. Programs
d. Keyboards
Answer:bc
Explanation / Answer
Before writing the code for we add the some folder to our application we write code in PHP
Database
Controller
Libraries
Model
View
Index.html
Database Table Quiz
create table Quiz
(
Question_id int ,
Question varchar(4000),
choicea varchar(1000),
choiceb varchar(1000),
choicec varchar(1000),
choiced varchar(1000),
answer varchar(5)
);
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('quiz_game');
}
}
class Questions extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->database();
}
public function quizdisplay()
{
$this->load->model('quizmodel');
$this->data['questions'] = $this->quizmodel->getQuestions();
$this->load->view('play_quiz', $this->data);
}
public function resultdisplay()
{
$this->data['checks'] = array(
'ques1' => $this->input->post('quizid1'),
'ques2' => $this->input->post('quizid2'),
'ques3' => $this->input->post('quizid3'),
'ques4' => $this->input->post('quizid4'),
'ques5' => $this->input->post('quizid5'),
'ques6' => $this->input->post('quizid6'),
'ques7' => $this->input->post('quizid7'),
'ques8' => $this->input->post('quizid8'),
'ques9' => $this->input->post('quizid9'),
'ques10' => $this->input->post('quizid10'),
);
$this->load->model('quizmodel');
$this->data['results'] = $this->quizmodel->getQuestions();
$this->load->view('result_display', $this->data);
}
}
class quizmodel extends CI_Model {
public function getQuestions()
{
$this->db->select("quizID, question, choicea, choiceb, choicec, choiced, answer");
$this->db->from("Quiz");
$query = $this->db->get();
return $query->result();
$num_data_returned = $query->num_rows;
if ($num_data_returned < 1) {
echo "There is no data in the database";
exit();
}
}
}
class Welcome extends CI_Controller
{
public function index()
{
$this->load->view('quiz_game');
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.