Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWWDillingham WesleyDillingham <wwdillingham@sugarlabs.org>2009-06-30 18:15:10 (GMT)
committer WWDillingham WesleyDillingham <wwdillingham@sugarlabs.org>2009-06-30 18:15:10 (GMT)
commit39e226003c8abeee3ba2df8226491596ea38c20a (patch)
treeec709feb71b40f37d188064abfd324ca048e8425
parentdb0545fab3c8d040c9764032b4c26bcc04cb2cd9 (diff)
accounting for equations with only subtraction
-rw-r--r--order_of_operations_parser.php47
1 files changed, 30 insertions, 17 deletions
diff --git a/order_of_operations_parser.php b/order_of_operations_parser.php
index d025d8f..8bd5586 100644
--- a/order_of_operations_parser.php
+++ b/order_of_operations_parser.php
@@ -69,6 +69,11 @@ for (i=0;i<=$numRecords;i++)
$equation = $tok[2];
+
+// ` ********************************ADDITION*************************
+
+
+
$regexp = "+";
if (preg_match($regexp, $equation)) //if ($tok[2] contains TODO check for correctness
{
@@ -83,28 +88,20 @@ for (i=0;i<=$numRecords;i++)
//Now we need to determine if a particular question contained ONLY a particular operation
-
//Matches operations with ONLY ADDITION
if (preg_match($regexp, $equation) && !preg_match("-", $equation), && !preg_match("/", $equation), && !preg_match("*", $equation))
{
- only_addition[tok[2]]++
+ $only_addition[tok[2]]++
+
+ if ($tok[3] = "1") //is it also correct? put it in a different associative array with the same key
+ {
+ $only_addition_correct[tok[0]]++;
+ }
}
-
-
- /*# 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]++
- }
-*/
-
-
+ //******************************************SUBTRACTION********************************
+
+
//TODO: account for negative numbers
$regexp = "-"; //operation remains the same, as we are checking it four times for each operation
if (preg_match($regexp, $equation))
@@ -117,6 +114,22 @@ for (i=0;i<=$numRecords;i++)
}
}
+ //Matches operations with ONLY ADDITION
+ if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("/", $equation), && !preg_match("*", $equation))
+ {
+ $only_subtraction[tok[2]]++
+
+ if ($tok[3] = "1") //is it also correct? put it in a different associative array with the same key
+ {
+ $only_subtraction_correct[tok[0]]++;
+ }
+ }
+
+
+
+
+
+
$regexp = "/"
if (preg_match($regexp, $equation))
{