Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/4.N.10_Parser.php
blob: fa274ec4a9756e6223364e7a2a1bc428e130de54 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//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, " ");
	//this if-statement allows us to determine if a student is on his/her second attempt	
		 		if ($attempts[$question_id] == 1) 
		 			{
		 				
		 			} 
	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;
		 	
			//Need to determine which attempt this is for this particular question
		 	$attempts[$question_id]++;
		 			 	
		 	//*****************************Case: Correct Submission ******************************
		 	//How many correct submissions are there - important for determining percentages for yes/no 
		 	if ($submitted_sum == $correct_sum)
		 	{
		 		$student_num_correct[$student_id]++;
				$question_num_correct[$question_id]++;

							 		
		 		
		 		//this if-statement allows us to determine if a student is on his/her second attempt	
		 		if ($attempts[$question_id] > 1) 
		 			{
		 				//the code is looking here if and only if the parser is analyzing a question which he/she
		 				//initially got wrong but has now gotten correct
		 				//We can assume it was initally wrong because gcompris money cents would not have a second record of a question_id
		 				// if it was correct initially.
		 				//TODO - determine whether wrong means previously overpaid or previously underpaid 
		 				
		 			} 


		 	}
		 	
		 	//*****************************CASE: OVERPAID******************************
		 	//How many times does each student overpay - important for determining subraction understanding
		 	if ($submitted_sum > $correct_sum)
		 	{
		 		$student_num_overpaid[$student_id]++;
				$question_num_overpaid[$question_id]++;

		 		
		 		
		 		//this if-statement allows us to determine if a student is on his/her second attempt	
		 		if ($attempts[$question_id] == 1) 
		 			{
		 				if($previous_response[$question_id] == "u")
						{

						}
						elseif($previous_response[$question_id] == "o")
						{
						}	 				
		 			} 


			$previous_response[$question_id] = "o"

		 	}
		 	
		 	//******************************Case: Underpaid***********************************
		 			 	//how many times the student underpaid 
		 	if($submitted_sum < $correct_sum)
		 	{
		 		$student_num_underpaid[$student_id]++;
				$question_num_underpaid[$question_id]++;
		 		
		 		//this if-statement allows us to determine if a student is on his/her second attempt	
		 		if ($attempts[$question_id] == 1) 
		 			{
						if($previous_response[$question_id] == "u")
						{

						}
						elseif($previous_response[$question_id] == "o")
						{
						}
						
	
		 			} 

			$previous_response[$question_id] = "u"
		 	}
			
						
	}
}	

?>