I am getting 40 key & value data when the user submits the from. Like below.
$student_answer = [
1 => "rehabilitation of offenders",
2 => "has been accelerating",
3 => "all expectations",
4 => "question the validity",
5 => "than alleviate",
6 => "more effective alternatives",
7 => "social and economic",
8 => "dcfgvhjk",
9 => "vghbjnk",
10 => "hbjnk",
11 => "gvhbjn",
12 => "vbhnm",
13 => "fghj",
14 => "fghj",
15 => "vghbj",
16 => "cgvhb",
17 => "vbhn",
18 => "vbn",
19 => "fghj",
20 => "gvhbj",
21 => "cvbn",
22 => "vbn",
23 => "v bn",
24 => "cfghjk",
"25-26" => [
0 => "D",
1 => "E",
],
27 => "fgvhbj",
28 => "vbnm",
29 => "v bnm",
30 => "v bnm",
31 => "n hb",
32 => "hbjnkm",
33 => "bnm",
34 => "bnm",
35 => "b nm",
36 => "b nm",
37 => "v bn",
38 => "vbnm",
"39-40" => [
0 => "A",
1 => "D",
],
];
And I have right answer coming from database like below:
$answer_from_database = [
1 => [
0 => "rehabilitation of offenders"
],
2 => [
0 => "has been accelerating"
],
3 => [
0 => "all expectations"
],
4 => [
0 => "question the validity"
],
5 => [
0 => "than alleviate"
],
6 => [
0 => "more effective alternatives"
],
7 => [
0 => "social and economic"
],
8 => [
0 => "NOT GIVEN"
],
9 => [
0 => "FALSE"
],
10 => [
0 => "TRUE"
],
11 => [
0 => "TRUE"
],
12 => [
0 => "FALSE"
],
13 => [
0 => "FALSE"
],
14 => [
0 => "moral or philosophical"
],
15 => [
0 => "physiological/biological disposition"
],
16 => [
0 => "heritable/inherited"
],
17 => [
0 => "characterised by"
],
18 => [
0 => "hereditary aspect/biological basis"
],
19 => [
0 => "associated with"
],
20 => [
0 => "criminal tendencies"
],
21 => [
0 => "Chromosomal abnormality"
],
22 => [
0 => "masculine and aggressive"
],
23 => [
0 => "severely undermined by"
],
24 => [
0 => "environmental and social"
],
"25-26 " => [
0 => "D",
1 => "E",
],
27 => [
0 => "means"
],
28 => [
0 => "for identification purposes"
],
29 => [
0 => "victims"
],
30 => [
0 => "centred on"
],
31 => [
0 => "removed"
],
32 => [
0 => "law enforcement agencies"
],
33 => [
0 => "evade capture"
],
34 => [
0 => "crime scene"
],
35 => [
0 => "the publication of"
],
36 => [
0 => "modern forensic techniques/forensic science"
],
37 => [
0 => "fingerprint-ing/new-found"
],
38 => [
0 => "standard practice"
],
"39-40" => [
0 => "A",
1 => "D",
]
];
Now I want to check whether the student's answer match the answer coming from the database, and if the answer is correct, I want to increase the value of $count
,
So far I have done this:
//$data = student's answer
//$answerKey = right answer
foreach($data as $key => $student){
$count = 0;
foreach($answerKey as $rkey => $right){
if($student == implode (", ", $right)){
$count = $count + 1;
}
if(is_array($student)){
}
}
}
I got stuck here, what should I do next to check answer?