/i', "\r\n", $element->core_vendor);
$dataid = $DB->insert_record('scorm_scoes_data',$scodata);
}
}
diff --git a/mod/scorm/player.php b/mod/scorm/player.php
index a24d9499e02..b0a6091dbca 100755
--- a/mod/scorm/player.php
+++ b/mod/scorm/player.php
@@ -306,7 +306,7 @@
echo " \n";
} else {
// Clean the name for the window as IE is fussy
- $name = ereg_replace("[^A-Za-z0-9]", "", $scorm->name);
+ $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
if (!$name) {
$name = 'DefaultPlayerWindow';
}
@@ -355,4 +355,4 @@
-
\ No newline at end of file
+
diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php
index ce2a61776dd..950523eef90 100644
--- a/mod/wiki/lib.php
+++ b/mod/wiki/lib.php
@@ -1920,7 +1920,7 @@ function wiki_admin_checklinks($pagetocheck) {
}
/// Remove old Notices
- $content = eregi_replace(' µµ__~\['.get_string("offline","wiki").'\]__µµ ','', $content);
+ $content = preg_replace('/ µµ__~\['.get_string("offline","wiki").'\]__µµ /i','', $content);
#-- replace dead links
foreach ($badlinks as $href) {
diff --git a/pix/smartpix.php b/pix/smartpix.php
index e44628de5ac..bb1c72d4b60 100644
--- a/pix/smartpix.php
+++ b/pix/smartpix.php
@@ -21,10 +21,10 @@ function makesafe($param) {
$param = str_replace('\\\'', '\'', $param);
$param = str_replace('\\"', '"', $param);
$param = str_replace('\\', '/', $param);
- $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':]', '', $param);
- $param = ereg_replace('\.\.+', '', $param);
- $param = ereg_replace('//+', '/', $param);
- return ereg_replace('/(\./)+', '/', $param);
+ $param = preg_replace('/[[:cntrl:]]|[<>"`\|\':]/', '', $param);
+ $param = preg_replace('/\.\.+/', '', $param);
+ $param = preg_replace('~//+~', '/', $param);
+ return preg_replace('~/(\./)+~', '/', $param);
}
// Nicked from weblib
diff --git a/question/format.php b/question/format.php
index 76d12731d23..5108c509e2e 100644
--- a/question/format.php
+++ b/question/format.php
@@ -423,7 +423,7 @@ class qformat_default {
$filearray = file($filename);
/// Check for Macintosh OS line returns (ie file on one line), and fix
- if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
+ if (preg_match("~\r~", $filearray[0]) AND !preg_match("~\n~", $filearray[0])) {
return explode("\r", $filearray[0]);
} else {
return $filearray;
@@ -572,7 +572,7 @@ class qformat_default {
fclose( $fh );
// return the (possibly) new filename
- $newfile = ereg_replace("{$CFG->dataroot}/{$this->course->id}/", '',$newfullpath);
+ $newfile = preg_replace("~{$CFG->dataroot}/{$this->course->id}/~", '',$newfullpath);
return $newfile;
}
diff --git a/question/format/blackboard_six/format.php b/question/format/blackboard_six/format.php
index 6f8ed255fa1..1cf7e36942b 100644
--- a/question/format/blackboard_six/format.php
+++ b/question/format/blackboard_six/format.php
@@ -180,7 +180,7 @@ class qformat_blackboard_six extends qformat_default {
if (is_readable($q_file)) {
$filearray = file($q_file);
/// Check for Macintosh OS line returns (ie file on one line), and fix
- if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
+ if (preg_match("~\r~", $filearray[0]) AND !preg_match("~\n~", $filearray[0])) {
return explode("\r", $filearray[0]);
} else {
return $filearray;
diff --git a/question/format/gift/format.php b/question/format/gift/format.php
index 08a3b857fd0..c246dceee4f 100755
--- a/question/format/gift/format.php
+++ b/question/format/gift/format.php
@@ -119,7 +119,7 @@ class qformat_gift extends qformat_default {
$question = $this->defaultquestion();
$comment = NULL;
// define replaced by simple assignment, stop redefine notices
- $gift_answerweight_regex = "^%\-*([0-9]{1,2})\.?([0-9]*)%";
+ $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/";
// REMOVED COMMENTED LINES and IMPLODE
foreach ($lines as $key => $line) {
@@ -139,7 +139,7 @@ class qformat_gift extends qformat_default {
$text = $this->escapedchar_pre($text);
// Look for category modifier
- if (ereg( '^\$CATEGORY:', $text)) {
+ if (preg_match( '~^\$CATEGORY:~', $text)) {
// $newcategory = $matches[1];
$newcategory = trim(substr( $text, 10 ));
@@ -317,7 +317,7 @@ class qformat_gift extends qformat_default {
$answer_weight = 1;
$answer = substr($answer, 1);
- } elseif (ereg($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
+ } elseif (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
$answer_weight = $this->answerweightparser($answer);
} else { //default, i.e., wrong anwer
@@ -408,7 +408,7 @@ class qformat_gift extends qformat_default {
$answer = trim($answer);
// Answer Weight
- if (ereg($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
+ if (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
$answer_weight = $this->answerweightparser($answer);
} else { //default, i.e., full-credit anwer
$answer_weight = 1;
@@ -456,7 +456,7 @@ class qformat_gift extends qformat_default {
$answer = trim($answer);
// Answer weight
- if (ereg($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
+ if (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
$answer_weight = $this->answerweightparser($answer);
} else { //default, i.e., full-credit anwer
$answer_weight = 1;
diff --git a/question/format/qti_two/format.php b/question/format/qti_two/format.php
index 6542587ac7d..e3fc297ba0f 100644
--- a/question/format/qti_two/format.php
+++ b/question/format/qti_two/format.php
@@ -33,8 +33,8 @@ class qformat_qti_two extends qformat_default {
// Remove all tabs.
$source = str_replace("\t", '', $source);
// Remove all space after ">" and before "<".
- $source = ereg_replace(">( )*", ">", $source);
- $source = ereg_replace("( )*<", "<", $source);
+ $source = preg_replace("/>( )*", ">/", $source);
+ $source = preg_replace("/( )*<", "", $source);
// Iterate through the source.
$level = 0;
diff --git a/question/format/webct/format.php b/question/format/webct/format.php
index f97b488044a..9c64a4c1b36 100644
--- a/question/format/webct/format.php
+++ b/question/format/webct/format.php
@@ -70,21 +70,20 @@ function qformat_webct_convert_formula($formula) {
$formula = str_replace(' ', '', $formula);
// Remove paranthesis after e,E and *10**:
- while (ereg('[0-9.](e|E|\\*10\\*\\*)\\([+-]?[0-9]+\\)', $formula, $regs)) {
+ while (preg_match('~[0-9.](e|E|\\*10\\*\\*)\\([+-]?[0-9]+\\)~', $formula, $regs)) {
$formula = str_replace(
- $regs[0], ereg_replace('[)(]', '', $regs[0]), $formula);
+ $regs[0], preg_replace('/[)(]/', '', $regs[0]), $formula);
}
// Replace *10** with e where possible
- while (ereg(
- '(^[+-]?|[^eE][+-]|[^0-9eE+-])[0-9.]+\\*10\\*\\*[+-]?[0-9]+([^0-9.eE]|$)',
+ while (preg_match('~(^[+-]?|[^eE][+-]|[^0-9eE+-])[0-9.]+\\*10\\*\\*[+-]?[0-9]+([^0-9.eE]|$)~',
$formula, $regs)) {
$formula = str_replace(
$regs[0], str_replace('*10**', 'e', $regs[0]), $formula);
}
// Replace other 10** with 1e where possible
- while (ereg('(^|[^0-9.eE])10\\*\\*[+-]?[0-9]+([^0-9.eE]|$)', $formula, $regs)) {
+ while (preg_match('~(^|[^0-9.eE])10\\*\\*[+-]?[0-9]+([^0-9.eE]|$)~', $formula, $regs)) {
$formula = str_replace(
$regs[0], str_replace('10**', '1e', $regs[0]), $formula);
}
@@ -94,17 +93,17 @@ function qformat_webct_convert_formula($formula) {
while (2 == count($splits = explode('**', $formula, 2))) {
// Find $base
- if (ereg('^(.*[^0-9.eE])?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?|\\{[^}]*\\})$',
+ if (preg_match('~^(.*[^0-9.eE])?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?|\\{[^}]*\\})$~',
$splits[0], $regs)) {
// The simple cases
$base = $regs[2];
$splits[0] = $regs[1];
- } else if (ereg('\\)$', $splits[0])) {
+ } else if (preg_match('~\\)$~', $splits[0])) {
// Find the start of this parenthesis
$deep = 1;
for ($i = 1 ; $deep ; ++$i) {
- if (!ereg('^(.*[^[:alnum:]_])?([[:alnum:]_]*([)(])([^)(]*[)(]){'.$i.'})$',
+ if (!preg_match('~^(.*[^[:alnum:]_])?([[:alnum:]_]*([)(])([^)(]*[)(]){'.$i.'})$~',
$splits[0], $regs)) {
print_error("parenthesisinproperstart", 'question', '', $splits[0]);
}
@@ -124,17 +123,17 @@ function qformat_webct_convert_formula($formula) {
}
// Find $exp (similar to above but a little easier)
- if (ereg('^([+-]?(\\{[^}]\\}|([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?))(.*)',
+ if (preg_match('~^([+-]?(\\{[^}]\\}|([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?))(.*)~',
$splits[1], $regs)) {
// The simple case
$exp = $regs[1];
$splits[1] = $regs[6];
- } else if (ereg('^[+-]?[[:alnum:]_]*\\(', $splits[1])) {
+ } else if (preg_match('~^[+-]?[[:alnum:]_]*\\(~', $splits[1])) {
// Find the end of the parenthesis
$deep = 1;
for ($i = 1 ; $deep ; ++$i) {
- if (!ereg('^([+-]?[[:alnum:]_]*([)(][^)(]*){'.$i.'}([)(]))(.*)',
+ if (!preg_match('~^([+-]?[[:alnum:]_]*([)(][^)(]*){'.$i.'}([)(]))(.*)~',
$splits[1], $regs)) {
print_error("parenthesisinproperclose", 'question', '', $splits[1]);
}
@@ -190,7 +189,7 @@ class qformat_webct extends qformat_default {
// Processing multiples lines strings
if (isset($questiontext) and is_string($questiontext)) {
- if (ereg("^:",$line)) {
+ if (preg_match("~^:~",$line)) {
$question->questiontext = trim($questiontext);
unset($questiontext);
}
@@ -201,7 +200,7 @@ class qformat_webct extends qformat_default {
}
if (isset($answertext) and is_string($answertext)) {
- if (ereg("^:",$line)) {
+ if (preg_match("~^:~",$line)) {
$answertext = trim($answertext);
$question->answer[$currentchoice] = $answertext;
$question->subanswers[$currentchoice] = $answertext;
@@ -214,7 +213,7 @@ class qformat_webct extends qformat_default {
}
if (isset($responsetext) and is_string($responsetext)) {
- if (ereg("^:",$line)) {
+ if (preg_match("~^:~",$line)) {
$question->subquestions[$currentchoice] = trim($responsetext);
unset($responsetext);
}
@@ -225,7 +224,7 @@ class qformat_webct extends qformat_default {
}
if (isset($feedbacktext) and is_string($feedbacktext)) {
- if (ereg("^:",$line)) {
+ if (preg_match("~^:~",$line)) {
$question->feedback[$currentchoice] = trim($feedbacktext);
unset($feedbacktext);
}
@@ -236,7 +235,7 @@ class qformat_webct extends qformat_default {
}
if (isset($generalfeedbacktext) and is_string($generalfeedbacktext)) {
- if (ereg("^:",$line)) {
+ if (preg_match("~^:~",$line)) {
$question->tempgeneralfeedback= trim($generalfeedbacktext);
unset($generalfeedbacktext);
}
@@ -248,7 +247,7 @@ class qformat_webct extends qformat_default {
$line = trim($line);
- if (eregi("^:(TYPE|EOF):",$line)) {
+ if (preg_match("~^:(TYPE|EOF):~i",$line)) {
// New Question or End of File
if (isset($question)) { // if previous question exists, complete, check and save it
@@ -382,7 +381,7 @@ class qformat_webct extends qformat_default {
// Processing Question Header
- if (eregi("^:TYPE:MC:1(.*)",$line,$webct_options)) {
+ if (preg_match("~^:TYPE:MC:1(.*)~i",$line,$webct_options)) {
// Multiple Choice Question with only one good answer
$question = $this->defaultquestion();
$question->feedback = array();
@@ -392,7 +391,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TYPE:MC:N(.*)",$line,$webct_options)) {
+ if (preg_match("~^:TYPE:MC:N(.*)~i",$line,$webct_options)) {
// Multiple Choice Question with several good answers
$question = $this->defaultquestion();
$question->feedback = array();
@@ -402,7 +401,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TYPE:S",$line)) {
+ if (preg_match("~^:TYPE:S~i",$line)) {
// Short Answer Question
$question = $this->defaultquestion();
$question->feedback = array();
@@ -412,7 +411,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TYPE:C",$line)) {
+ if (preg_match("~^:TYPE:C~i",$line)) {
// Calculated Question
/* $warnings[] = get_string("calculatedquestion", "quiz", $nLineCounter);
unset($question);
@@ -434,7 +433,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TYPE:M",$line)) {
+ if (preg_match("~^:TYPE:M~i",$line)) {
// Match Question
$question = $this->defaultquestion();
$question->qtype = MATCH;
@@ -443,7 +442,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TYPE:P",$line)) {
+ if (preg_match("~^:TYPE:P~i",$line)) {
// Paragraph Question
$warnings[] = get_string("paragraphquestion", "quiz", $nLineCounter);
unset($question);
@@ -451,7 +450,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TYPE:",$line)) {
+ if (preg_match("~^:TYPE:~i",$line)) {
// Unknow Question
$warnings[] = get_string("unknowntype", "quiz", $nLineCounter);
unset($question);
@@ -463,7 +462,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:TITLE:(.*)",$line,$webct_options)) {
+ if (preg_match("~^:TITLE:(.*)~i",$line,$webct_options)) {
$name = trim($webct_options[1]);
if (strlen($name) > 255) {
$name = substr($name,0,250)."...";
@@ -473,9 +472,9 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:IMAGE:(.*)",$line,$webct_options)) {
+ if (preg_match("~^:IMAGE:(.*)~i",$line,$webct_options)) {
$filename = trim($webct_options[1]);
- if (eregi("^http://",$filename)) {
+ if (preg_match("~^http://~i",$filename)) {
$question->image = $filename;
}
continue;
@@ -486,9 +485,9 @@ class qformat_webct extends qformat_default {
if (!isset($question)) {
continue;
}
- if (isset($question->qtype ) && CALCULATED == $question->qtype && ereg(
- "^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)", $line, $webct_options)) {
- $datasetname = ereg_replace('^::', '', $webct_options[1]);
+ if (isset($question->qtype ) && CALCULATED == $question->qtype && preg_match(
+ "~^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)~", $line, $webct_options)) {
+ $datasetname = preg_replace('/^::/', '', $webct_options[1]);
$datasetvalue = qformat_webct_convert_formula($webct_options[4]);
switch ($webct_options[2]) {
case 'MIN':
@@ -512,27 +511,27 @@ class qformat_webct extends qformat_default {
}
- $bIsHTMLText = eregi(":H$",$line); // True if next lines are coded in HTML
- if (eregi("^:QUESTION",$line)) {
+ $bIsHTMLText = preg_match("~:H$~i",$line); // True if next lines are coded in HTML
+ if (preg_match("~^:QUESTION~i",$line)) {
$questiontext=""; // Start gathering next lines
continue;
}
- if (eregi("^:ANSWER([0-9]+):([^:]+):([0-9\.\-]+):(.*)",$line,$webct_options)) { /// SHORTANSWER
+ if (preg_match("~^:ANSWER([0-9]+):([^:]+):([0-9\.\-]+):(.*)~i",$line,$webct_options)) { /// SHORTANSWER
$currentchoice=$webct_options[1];
$answertext=$webct_options[2]; // Start gathering next lines
$question->fraction[$currentchoice]=($webct_options[3]/100);
continue;
}
- if (eregi("^:ANSWER([0-9]+):([0-9\.\-]+)",$line,$webct_options)) {
+ if (preg_match("~^:ANSWER([0-9]+):([0-9\.\-]+)~i",$line,$webct_options)) {
$answertext=""; // Start gathering next lines
$currentchoice=$webct_options[1];
$question->fraction[$currentchoice]=($webct_options[2]/100);
continue;
}
- if (eregi('^:FORMULA:(.*)', $line, $webct_options)) {
+ if (preg_match('~^:FORMULA:(.*)~i', $line, $webct_options)) {
// Answer for a CALCULATED question
++$currentchoice;
$question->answers[$currentchoice] =
@@ -556,60 +555,60 @@ class qformat_webct extends qformat_default {
continue;
}
- if (eregi("^:L([0-9]+)",$line,$webct_options)) {
+ if (preg_match("~^:L([0-9]+)~i",$line,$webct_options)) {
$answertext=""; // Start gathering next lines
$currentchoice=$webct_options[1];
$question->fraction[$currentchoice]=1;
continue;
}
- if (eregi("^:R([0-9]+)",$line,$webct_options)) {
+ if (preg_match("~^:R([0-9]+)~i",$line,$webct_options)) {
$responsetext=""; // Start gathering next lines
$currentchoice=$webct_options[1];
continue;
}
- if (eregi("^:REASON([0-9]+):?",$line,$webct_options)) {
+ if (preg_match("~^:REASON([0-9]+):?~i",$line,$webct_options)) {
$feedbacktext=""; // Start gathering next lines
$currentchoice=$webct_options[1];
continue;
}
- if (eregi("^:FEEDBACK([0-9]+):?",$line,$webct_options)) {
+ if (preg_match("~^:FEEDBACK([0-9]+):?~i",$line,$webct_options)) {
$generalfeedbacktext=""; // Start gathering next lines
$currentchoice=$webct_options[1];
continue;
}
- if (eregi('^:FEEDBACK:(.*)',$line,$webct_options)) {
+ if (preg_match('~^:FEEDBACK:(.*)~i',$line,$webct_options)) {
$generalfeedbacktext=""; // Start gathering next lines
continue;
}
- if (eregi('^:LAYOUT:(.*)',$line,$webct_options)) {
+ if (preg_match('~^:LAYOUT:(.*)~i',$line,$webct_options)) {
// ignore since layout in question_multichoice is no more used in moodle
// $webct_options[1] contains either vertical or horizontal ;
continue;
}
- if (isset($question->qtype ) && CALCULATED == $question->qtype && eregi('^:ANS-DEC:([1-9][0-9]*)', $line, $webct_options)) {
+ if (isset($question->qtype ) && CALCULATED == $question->qtype && preg_match('~^:ANS-DEC:([1-9][0-9]*)~i', $line, $webct_options)) {
// We can but hope that this always appear before the ANSTYPE property
$question->correctanswerlength[$currentchoice] = $webct_options[1];
continue;
}
- if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi("^:TOL:($webctnumberregex)", $line, $webct_options)) {
+ if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match("~^:TOL:($webctnumberregex)~i", $line, $webct_options)) {
// We can but hope that this always appear before the TOL property
$question->tolerance[$currentchoice] =
qformat_webct_convert_formula($webct_options[1]);
continue;
}
- if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:TOLTYPE:percent', $line)) {
+ if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match('~^:TOLTYPE:percent~i', $line)) {
// Percentage case is handled as relative in Moodle:
$question->tolerance[$currentchoice] /= 100;
$question->tolerancetype[$currentchoice] = 1; // Relative
continue;
}
- if (eregi('^:UNITS:(.+)', $line, $webct_options)
+ if (preg_match('~^:UNITS:(.+)~i', $line, $webct_options)
and $webctunits = trim($webct_options[1])) {
// This is a guess - I really do not know how different webct units are separated...
$webctunits = explode(':', $webctunits);
@@ -621,7 +620,7 @@ class qformat_webct extends qformat_default {
continue;
}
- if (!empty($question->units) && eregi('^:UNITREQ:(.*)', $line, $webct_options)
+ if (!empty($question->units) && preg_match('~^:UNITREQ:(.*)~i', $line, $webct_options)
&& !$webct_options[1]) {
// There are units but units are not required so add the no unit alternative
// We can but hope that the UNITS property always appear before this property
@@ -631,17 +630,17 @@ class qformat_webct extends qformat_default {
continue;
}
- if (!empty($question->units) && eregi('^:UNITCASE:', $line)) {
+ if (!empty($question->units) && preg_match('~^:UNITCASE:~i', $line)) {
// This could be important but I was not able to figure out how
// it works so I ignore it for now
continue;
}
- if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:ANSTYPE:dec', $line)) {
+ if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match('~^:ANSTYPE:dec~i', $line)) {
$question->correctanswerformat[$currentchoice]='1';
continue;
}
- if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:ANSTYPE:sig', $line)) {
+ if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match('~^:ANSTYPE:sig~i', $line)) {
$question->correctanswerformat[$currentchoice]='2';
continue;
}
diff --git a/question/format/xml/format.php b/question/format/xml/format.php
index 33097978574..3d3af94696a 100755
--- a/question/format/xml/format.php
+++ b/question/format/xml/format.php
@@ -930,7 +930,7 @@ class qformat_xml extends qformat_default {
foreach($question->options->questions as $question) {
$thispattern = addslashes("{#".$a_count."}"); // TODO: fix this addslashes
$thisreplace = $question->questiontext;
- $expout=ereg_replace($thispattern, $thisreplace, $expout );
+ $expout=preg_replace("~$thispattern~", $thisreplace, $expout );
$a_count++;
}
break;
diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php
index b3422b41aed..bc9c49d3248 100644
--- a/question/type/calculated/edit_calculated_form.php
+++ b/question/type/calculated/edit_calculated_form.php
@@ -169,7 +169,7 @@ class question_edit_calculated_form extends question_edit_form {
$qtextremaining = str_replace('{'.$name.'}', '1', $qtextremaining);
}
// echo "numericalquestion qtextremaining ";print_r($possibledatasets);
- while (ereg('\{=([^[:space:]}]*)}', $qtextremaining, $regs1)) {
+ while (preg_match('~\{=([^[:space:]}]*)}~', $qtextremaining, $regs1)) {
$qtextsplits = explode($regs1[0], $qtextremaining, 2);
$qtext =$qtext.$qtextsplits[0];
$qtextremaining = $qtextsplits[1];
@@ -274,4 +274,4 @@ class question_edit_calculated_form extends question_edit_form {
return $errors;
}
}
-?>
\ No newline at end of file
+?>
diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php
index c31aec4fd4d..4cf8596c7e1 100644
--- a/question/type/calculated/questiontype.php
+++ b/question/type/calculated/questiontype.php
@@ -267,7 +267,7 @@ class question_calculated_qtype extends default_questiontype {
}
function restore_session_and_responses(&$question, &$state) {
- if (!ereg('^dataset([0-9]+)[^-]*-(.*)$',
+ if (!preg_match('~^dataset([0-9]+)[^-]*-(.*)$~',
$state->responses[''], $regs)) {
notify ("Wrongly formatted raw response answer " .
"{$state->responses['']}! Could not restore session for " .
@@ -647,7 +647,7 @@ class question_calculated_qtype extends default_questiontype {
//evaluate the equations i.e {=5+4)
$qtext = "";
$qtextremaining = $numericalquestion->questiontext ;
- while (ereg('\{=([^[:space:]}]*)}', $qtextremaining, $regs1)) {
+ while (preg_match('~\{=([^[:space:]}]*)}~', $qtextremaining, $regs1)) {
$qtextsplits = explode($regs1[0], $qtextremaining, 2);
$qtext =$qtext.$qtextsplits[0];
$qtextremaining = $qtextsplits[1];
@@ -766,7 +766,7 @@ class question_calculated_qtype extends default_questiontype {
function custom_generator_set_data($datasetdefs, $formdata){
$idx = 1;
foreach ($datasetdefs as $datasetdef){
- if (ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$', $datasetdef->options, $regs)) {
+ if (preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~', $datasetdef->options, $regs)) {
$defid = "$datasetdef->type-$datasetdef->category-$datasetdef->name";
$formdata["calcdistribution[$idx]"] = $regs[1];
$formdata["calcmin[$idx]"] = $regs[2];
@@ -779,7 +779,7 @@ class question_calculated_qtype extends default_questiontype {
}
function custom_generator_tools($datasetdef) {
- if (ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$',
+ if (preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~',
$datasetdef->options, $regs)) {
$defid = "$datasetdef->type-$datasetdef->category-$datasetdef->name";
for ($i = 0 ; $i<10 ; ++$i) {
@@ -1012,7 +1012,7 @@ class question_calculated_qtype extends default_questiontype {
}
}
function generate_dataset_item($options) {
- if (!ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$',
+ if (!preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~',
$options, $regs)) {
// Unknown options...
return false;
@@ -1122,7 +1122,7 @@ class question_calculated_qtype extends default_questiontype {
// list($options, $selected) = $this->dataset_optionsa($form, $name);
foreach ($options as $key => $whatever) {
- if (!ereg('^1-', $key) && $key != '0') {
+ if (!preg_match('~^1-~', $key) && $key != '0') {
unset($options[$key]);
}
}
@@ -1495,7 +1495,7 @@ class question_calculated_qtype extends default_questiontype {
/// Returns the possible dataset names found in the text as an array
/// The array has the dataset name for both key and value
$datasetnames = array();
- while (ereg('\\{([[:alpha:]][^>} <{"\']*)\\}', $text, $regs)) {
+ while (preg_match('~\\{([[:alpha:]][^>} <{"\']*)\\}~', $text, $regs)) {
$datasetnames[$regs[1]] = $regs[1];
$text = str_replace($regs[0], '', $text);
}
@@ -1781,7 +1781,7 @@ function qtype_calculated_calculate_answer($formula, $individualdata,
if ($answerlength) {
/* Try to include missing zeros at the end */
- if (ereg('^(.*\\.)(.*)$', $calculated->answer, $regs)) {
+ if (preg_match('~^(.*\\.)(.*)$~', $calculated->answer, $regs)) {
$calculated->answer = $regs[1] . substr(
$regs[2] . '00000000000000000000000000000000000000000x',
0, $answerlength)
@@ -1841,7 +1841,7 @@ function qtype_calculated_calculate_answer($formula, $individualdata,
$calculated->answer = $sign.$answer.$unit;
} else {
// Could be an idea to add some zeros here
- $answer .= (ereg('^[0-9]*$', $answer) ? '.' : '')
+ $answer .= (preg_match('~^[0-9]*$~', $answer) ? '.' : '')
. '00000000000000000000000000000000000000000x';
$oklen = $answerlength + ($p10 < 1 ? 2-$p10 : 1);
$calculated->answer = $sign.substr($answer, 0, $oklen).$unit;
@@ -1862,7 +1862,7 @@ function qtype_calculated_find_formula_errors($formula) {
/// Returns false if everything is alright.
/// Otherwise it constructs an error message
// Strip away dataset names
- while (ereg('\\{[[:alpha:]][^>} <{"\']*\\}', $formula, $regs)) {
+ while (preg_match('~\\{[[:alpha:]][^>} <{"\']*\\}~', $formula, $regs)) {
$formula = str_replace($regs[0], '1', $formula);
}
@@ -1873,7 +1873,7 @@ function qtype_calculated_find_formula_errors($formula) {
$operatorornumber = "[$safeoperatorchar.0-9eE]";
- while (ereg("(^|[$safeoperatorchar,(])([a-z0-9_]*)\\(($operatorornumber+(,$operatorornumber+((,$operatorornumber+)+)?)?)?\\)",
+ while (preg_match("~(^|[$safeoperatorchar,(])([a-z0-9_]*)\\(($operatorornumber+(,$operatorornumber+((,$operatorornumber+)+)?)?)?\\)~",
$formula, $regs)) {
switch ($regs[2]) {
@@ -1936,11 +1936,11 @@ function qtype_calculated_find_formula_errors($formula) {
$formula = str_replace($regs[0], $regs[1] . '1', $formula);
} else {
// The function call starts the formula
- $formula = ereg_replace("^$regs[2]\\([^)]*\\)", '1', $formula);
+ $formula = preg_replace("~^$regs[2]\\([^)]*\\)~", '1', $formula);
}
}
- if (ereg("[^$safeoperatorchar.0-9eE]+", $formula, $regs)) {
+ if (preg_match("~[^$safeoperatorchar.0-9eE]+~", $formula, $regs)) {
return get_string('illegalformulasyntax', 'quiz', $regs[0]);
} else {
// Formula just might be valid
diff --git a/question/type/calculatedsimple/edit_calculatedsimple_form.php b/question/type/calculatedsimple/edit_calculatedsimple_form.php
index 251453d99c3..f41f7502160 100644
--- a/question/type/calculatedsimple/edit_calculatedsimple_form.php
+++ b/question/type/calculatedsimple/edit_calculatedsimple_form.php
@@ -161,7 +161,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
$this->datasetdefs[$def]->calcmax = $calcmax[$key] ;
$this->datasetdefs[$def]->calclength = $calclength[$key] ;
//then compare with new values
- if (ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$', $this->datasetdefs[$def]->options, $regs)) {
+ if (preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~', $this->datasetdefs[$def]->options, $regs)) {
if( $this->datasetdefs[$def]->calcmin != $regs[2]||
$this->datasetdefs[$def]->calcmax != $regs[3] ||
$this->datasetdefs[$def]->calclength != $regs[4]){
@@ -667,7 +667,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
foreach ($possibledatasets as $name => $value) {
$qtextremaining = str_replace('{'.$name.'}', '1', $qtextremaining);
}
- while (ereg('\{=([^[:space:]}]*)}', $qtextremaining, $regs1)) {
+ while (preg_match('~\{=([^[:space:]}]*)}~', $qtextremaining, $regs1)) {
$qtextsplits = explode($regs1[0], $qtextremaining, 2);
$qtext =$qtext.$qtextsplits[0];
$qtextremaining = $qtextsplits[1];
@@ -799,4 +799,4 @@ class question_edit_calculatedsimple_form extends question_edit_form {
return $errors;
}
}
-?>
\ No newline at end of file
+?>
diff --git a/question/type/calculatedsimple/questiontype.php b/question/type/calculatedsimple/questiontype.php
index 08fd8438ff2..ae001db7d97 100644
--- a/question/type/calculatedsimple/questiontype.php
+++ b/question/type/calculatedsimple/questiontype.php
@@ -332,7 +332,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype {
// list($options, $selected) = $this->dataset_optionsa($form, $name);
foreach ($options as $key => $whatever) {
- if (!ereg('^1-', $key) && $key != '0') {
+ if (!preg_match('~^1-~', $key) && $key != '0') {
unset($options[$key]);
}
}
diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php
index d534fbf8422..eeb5f96edbd 100644
--- a/question/type/multianswer/questiontype.php
+++ b/question/type/multianswer/questiontype.php
@@ -307,7 +307,7 @@ class embedded_cloze_qtype extends default_questiontype {
// The regex will recognize text snippets of type {#X}
// where the X can be any text not containg } or white-space characters.
- while (ereg('\{#([^[:space:]}]*)}', $qtextremaining, $regs)) {
+ while (preg_match('~\{#([^[:space:]}]*)}~', $qtextremaining, $regs)) {
$qtextsplits = explode($regs[0], $qtextremaining, 2);
echo $qtextsplits[0];
echo "