hotpotroot = $CFG->dirroot.DIRECTORY_SEPARATOR.'mod'.DIRECTORY_SEPARATOR.'hotpot';
define("HOTPOT_JS", "$CFG->wwwroot/mod/hotpot/hotpot-full.js");
define("HOTPOT_NO", "0");
define("HOTPOT_YES", "1");
define("HOTPOT_LOCATION_COURSEFILES", "0");
define("HOTPOT_LOCATION_SITEFILES", "1");
$HOTPOT_LOCATION = array (
HOTPOT_LOCATION_COURSEFILES => get_string("coursefiles"),
HOTPOT_LOCATION_SITEFILES => get_string("sitefiles"),
);
define("HOTPOT_OUTPUTFORMAT_BEST", "1");
define("HOTPOT_OUTPUTFORMAT_V3", "11");
define("HOTPOT_OUTPUTFORMAT_V4", "12");
define("HOTPOT_OUTPUTFORMAT_V5", "13");
define("HOTPOT_OUTPUTFORMAT_V6", "14");
define("HOTPOT_OUTPUTFORMAT_V6_PLUS", "15");
define("HOTPOT_OUTPUTFORMAT_FLASH", "20");
define("HOTPOT_OUTPUTFORMAT_MOBILE", "30");
$HOTPOT_OUTPUTFORMAT = array (
HOTPOT_OUTPUTFORMAT_BEST => get_string("outputformat_best", "hotpot"),
HOTPOT_OUTPUTFORMAT_V6_PLUS => get_string("outputformat_v6_plus", "hotpot"),
HOTPOT_OUTPUTFORMAT_V6 => get_string("outputformat_v6", "hotpot"),
// HOTPOT_OUTPUTFORMAT_V5 => get_string("outputformat_v5", "hotpot"),
// HOTPOT_OUTPUTFORMAT_V4 => get_string("outputformat_v4", "hotpot"),
// HOTPOT_OUTPUTFORMAT_V3 => get_string("outputformat_v3", "hotpot"),
// HOTPOT_OUTPUTFORMAT_FLASH => get_string("outputformat_flash", "hotpot"),
// HOTPOT_OUTPUTFORMAT_MOBILE => get_string("outputformat_mobile", "hotpot"),
);
define("HOTPOT_NAVIGATION_BAR", "1");
define("HOTPOT_NAVIGATION_FRAME", "2");
define("HOTPOT_NAVIGATION_IFRAME", "3");
define("HOTPOT_NAVIGATION_BUTTONS", "4");
define("HOTPOT_NAVIGATION_GIVEUP", "5");
define("HOTPOT_NAVIGATION_NONE", "6");
$HOTPOT_NAVIGATION = array (
HOTPOT_NAVIGATION_BAR => get_string("navigation_bar", "hotpot"),
HOTPOT_NAVIGATION_FRAME => get_string("navigation_frame", "hotpot"),
HOTPOT_NAVIGATION_IFRAME => get_string("navigation_iframe", "hotpot"),
HOTPOT_NAVIGATION_BUTTONS => get_string("navigation_buttons", "hotpot"),
HOTPOT_NAVIGATION_GIVEUP => get_string("navigation_give_up", "hotpot"),
HOTPOT_NAVIGATION_NONE => get_string("navigation_none", "hotpot"),
);
define("HOTPOT_JCB", "1");
define("HOTPOT_JCLOZE", "2");
define("HOTPOT_JCROSS", "3");
define("HOTPOT_JMATCH", "4");
define("HOTPOT_JMIX", "5");
define("HOTPOT_JQUIZ", "6");
define("HOTPOT_TEXTOYS_RHUBARB", "7");
define("HOTPOT_TEXTOYS_SEQUITUR", "8");
define("HOTPOT_JQUIZ_MULTICHOICE", "1");
define("HOTPOT_JQUIZ_SHORTANSWER", "2");
define("HOTPOT_JQUIZ_HYBRID", "3");
define("HOTPOT_JQUIZ_MULTISELECT", "4");
define("HOTPOT_GRADEMETHOD_HIGHEST", "1");
define("HOTPOT_GRADEMETHOD_AVERAGE", "2");
define("HOTPOT_GRADEMETHOD_FIRST", "3");
define("HOTPOT_GRADEMETHOD_LAST", "4");
$HOTPOT_GRADEMETHOD = array (
HOTPOT_GRADEMETHOD_HIGHEST => get_string("gradehighest", "quiz"),
HOTPOT_GRADEMETHOD_AVERAGE => get_string("gradeaverage", "quiz"),
HOTPOT_GRADEMETHOD_FIRST => get_string("attemptfirst", "quiz"),
HOTPOT_GRADEMETHOD_LAST => get_string("attemptlast", "quiz"),
);
function hotpot_add_instance($hp) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will create a new instance and return the id number
/// of the new instance.
hotpot_set_times($hp);
return insert_record("hotpot", $hp);
}
function hotpot_update_instance($hp) {
/// Given an object containing all the necessary data,
/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
hotpot_set_times($hp);
$hp->id = $hp->instance;
return update_record("hotpot", $hp);
}
function hotpot_set_times(&$hp) {
$time = time();
$hp->timecreated = $time;
$hp->timemodified = $time;
$hp->timeopen = make_timestamp(
$hp->openyear, $hp->openmonth, $hp->openday,
$hp->openhour, $hp->openminute, 0
);
$hp->timeclose = make_timestamp(
$hp->closeyear, $hp->closemonth, $hp->closeday,
$hp->closehour, $hp->closeminute, 0
);
}
function hotpot_delete_instance($id) {
/// Given an ID of an instance of this module,
/// this function will permanently delete the instance
/// and any data that depends on it.
$result = false;
if (delete_records("hotpot", "id", "$id")) {
$result = true;
if ($attempts = get_records_select("hotpot_attempts", "hotpot='$id'")) {
$ids = implode(',', array_keys($attempts));
delete_records_select("hotpot_attempts", "id IN ($ids)");
delete_records_select("hotpot_questions", "attempt IN ($ids)");
delete_records_select("hotpot_responses", "attempt IN ($ids)");
}
}
return $result;
}
function hotpot_delete_and_notify($table, $select, $strtable) {
$count = max(0, count_records_select($table, $select));
if ($count) {
delete_records_select($table, $select);
$count -= max(0, count_records_select($table, $select));
if ($count) {
notify(get_string("deleted")." $count x $strtable");
}
}
}
function hotpot_user_complete($course, $user, $mod, $hp) {
/// Print a detailed representation of what a user has done with
/// a given particular instance of this module, for user activity reports.
$report = hotpot_user_outline($course, $user, $mod, $hp);
if (empty($report)) {
print get_string("noactivity", "hotpot");
} else {
$date = userdate($report->time, get_string('strftimerecentfull'));
print $report->info.' '.get_string('mostrecently').': '.$date;
}
return true;
}
function hotpot_user_outline($course, $user, $mod, $hp) {
/// Return a small object with summary information about what a
/// user has done with a given particular instance of this module
/// Used for user activity reports.
/// $report->time = the time they did it
/// $report->info = a short text description
$report = NULL;
if ($records = get_records_select("hotpot_attempts", "hotpot='$hp->id' AND userid='$user->id'", "timestart ASC", "*")) {
$scores = array();
foreach ($records as $record){
if (empty($report->time)) {
$report->time = $record->timestart;
}
$scores[] = hotpot_format_score($record);
}
if (empty($scores)) {
$report->time = 0;
$report->info = get_string('noactivity', 'hotpot');
} else {
$report->info = get_string('score', 'quiz').': '.implode(', ', $scores);
}
}
return $report;
}
function hotpot_format_score($record) {
if (isset($record->score)) {
$score = $record->score;
} else {
$str = empty($record->timefinish) ? 'inprogress' : 'abandoned';
$score = ''.get_string($str, 'hotpot').'';
}
return $score;
}
function hotpot_print_recent_activity($course, $isteacher, $timestart) {
/// Given a course and a time, this module should find recent activity
/// that has occurred in hotpot activities and print it out.
/// Return true if there was output, or false is there was none.
global $CFG;
$result = false;
if($isteacher){
$records = get_records_sql("
SELECT
h.id AS id,
h.name AS name,
COUNT(*) AS count_attempts
FROM
{$CFG->prefix}hotpot AS h,
{$CFG->prefix}hotpot_attempts AS a
WHERE
h.course = $course->id
AND h.id = a.hotpot
AND a.starttime > $timestart
GROUP BY
h.id, h.name
");
// note that PostGreSQL requires h.name in the GROUP BY clause
if($records) {
$names = array();
foreach ($records as $id => $record){
$href = "$CFG->wwwroot/mod/hotpot/view.php?id=$id";
$name = " $record->name";
if ($record->count_attempts > 1) {
$name >= " ($record->count_attempts)";
}
$names[] = $name;
}
print ' Hot Potatoes Activity: '.implode(' ', $names).'';
$result = true;
}
}
return $result; // True if anything was printed, otherwise false
}
function hotpot_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, $cmid="", $userid="", $groupid="") {
// Returns all quizzes since a given time.
global $CFG;
// If $cmid or $userid are specified, then this restricts the results
$cm_select = empty($cmid) ? "" : " AND cm.id = '$cmid'";
$user_select = empty($userid) ? "" : " AND u.id = '$userid'";
$records = get_records_sql("
SELECT
a.*,
h.name, h.course,
cm.instance, cm.section,
u.firstname, u.lastname, u.picture
FROM
{$CFG->prefix}hotpot_attempts AS a,
{$CFG->prefix}hotpot AS h,
{$CFG->prefix}course_modules AS cm,
{$CFG->prefix}user AS u
WHERE
a.timefinish > '$sincetime'
AND a.userid = u.id $user_select
AND a.hotpot = h.id $cm_select
AND cm.instance = h.id
AND cm.course = '$courseid'
AND h.course = cm.course
ORDER BY
a.timefinish ASC
");
if (!empty($records)) {
foreach ($records as $record) {
if (empty($groupid) || ismember($groupid, $record->userid)) {
$activity->type = "hotpot";
$activity->defaultindex = $index;
$activity->instance = $record->hotpot;
$activity->name = $record->name;
$activity->section = $record->section;
$activity->content->attemptid = $record->id;
$activity->content->attempt = $record->attempt;
$activity->content->score = $record->score;
$activity->content->details = $record->details;
$activity->content->timestart = $record->timestart;
$activity->content->timefinish = $record->timefinish;
$activity->user->userid = $record->userid;
$activity->user->fullname = fullname($record);
$activity->user->picture = $record->picture;
$activity->timestamp = $record->timefinish;
$activities[] = $activity;
$index++;
}
} // end foreach
}
}
function hotpot_print_recent_mod_activity($activity, $course, $detail=false) {
/// Basically, this function prints the results of "hotpot_get_recent_activity"
global $CFG, $THEME, $USER;
print '
';
if ($detail) {
// activity icon
$src = "$CFG->modpixpath/$activity->type/icon.gif";
print ' ';
// link to activity
$href = "$CFG->wwwroot/mod/hotpot/view.php?id=$activity->instance";
print ''.$activity->name.' - ';
}
if (isteacher($course)) {
// score (with link to attempt details)
$href = "$CFG->wwwroot/mod/hotpot/review.php?hp=$activity->instance&attempt=".$activity->content->attemptid;
print '('.hotpot_format_score($activity->content).') ';
// attempt number
print get_string('attempt', 'quiz').' - '.$activity->content->attempt.' ';
}
// link to user
$href = "$CFG->wwwroot/user/view.php?id=$activity->user->userid&course=$course";
print ''.$activity->user->fullname.' ';
// time and date
print ' - ' . userdate($activity->timestamp);
// duration
$duration = format_time($activity->content->timestart - $activity->content->timefinish);
print " ($duration)";
print "
";
print "
";
}
function hotpot_cron () {
/// Function to be run periodically according to the moodle cron
/// This function searches for things that need to be done, such
/// as sending out mail, toggling flags etc ...
global $CFG;
return true;
}
function hotpot_grades($hotpotid) {
/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
$hotpot = get_record('hotpot', 'id', $hotpotid);
$return->grades = hotpot_get_grades($hotpot);
$return->maxgrade = $hotpot->grade;
return $return;
}
function hotpot_get_grades($hotpot, $user_ids='') {
global $CFG;
$grades = array();
$weighting = $hotpot->grade / 100;
$precision = ($hotpot->grademethod==HOTPOT_GRADEMETHOD_AVERAGE || $hotpot->grade<100) ? 1 : 0;
// set the SQL string to determine the $grade
$grade = "";
switch ($hotpot->grademethod) {
case HOTPOT_GRADEMETHOD_HIGHEST:
$grade = "ROUND(MAX(score) * $weighting, $precision) AS grade";
break;
case HOTPOT_GRADEMETHOD_AVERAGE:
// the 'AVG' function skips abandoned quizzes, so use SUM(score)/COUNT(id)
$grade = "ROUND(SUM(score)/COUNT(id) * $weighting, $precision) AS grade";
break;
case HOTPOT_GRADEMETHOD_FIRST:
if ($CFG->dbtype=='postgres7') {
$grade = "MIN(timestart||'_'||(CASE WHEN (score IS NULL) THEN '' ELSE TRIM(ROUND(score * $weighting, $precision)) END)) AS grade";
} else {
$grade = "MIN(CONCAT(timestart, '_', IF(score IS NULL, '', ROUND(score * $weighting, $precision)))) AS grade";
}
break;
case HOTPOT_GRADEMETHOD_LAST:
if ($CFG->dbtype=='postgres7') {
$grade = "MAX(timestart||'_'||(CASE WHEN (score IS NULL) THEN '' ELSE TRIM(ROUND(score * $weighting, $precision)) END)) AS grade";
} else {
$grade = "MAX(CONCAT(timestart, '_', IF(score IS NULL, '', ROUND(score * $weighting, $precision)))) AS grade";
}
break;
}
if ($grade) {
$userid_condition = empty($user_ids) ? '' : "AND userid IN ($user_ids) ";
$grades = get_records_sql_menu("
SELECT userid, $grade
FROM {$CFG->prefix}hotpot_attempts
WHERE timefinish>0 AND hotpot='$hotpot->id' $userid_condition
GROUP BY userid
");
if ($hotpot->grademethod==HOTPOT_GRADEMETHOD_FIRST || $hotpot->grademethod==HOTPOT_GRADEMETHOD_LAST) {
// remove left hand characters in $grade (up to and including the underscore)
foreach ($grades as $userid=>$grade) {
$grades[$userid] = substr($grades[$userid], strpos($grades[$userid], '_')+1);
}
}
}
return $grades;
}
function hotpot_get_participants($hotpotid) {
//Must return an array of user records (all data) who are participants
//for a given instance of hotpot. Must include every user involved
//in the instance, independient of his role (student, teacher, admin...)
//See other modules as example.
global $CFG;
return get_records_sql("
SELECT DISTINCT
u.*
FROM
{$CFG->prefix}user u,
{$CFG->prefix}hotpot_attempts a
WHERE
u.id = a.userid
AND a.hotpot = '$hotpotid'
");
}
function hotpot_scale_used ($hotpotid, $scaleid) {
//This function returns if a scale is being used by one hotpot
//it it has support for grading and scales. Commented code should be
//modified if necessary. See forum, glossary or journal modules
//as reference.
$report = false;
//$rec = get_record("hotpot","id","$hotpotid","scale","-$scaleid");
//
//if (!empty($rec) && !empty($scaleid)) {
// $report = true;
//}
return $report;
}
//////////////////////////////////////////////////////////////////////////////////////
/// Any other hotpot functions go here. Each of them must have a name that
/// starts with hotpot
function hotpot_add_attempt($hotpotid, $userid=NULL) {
$userid = hotpot_get_userid($userid);
hotpot_close_previous_attempts($hotpotid, $userid);
$attempt->hotpot = $hotpotid;
$attempt->userid = $userid;
$attempt->attempt = hotpot_get_next_attempt($hotpotid, $userid);
$attempt->timestart = time();
return insert_record("hotpot_attempts", $attempt);
}
function hotpot_close_previous_attempts($hotpotid, $userid=NULL, $time=NULL) {
/// set previously unfinished attempts of this quiz by this user to "finished"
if (empty($time)) {
$time = time();
}
$userid = hotpot_get_userid($userid);
set_field("hotpot_attempts", "timefinish", $time, "hotpot", $hotpotid, "userid", $userid, "timefinish", 0);
}
function hotpot_get_next_attempt($hotpotid, $userid=NULL) {
// get max attempt so far
$i = count_records_select(
'hotpot_attempts',
"hotpot='$hotpotid' AND userid='".hotpot_get_userid($userid)."'",
'MAX(attempt)'
);
return empty($i) ? 1 : ($i+1);
}
function hotpot_get_userid($userid=NULL) {
global $USER;
return isset($userid) ? $userid : $USER->id;
}
function hotpot_get_question_name($question) {
$name = '';
if (isset($question->text)) {
$name =hotpot_strings($question->text);
}
if (empty($name)) {
$name = $question->name;
}
return $name;
}
function hotpot_strings($ids) {
// array of ids of empty strings
static $HOTPOT_EMPTYSTRINGS;
if (!isset($HOTPOT_EMPTYSTRINGS)) { // first time only
$emptystringids = get_records_select('hotpot_strings', 'LENGTH(TRIM(string))=0');
$HOTPOT_EMPTYSTRINGS = empty($emptystringids) ? array() : array_keys($emptystringids);
}
$strings = array();
if (!empty($ids)) {
$ids = explode(',', $ids);
foreach ($ids as $id) {
if (!in_array($id, $HOTPOT_EMPTYSTRINGS)) {
$strings[] = hotpot_string($id);
}
}
}
return implode(',', $strings);
}
function hotpot_string($id) {
return get_field('hotpot_strings', 'string', 'id', $id);
}
//////////////////////////////////////////////////////////////////////////////////////
/// the class definitions to handle XML trees
// get the standard XML parser supplied with Moodle
require_once($CFG->libdir.DIRECTORY_SEPARATOR.'xmlize.php');
class hotpot_xml_tree {
function hotpot_xml_tree($str, $xml_root='') {
if (empty($str)) {
$this->xml = array();
} else {
$str = utf8_encode($str);
$this->xml = xmlize($str, 0);
}
$this->xml_root = $xml_root;
}
function xml_value($tags, $more_tags="[0]['#']") {
$tags = empty($tags) ? '' : "['".str_replace(",", "'][0]['#']['", $tags)."']";
eval('$value = &$this->xml'.$this->xml_root.$tags.$more_tags.';');
if (is_string($value)) {
$value = utf8_decode($value);
// decode angle brackets and replace newlines
$value = strtr($value, array('<'=>'<', '>'=>'>', "\n"=>' '));
// encode any orphaned angle brackets back to html entities
if (empty($this->tag_pattern)) {
$q = "'"; // single quote
$qq = '"'; // double quote
$this->tag_pattern = '<(([^>'.$q.$qq.']*)|('."{$q}[^$q]*$q".')|('."{$qq}[^$qq]*$qq".'))*>';
}
$value = preg_replace('/<([^>]*'.$this->tag_pattern.')/', '<$1', $value);
$value = preg_replace('/('.$this->tag_pattern.'[^<]*)>/', '$1>', $value);
}
return $value;
}
function xml_values($tags) {
$i = 0;
$values = array();
while ($value = $this->xml_value($tags, "[$i]['#']")) {
$values[$i++] = $value;
}
return $values;
}
function obj_value(&$obj, $name) {
return is_object($obj) ? @$obj->$name : (is_array($obj) ? @$obj[$name] : NULL);
}
function encode_cdata(&$str, $tag) {
// conversion tables
$HTML_ENTITIES = array(
''' => "'",
'"' => '"',
'<' => '<',
'>' => '>',
'&' => '&',
);
$ILLEGAL_STRINGS = array(
"\r" => '',
"\n" => '<br />',
']]>' => ']]>',
);
// extract the $tag from the $str(ing), if possible
$pattern = '|(^.*<'.$tag.'[^>]*)(>.*<)(/'.$tag.'>.*$)|is';
if (preg_match($pattern, $str, $matches)) {
// encode problematic CDATA chars and strings
$matches[2] = strtr($matches[2], $ILLEGAL_STRINGS);
// if there are any ampersands in "open text"
// surround them by CDATA start and end markers
// (and convert HTML entities to plain text)
$search = '/>([^<]*&[^<]*)<"';
$matches[2] = preg_replace($search, $replace, $matches[2]);
$str = $matches[1].$matches[2].$matches[3];
}
}
}
class hotpot_xml_quiz extends hotpot_xml_tree {
// constructor function
function hotpot_xml_quiz(&$obj) {
// obj can be the $_GET array or a form object/array
global $CFG, $HOTPOT_OUTPUTFORMAT;
// check xmlize functions are available
if (! function_exists("xmlize")) {
error('xmlize functions are not available');
}
// extract fields from $obj
// course : the course id
// reference : the filename within the files folder for this course
// navigation : type of navigation required in quiz
// forceplugins : force Moodle compatible media players
$this->course = $this->obj_value($obj, 'course');
$this->reference = $this->obj_value($obj, 'reference');
$this->location = $this->obj_value($obj, 'location');
$this->navigation = $this->obj_value($obj, 'navigation');
$this->forceplugins = $this->obj_value($obj, 'forceplugins');
// can't continue if there is no course or reference
if (empty($this->course) || empty($this->reference)) {
error('Could not create XML tree: missing course or reference');
}
$this->course_homeurl = "$CFG->wwwroot/course/view.php?id=$this->course";
// set filedir, filename and filepath
switch ($this->location) {
case HOTPOT_LOCATION_SITEFILES:
$site = get_site();
$this->filedir = $site->id;
break;
case HOTPOT_LOCATION_COURSEFILES:
default:
$this->filedir = $this->course;
break;
}
$this->filename = basename($this->reference);
$this->filepath = $CFG->dataroot.DIRECTORY_SEPARATOR.$this->filedir.DIRECTORY_SEPARATOR.$this->reference;
// try and open the file
if (!file_exists($this->filepath) || !$fp = fopen($this->filepath, 'r')) {
error('Could not open the XML source file "'.$this->filename.'"', $this->course_homeurl);
}
// read in the XML source and close the file
$this->source = fread($fp, filesize($this->filepath));
fclose($fp);
// convert relative URLs to absolute URLs
$this->hotpot_convert_relative_urls($this->source);
// encode "gap fill" text in JCloze exercise
$this->encode_cdata($this->source, 'gap-fill');
// convert source to xml tree
$this->hotpot_xml_tree($this->source);
// initialize file type, quiz type and output format
$this->html = '';
$this->filetype = '';
$this->quiztype = '';
$this->outputformat = 0;
// link tag to , if necessary
if (isset($this->xml['HTML'])) {
$this->xml['html'] = &$this->xml['HTML'];
}
if (isset($this->xml['html'])) {
$this->filetype = 'html';
// shortcut to source
$s = &$this->source;
// try to set the quiz type from phrases in the source
if (strpos($s, 'QuizForm') && strpos($s, 'CheckForm') && strpos($s, 'CorrectAnswers')) {
$this->outputformat = HOTPOT_OUTPUTFORMAT_V3;
$this->quiztype = 'jmatch';
} else if (strpos($s, 'name="FeedbackFrame"') && strpos($s, 'name="CodeFrame"')) {
$this->outputformat = HOTPOT_OUTPUTFORMAT_V3;
$this->quiztype = strpos($s, 'QuizForm') ? 'jcb' : strpos($s, 'Cloze') ? 'jcloze' : strpos($s, 'Crossword') ? 'jcross' : strpos($s, 'QForm1') ? 'jquiz' : '';
} else if (strpos($s, 'function DynLayer')) {
$this->outputformat = HOTPOT_OUTPUTFORMAT_V4;
$this->quiztype = (strpos($s, 'QForm') && strpos($s, 'QForm.FB[QNum]')) ? 'jcb' : strpos($s, 'Cloze') ? 'jcloze' : strpos($s, 'Crossword') ? 'jcross' : strpos($s, 'ExCheck') ? 'jmatch' : (strpos($s, 'QForm') && strpos($s, 'QForm.Answer')) ? 'jquiz' : '';
} else if (strpos($s, 'name="TopFrame"') && strpos($s, 'name="BottomFrame"')) {
$this->outputformat = HOTPOT_OUTPUTFORMAT_V5;
$this->quiztype = (strpos($s, 'QForm') && strpos($s, 'FB_[QNum]_[ANum]')) ? 'jcb' : strpos($s, 'form name="Cloze"') ? 'jcloze' : strpos($s, 'AnswerForm') ? 'jcross' : (strpos($s, 'QForm') && strpos($s, 'sel[INum]')) ? 'jmatch' : strpos($s, 'ButtonForm') ? 'jmix' : (strpos($s, 'QForm[QNum]') && strpos($s, 'Buttons[QNum]')) ? 'jquiz' : '';
} else if (strpos($s, '
\n";
if (is_int($start = strpos($this->html, $start_str))) {
$start += strlen($start_str);
$this->html = substr($this->html, 0, $start).$message.substr($this->html, $start);
}
}
function adjust_media_urls() {
if ($this->forceplugins) {
// make sure the Moodle media plugin is available
global $CFG;
include_once "$CFG->dirroot/filter/mediaplugin/filter.php";
// exclude swf files from the filter
$CFG->filter_mediaplugin_ignore_swf = true;
$s = '\s+'; // at least one space
$n = '[^>]*'; // any character inside a tag
$q = '["'."']?"; // single, double, or no quote
$Q = '[^"'."' >]*"; // any charater inside a quoted string
// patterns to media files types and paths
$filetype = "avi|mpeg|mpg|mp3|mov|wmv";
$filepath = "$Q\.($filetype)";
// pattern to match tags which contain the file path
// wmp : url
// quicktime : src
// realplayer : src
// flash : movie (doesn't need replacing)
$url_param = "//is";
// pattern to match tags which link to multimedia files (not swf)
$link = "/(.*?)<\/a>/is";
// extract