Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/4.N.10_Parser.php
blob: fb8d42aa78ebe81504a0f34e7af71826e54ecf77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//5.N.10 Parser
//http://git.sugarlabs.org/projects/teacher-reporting
//
//Description:
/*

Select and use appropriate operations (addition, subtraction, multiplication, and division) to solve problems, including those involving money.

*/

<?php

$fp = fopen("./4.N.10.dat", "r");
if(!$fp) die ("Cannot open the file");

//Break Each line of the file into its own array element - will have to parse each array element to obtain fields
$lines = file($fp);


$numWords = str_word_count($fp); 
//Will always be a multiple of four so $NumRecords will be $numWords/4
$numRecords = $numWords / 5;
//Our Associative array Will also be in sequence 1,5,9,13.. + 4 etc 
//Need to tokenize each line and choose appropriate elements ($1)  
//This is just to fill the array with Variables. Next we will go through the same process for the remaining fields
// Perform the logic on them add them to additional associate arrays with various meanings
// For Example 

for (i=0;i<=$numRecords;i++)
{


	$tok = strtok($lines, " ");

			/*
			Because in the end statement we will have to loop through one of the arrays, which will be localized according
			#to specific aritmetic operations (- + / *). We need to account for the fact that some students may not answer a
			#question with one of these operations, and if we looped through that particular operation, we would not represent
			#that student in any of the logic containted within that loop in the END{} statment. Therefore an associative array
			#which absolutely, accounts for any student, contained in the .dat, the CLASS[] array.
			$Class[tok[0]];
			*/
	
	while ($tok !== false)
	 {
		$Class[tok[0]];
	 }
 
}

//in this loop we will cycle through each line of the .dat file and determine at each instance of 
for (i=0;i<=$numRecords;i++)
{
	$tok = strtok($lines, " ");
	
	while ($tok !== false)
	 {		 
			$student_id	= $tok[0];
			$question_id = $tok[1];	
			$correct_sum = $tok[2];	
		 	$submitted_sum = $tok[3];
		 	$correct = $tok[4];
		 	
		 	//Need to associate question_id with student
		 	$whose_question[$question_id] = $student_id;
		 			 	
		 	
		 	//How many correct submissions are there 
		 	if ($submitted_sum == $correct_sum)
		 	{
		 		$num_correct[$student_id]++;
		 	}
		 					
	}
}	

?>