Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/4.N.10_Parser.php~
blob: 4d7c6baa69c8e100e1819539b57536233a8a3d94 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
//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]++;

			//determine total number of submissions of a student
			$num_submissions[$student_id]++; //$num_incorrect[] = (num_submissions[] - num_correct[])
		 			 	
		 	//*****************************Case: Correct Submission ******************************
		 	//How many correct submissions are there - important for determining percentages for yes/no 
		 	if ($submitted_sum == $correct_sum)
		 	{
		 		$num_correct[$student_id]++;
				//$question_num_correct[$question_id]++; will only ever be one

							 		
		 		
		 		//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 

						//determine subtraction
						if ($previous_response[$question_id] == "o") // if you previously overpaid
						{
							$correct_subtraction[$student_id]++;							
						}


		 				
		 			} 


		 	}
		 	
		 	//*****************************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")
						{
							$strikes[$student_id]++;
						}	 				
		 			} 


			$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")
						{
							$strikes[$student_id]++;
						}
						elseif($previous_response[$question_id] == "o")
						{
						}
						
	
		 			} 

			$previous_response[$question_id] = "u"
		 	}
		}//end while()

//*******************************************************Output****************************************************
// addition can be determined if a student gets > 70% of the questions correct on their first attempt.
// subtraction can be determined if for > 70% of the questions the student initially over-paid, they immediately follow up with a correct payment. 

// If a student overpays and then increases their payment, or underpays, followed by an even lower payment it can be inferred the student does not
// understand the concepts of /ddition or subtraction with money.

//    * If for > 10% of the questions the student makes this mistake. He or she gets a "no" for addition and subtraction. 




//****************** Addition Yes / No ***************
foreach ($Class as $student)
{
	if( $num_correct[$student] >= ( .7 * ($num_submissions))
	{
		$understands_addition = "yes"
	}
	else
	{
		$understands_addition = "no"
	}
		
	
} //end foreach
			
						
	
}	

fclose($fp); //close 4.n.10.dat

?>