Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/order_of_operations_parser.awk
blob: 44ea8f88463537a18d00bc640a12d71970310832 (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#Wesley Dillingham
#Filename parser.awk
#Last updated May 17th 2009

BEGIN{
	printf("%-11s%-8s%-11s%-8s%-11s%-8s%-11s%-8s%-11s%-11s\n", "Student", "Only +", "Contains +", "Only -", "Contains -", "Only
*", "Contains *", "Only /", "Contains /", "Understands OoO?") 
}

{
 #*****Field Reference *************

	#MAC=$1
	#NAME=$2
	#OPERATION=$3
	#SUCCESS=$4

#************************************

#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[$2]
  
	#any line that has division, but not necessarily just.  
	if ( match($3, /\//) ) 
	{
		#How many division problem student $2 encounters = divison[$2]
		division[$2]++ 
		
		if ( $4 == "1" )
		{
			division_correct[$2]++
		} 
	}
	
	#any line with multiplication but not  neccearily just multiplication
	if ( match($3, /\*/) ) 
	{
		#How many multiplication problem student $2 encounters = multiplication[$2]
		multiplication[$2]++ 
		
		if ( $4 == "1" )
		{
			multiplication_correct[$2]++
		} 

	}
	
	#any line with addition but not necessarily just addition
	if ( match($3, /\+/) )
	{
		#How many addition problem student $2 encounters = addition[$2]
		addition[$2]++ 
		
		if ( $4 == "1" )
		{
			addition_correct[$2]++
		} 
	}
	
	#contains subtractions, excludes negative numbers, as it only matches expressions with a "-" sandwiched b/w two digits
	if ( match($3, /[0-9]\-[0-9]/) )  
	{				
		#How many subtraction problem student $2 encounters = subtraction[$2]
		subtraction[$2]++ 
		
		if ( $4 == "1" )
		{
			subtraction_correct[$2]++
		} 
	}
	


	# Matches operations with ONLY DIVISION
	if ( match($3, /\//) && !match($3, /[0-9]\-[0-9]/) && !match($3, /\+/) && !match($3, /\*/) ) 
	{

		#How many ONLY division problem student $2 encounters = 0_divison[$2]
		o_division[$2]++ 
		
		if ( $4 == "1" )
		{
			o_division_correct[$2]++
		} 

	
	}
	
	# Matches operations with ONLY SUBTRACTION
	if (  !match($3, /\//) && match($3, /[0-9]\-[0-9]/) && !match($3, /\+/) && !match($3, /\*/) )
	{
		#How many ONLY subtraction problem student $2 encounters = o_subtraction[$2]
		o_subtraction[$2]++ 
		
		if ( $4 == "1" )
		{
			o_subtraction_correct[$2]++
		} 
	
	}
	
	# Matches operations with ONLY ADDITION
	if (  !match($3, /\//) && !match($3, /[0-9]\-[0-9]/) && match($3, /\+/) && !match($3, /\*/) )
	{
		#How many ONLY Addition problem student $2 encounters = o_addition[$2]
		o_addition[$2]++ 
		
		if ( $4 == "1" )
		{
			o_addition_correct[$2]++
		} 

	}
	
	# Matches operations with ONLY MULTIPLICATION 
	if (  !match($3, /\//) && !match($3, /[0-9]\-[0-9]/) && !match($3, /\+/) && match($3, /\*/) )
	{
		#How many ONLY MULTIPLICATION problem student $2 encounters = o_multiplication[$2]
		o_multiplication[$2]++ 
		
		if ( $4 == "1" )
		{
			o_multiplication_correct[$2]++
		} 
			
	}

#How many problems an individual student faced: for classwide statistics we simply use the built-in var NR
numproblems[$2]++

#Determine if it is a compound operation if so increment by one, this requires 4 if's as we have to check if each of them exists in
# conjuntion with another.
#Keep track of total compounds and compounds correct. 
#Else-if structure required because if stringed If's were used each compound match would register twice.

if ( match($3, /\//) && ( match($3, /[0-9]\-[0-9]/) || match($3, /\+/) || match($3, /\*/) ) ) 
{
	compound[$2]++
	 
	if ($4 == "1") #if correct
	{
		compound_correct[$2]++
	} 
}
else if (  match($3, /[0-9]\-[0-9]/) && (match($3, /\//) || match($3, /\+/) || match($3, /\*/) ) ) 
{
	compound[$2]++
	
	if ($4 == "1") #if correct
	{
		compound_correct[$2]++
	} 

}
else if ( match($3, /\+/) && ( match($3, /[0-9]\-[0-9]/) || match($3, /\//) || match($3, /\*/) ) ) 
{
		compound[$2]++
	
	if ($4 == "1") #if correct
	{
		compound_correct[$2]++
	} 
}
else if  ( match($3, /\*/) && ( match($3, /\+/) ||  match($3, /[0-9]\-[0-9]/) || match($3, /\//) ) ) 
{
		compound[$2]++
	
	if ($4 == "1") #if correct
	{
		compound_correct[$2]++
	} 
	
}
else # This allows for easy way to harness non compound statements, instead of going through a whole new slew of logic statements. 
{

		non_compound[$2]++
	
	if ($4 == "1") #if correct
	{
		non_compound_correct[$2]++
	} 

}


if ( $4 == "1" )
{totalcorrect[$2]++}
	
}#end of AWK_MAIN
END{
	


	#loops through all of the elements in the array CLASS[]
	#Here We will print out the students	

for (student in CLASS) 
{

# A student doesnt understand order of operations if their is a greater than 20% difference in between compound 
# operations and single operation instructions, but only if lower on the compound instruction side. 
# or if they get less than 70% on compounds, because getting a 51% on compounds and 70% on non compounds doesnt satisfy
# understaning of OoO

if ( ( (non_compound_correct[student] / non_compound[student]) - (compound_correct[student] / compound[student]) > .2 ) || 
( (non_compound_correct[student] / non_compound[student]) ) < .7)
{
	understands= "no"
}
else
{
	understands= "yes"
}


	#need to address divide by 0 issue
	printf("%-11s%-8s%-11s%-8s%-11s%-8s%-11s%-8s%-11s%-11s\n", student,
int(o_addition_correct[student]*100/o_addition[student]), int(addition_correct[student]*100/addition[student]),
int(o_subtraction_correct[student]*100/o_addition[student]), int(subtraction_correct[student]*100/subtraction[student]),
int(o_multiplication_correct[student]*100/o_multiplication[student]),
int(multiplication_correct[student]*100/multiplication[student]), int(o_division_correct[student]*100/o_division[student]),
int(division_correct[student]*100/division[student]), understands)  


	
}

} #end of AWK_END