[Aimmath-commit] moodle/mod/math_assignment lib.php,1.28,1.29
Brought to you by:
gustav_delius,
npstrick
|
From: <gus...@us...> - 2003-09-29 21:46:43
|
Update of /cvsroot/aimmath/moodle/mod/math_assignment
In directory sc8-pr-cvs1:/tmp/cvs-serv9349/mod/math_assignment
Modified Files:
lib.php
Log Message:
no longer uses PREG_OFFSET_CAPTURE
Index: lib.php
===================================================================
RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/lib.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** lib.php 28 Sep 2003 15:23:07 -0000 1.28
--- lib.php 28 Sep 2003 16:23:29 -0000 1.29
***************
*** 597,600 ****
--- 597,601 ----
$error = false;
+ /*
// remove everything up to and including the html tag
if (!preg_match("/<html(?:\s[^<>]*?|)>/i", $data, $matches, PREG_OFFSET_CAPTURE))
***************
*** 602,605 ****
--- 603,608 ----
$data = substr($data, $matches[0][1]);
+ $data = preg_replace("/^[\s\S]*<html(?:\s[^<>]*?|)>/i", "", $data);
+
// seach for a head tag
if (preg_match("/<head(?:\s[^<>]*?|)>/i", $data, $matches, PREG_OFFSET_CAPTURE)) {
***************
*** 642,646 ****
$out .= $data; // add body to output (NOTE that this means we can modify $data now)
!
if (!$error) {
// extract grades (if present)
--- 645,649 ----
$out .= $data; // add body to output (NOTE that this means we can modify $data now)
!
if (!$error) {
// extract grades (if present)
***************
*** 657,660 ****
--- 660,683 ----
}
}
+ }
+ }
+ */
+
+ // extract scripts and add to $out
+ preg_match_all("/<script[\s\S]*?<\/script>/", $data, $scripts);
+ $out = "\n\n<!-- Start AiM scripts -->\n" . implode("\n",$scripts[0]);
+ // extract body and add to $out
+ preg_match("/<body(?:\s[^<>]*?|)>([\s\S]*)?<\/body>/i", $data, $body);
+ $out .= "\n<!-- End AiM scripts and start AiM body-->\n\n $body[1] \n\n<!-- End AiM body-->\n\n";
+
+ // extract grades (if present)
+ if (preg_match("/class=\"marktable\"([\s\S]*)?<\/table>/i", $data, $matches)) {
+ $data = $matches[1];
+ // find the row which gives the totals
+ if (preg_match("/<td(?:\s[^<>]*?|)>Total<\/td>(?:.(?!<td\s|<td>))*.?<td(?:\s[^<>]*?|)>((?:.(?!<\/td>))*?.?)<\/td>(?:.(?!<td\s|<td>))*.?<td(?:\s[^<>]*?|)>((?:.(?!<\/td>))*?.?)<\/td>/si", $data, $matches)) {
+ if (empty($CFG->math_assignment_grade_multiplier))
+ $CFG->math_assignment_grade_multiplier = 1.0;
+ $max_grade = (int) (((float) html_entity_decode($matches[1])) * ((float) $CFG->math_assignment_grade_multiplier));
+ $grade = (int) (((float) html_entity_decode($matches[2])) * ((float) $CFG->math_assignment_grade_multiplier));
}
}
|