Suppose that you are given a collection of JSON documents that represent a database of multiple choice exams taken by students.
Write mongoDB queries to answer the following questions:
Determine the total number of exams.
Determine the number of students that got questionid 34532
Determine the average grade of all students that took exam number 2 of 198:111 in the Fall of 2015.
For each (letter) grade determine the number of students that got that grade
For each question id determine its difficulty (number of times it was answered correctly/ number of times it was used in an exam).
The following json file is only an example to illustrate what the data looks like. The actual data has unique optionid and questionid.
{
name:’Smith’,
id:159008743,
courseId:’198:111’,
semester:’Sp2018’,
examNumber:1,
totalQuestions:10,
totalCorrect:8,
percentage:0.8,
grade:’B’,
date_submitted:’04-25-2018’,
time_submitted:’19:25:24’,
room:’Hill 363’,
computerNumber:5,
ip:’198.253.128.5’,
questions:[
{
number:1,
questionid:34532,
questiontext:’Question 1’,
answers:[
{
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:false,
answered:false
},
{
option:’B’,
optionid:384734,
optiontext:’Option B’,
correct:false,
answered:false
},
{
option:’C’,
optionid:384249,
optiontext:’Option C’,
correct:true,
answered:true
},
{
option:’D’,
optionid:3834223,
optiontext:’Option D’,
correct:false,
answered:false
}]
},
{
number:2,
questionid:34325,
questiontext:’Question 2’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:false,
answered:false
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:false
},{
option:’D’,
2
optionid:384729,
optiontext:’Option D’,
correct:true,
answered:true }]
},{
number:3,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:true,
answered:true
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:false
},{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:false,
answered:false }]
},{
number:4,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
3
optionid:384729,
optiontext:’Option A’,
correct:true,
answered:true
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:false
},{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:false,
answered:false }]
},{
number:5,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:false,
answered:false
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
4
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:false
},{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:true,
answered:true }]
},{
number:6,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:true,
answered:true
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:false
},{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:false,
answered:false }]
},
5
{
number:7,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:false,
answered:true
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:true,
answered:false
},{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:false,
answered:false }]
},{
number:8,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:false,
answered:false
},{
option:’B’,
6
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:false
},{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:true,
answered:true }]
},{
number:9,
questionid:34532,
questiontext:’Question 1’,
answers:[ {
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:false,
answered:false
},{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:true,
answered:true
},{
option:’D’,
7
optionid:384729,
optiontext:’Option D’,
correct:false,
answered:false
}
]
},
{
number:10,
questionid:34532,
questiontext:’Question 1’,
answers:[
{
option:’A’,
optionid:384729,
optiontext:’Option A’,
correct:true,
answered:false
},
{
option:’B’,
optionid:384729,
optiontext:’Option B’,
correct:false,
answered:false
},
{
option:’C’,
optionid:384729,
optiontext:’Option C’,
correct:false,
answered:true
},
{
option:’D’,
optionid:384729,
optiontext:’Option D’,
correct:false,
answered:false
}
]
}
]
}