<?PHP // $Id$\r
\r
//////////////////////////////////\r
-/// CONFIGURATION settings \r
+/// CONFIGURATION settings\r
\r
if (!isset($CFG->hotpot_showtimes)) {\r
set_config("hotpot_showtimes", 0);\r
\r
\r
// possible return values:\r
-// false: \r
+// false:\r
// display moderr.html (if exists) OR "Could not update" and return to couse view\r
-// string: \r
+// string:\r
// display as error message and return to course view\r
// true (or non-zero number):\r
// continue to $hp->redirect (if set) OR hotpot/view.php (to displsay quiz)\r
$hp->timeopen = 0;\r
} else {\r
$hp->timeopen = make_timestamp(\r
- $hp->openyear, $hp->openmonth, $hp->openday, \r
+ $hp->openyear, $hp->openmonth, $hp->openday,\r
$hp->openhour, $hp->openminute, 0\r
);\r
}\r
$hp->timeclose = 0;\r
} else {\r
$hp->timeclose = make_timestamp(\r
- $hp->closeyear, $hp->closemonth, $hp->closeday, \r
+ $hp->closeyear, $hp->closemonth, $hp->closeday,\r
$hp->closehour, $hp->closeminute, 0\r
);\r
}\r
\r
if (! set_field("course_modules", "section", $sectionid, "id", $hp->coursemodule)) {\r
error("Could not update the course module with the correct section");\r
- } \r
+ }\r
\r
- add_to_log($hp->course, "course", "add mod", \r
- "../mod/$hp->modulename/view.php?id=$hp->coursemodule", \r
+ add_to_log($hp->course, "course", "add mod",\r
+ "../mod/$hp->modulename/view.php?id=$hp->coursemodule",\r
"$hp->modulename $hp->instance"\r
- ); \r
- add_to_log($hp->course, $hp->modulename, "add", \r
- "view.php?id=$hp->coursemodule", \r
+ );\r
+ add_to_log($hp->course, $hp->modulename, "add",\r
+ "view.php?id=$hp->coursemodule",\r
"$hp->instance", $hp->coursemodule\r
);\r
\r
}\r
}\r
\r
- } else { \r
+ } else {\r
// xml file (...maybe)\r
$xml_tree = new hotpot_xml_tree($source);\r
$xml_tree->filetype = '';\r
- \r
+\r
$keys = array_keys($xml_tree->xml);\r
foreach ($keys as $key) {\r
if (preg_match('/^(hotpot|textoys)-(\w+)-file$/i', $key, $matches)) {\r
\r
$title = strip_tags($xml_tree->xml_value('data,title'));\r
$subtitle = $xml_tree->xml_value('hotpot-config-file,'.$xml_tree->quiztype.',exercise-subtitle');\r
- \r
+\r
if ($get_next) {\r
$include = $xml_tree->xml_value('hotpot-config-file,global,include-next-ex');\r
if (!empty($include)) {\r
}\r
\r
$query = "\r
- SELECT \r
- cm.id AS coursemodule, \r
+ SELECT\r
+ cm.id AS coursemodule,\r
cm.course AS course,\r
cm.module AS module,\r
cm.instance AS instance,\r
cs.sequence AS sequence,\r
cs.visible AS sectionvisible,\r
thismodule.*\r
- FROM \r
+ FROM\r
{$CFG->prefix}course_modules AS cm,\r
{$CFG->prefix}course_sections AS cs,\r
{$CFG->prefix}modules AS m,\r
{$CFG->prefix}$modulename AS thismodule\r
- WHERE \r
+ WHERE\r
m.name = '$modulename' AND\r
m.id = cm.module AND\r
cm.course = '$course->id' AND\r
\r
$explodesection = array();\r
$order = array();\r
- \r
+\r
foreach ($rawmods as $rawmod) {\r
\r
if (empty($explodesection[$rawmod->section])) {\r
}\r
\r
} // end foreach $modinfo\r
- \r
+\r
ksort($instances);\r
$instances = array_values($instances);\r
}\r
return $ok;\r
}\r
function hotpot_delete_instance($id) {\r
-/// Given an ID of an instance of this module, \r
-/// this function will permanently delete the instance \r
-/// and any data that depends on it. \r
+/// Given an ID of an instance of this module,\r
+/// this function will permanently delete the instance\r
+/// and any data that depends on it.\r
\r
$result = false;\r
if (delete_records("hotpot", "id", "$id")) {\r
}\r
\r
function hotpot_user_complete($course, $user, $mod, $hp) {\r
-/// Print a detailed representation of what a user has done with \r
+/// Print a detailed representation of what a user has done with\r
/// a given particular instance of this module, for user activity reports.\r
\r
$report = hotpot_user_outline($course, $user, $mod, $hp);\r
}\r
\r
function hotpot_user_outline($course, $user, $mod, $hp) {\r
-/// Return a small object with summary information about what a \r
+/// Return a small object with summary information about what a\r
/// user has done with a given particular instance of this module\r
/// Used for user activity reports.\r
/// $report->time = the time they did it\r
}\r
\r
function hotpot_print_recent_activity($course, $isteacher, $timestart) {\r
-/// Given a course and a time, this module should find recent activity \r
-/// that has occurred in hotpot activities and print it out. \r
+/// Given a course and a time, this module should find recent activity\r
+/// that has occurred in hotpot activities and print it out.\r
/// Return true if there was output, or false is there was none.\r
\r
global $CFG;\r
\r
$records = get_records_sql("\r
SELECT\r
- h.id AS id, \r
+ h.id AS id,\r
h.name AS name,\r
COUNT(*) AS count_attempts\r
- FROM \r
- {$CFG->prefix}hotpot AS h, \r
+ FROM\r
+ {$CFG->prefix}hotpot AS h,\r
{$CFG->prefix}hotpot_attempts AS a\r
- WHERE \r
- h.course = $course->id \r
- AND h.id = a.hotpot \r
+ WHERE\r
+ h.course = $course->id\r
+ AND h.id = a.hotpot\r
AND a.id = a.clickreportid\r
AND a.starttime > $timestart\r
- GROUP BY \r
+ GROUP BY\r
h.id, h.name\r
");\r
// note that PostGreSQL requires h.name in the GROUP BY clause\r
$result = true;\r
}\r
}\r
- return $result; // True if anything was printed, otherwise false \r
+ return $result; // True if anything was printed, otherwise false\r
}\r
\r
function hotpot_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, $cmid="", $userid="", $groupid="") {\r
-// Returns all quizzes since a given time. \r
+// Returns all quizzes since a given time.\r
\r
global $CFG;\r
\r
\r
$records = get_records_sql("\r
SELECT\r
- a.*, \r
- h.name, h.course, \r
+ a.*,\r
+ h.name, h.course,\r
cm.instance, cm.section,\r
u.firstname, u.lastname, u.picture\r
- FROM \r
+ FROM\r
{$CFG->prefix}hotpot_attempts AS a,\r
{$CFG->prefix}hotpot AS h,\r
{$CFG->prefix}course_modules AS cm,\r
{$CFG->prefix}user AS u\r
- WHERE \r
+ WHERE\r
a.timefinish > '$sincetime'\r
AND a.id = a.clickreportid\r
AND a.userid = u.id $user_select\r
AND cm.instance = h.id\r
AND cm.course = '$courseid'\r
AND h.course = cm.course\r
- ORDER BY \r
+ ORDER BY\r
a.timefinish ASC\r
");\r
\r
\r
function hotpot_cron () {\r
/// Function to be run periodically according to the moodle cron\r
-/// This function searches for things that need to be done, such \r
-/// as sending out mail, toggling flags etc ... \r
+/// This function searches for things that need to be done, such\r
+/// as sending out mail, toggling flags etc ...\r
\r
global $CFG;\r
\r
}\r
\r
function hotpot_grades($hotpotid) {\r
-/// Must return an array of grades for a given instance of this module, \r
+/// Must return an array of grades for a given instance of this module,\r
/// indexed by user. It also returns a maximum allowed grade.\r
\r
$hotpot = get_record('hotpot', 'id', $hotpotid);\r
global $CFG;\r
\r
return get_records_sql("\r
- SELECT DISTINCT \r
+ SELECT DISTINCT\r
u.id, u.id\r
- FROM \r
+ FROM\r
{$CFG->prefix}user u,\r
{$CFG->prefix}hotpot_attempts a\r
- WHERE \r
+ WHERE\r
u.id = a.userid\r
- AND a.hotpot = '$hotpotid' \r
+ AND a.hotpot = '$hotpotid'\r
");\r
}\r
\r
//it it has support for grading and scales. Commented code should be\r
//modified if necessary. See forum, glossary or journal modules\r
//as reference.\r
- \r
+\r
$report = false;\r
\r
//$rec = get_record("hotpot","id","$hotpotid","scale","-$scaleid");\r
//if (!empty($rec) && !empty($scaleid)) {\r
// $report = true;\r
//}\r
- \r
+\r
return $report;\r
}\r
\r
//////////////////////////////////////////////////////////\r
-/// Any other hotpot functions go here. \r
+/// Any other hotpot functions go here.\r
/// Each of them must have a name that starts with hotpot\r
\r
\r
\r
// set all previous "in progress" attempts at this quiz to "abandoned"\r
$db->Execute("\r
- UPDATE \r
+ UPDATE\r
{$CFG->prefix}hotpot_attempts as a\r
SET\r
a.timefinish = $timefinish,\r
// decode angle brackets\r
$value = strtr($value, array('<'=>'<', '>'=>'>', '&'=>'&'));\r
\r
- // remove white space between <table>, <ul|OL|DL> and <OBJECT|EMBED> parts \r
+ // remove white space between <table>, <ul|OL|DL> and <OBJECT|EMBED> parts\r
// (so it doesn't get converted to <br />)\r
$htmltags = '('\r
. 'TABLE|/?CAPTION|/?COL|/?COLGROUP|/?TBODY|/?TFOOT|/?THEAD|/?TD|/?TH|/?TR'\r
$this->draganddrop = '';\r
if (\r
empty($this->real_outputformat) ||\r
- $this->real_outputformat==HOTPOT_OUTPUTFORMAT_BEST || \r
+ $this->real_outputformat==HOTPOT_OUTPUTFORMAT_BEST ||\r
empty($HOTPOT_OUTPUTFORMAT_DIR[$this->real_outputformat])\r
) {\r
if ($CFG->hotpotismobile && isset($HOTPOT_OUTPUTFORMAT_DIR[HOTPOT_OUTPUTFORMAT_MOBILE])) {\r
// adjust JCross question numbers\r
if (preg_match('/^(across|down)(.*)$/', $name, $matches)) {\r
$num .= '_'.$matches[1]; // e.g. 01_across, 02_down\r
- $name = $matches[2]; \r
+ $name = $matches[2];\r
if (substr($name, 0, 1)=='_') {\r
$name = substr($name, 1); // remove leading '_'\r
}\r
$loopcount++;\r
$question->name = "$questionname ($loopcount)";\r
\r
- // This method fails to correctly identify questions in \r
- // quizzes which allow questions to be shuffled or omitted. \r
+ // This method fails to correctly identify questions in\r
+ // quizzes which allow questions to be shuffled or omitted.\r
// As yet, there is no workaround for such cases.\r
\r
} else {\r
// required for Moodle 1.x\r
if (!isset($CFG->pixpath)) {\r
$CFG->pixpath = "$CFG->wwwroot/pix";\r
-} \r
+}\r
\r
if (!defined('PARAM_RAW')) define('PARAM_RAW', 0x0000);\r
-if (!defined('PARAM_CLEAN')) define('PARAM_CLEAN', 0x0001);\r
if (!defined('PARAM_INT')) define('PARAM_INT', 0x0002);\r
+if (!defined('PARAM_CLEAN')) define('PARAM_CLEAN', 0x0001);\r
if (!defined('PARAM_ALPHA')) define('PARAM_ALPHA', 0x0004);\r
if (!defined('PARAM_ALPHANUM')) define('PARAM_ALPHANUM', 0x0400);\r
+if (!defined('PARAM_SAFEDIR')) define('PARAM_SAFEDIR', 0x4000);\r
\r
if (!function_exists('required_param')) {\r
// add this function for Moodle version<1.4.2\r
return $param;\r
}\r
}\r
-if (!function_exists('set_user_preference')) {\r
+if (!function_exists('clean_param')) {\r
+ // add this function for Moodle 1.3 and less\r
+ function clean_param($param, $type) {\r
+ return $param;\r
+ }\r
+}\r
+if (!function_exists('fullname')) {\r
// add this function for Moodle 1.x\r
- function set_user_preference($name, $value, $otheruser=NULL) {\r
- return false;\r
+ function fullname($user) {\r
+ return "$user->firstname $user->lastname";\r
}\r
}\r
if (!function_exists('get_user_preferences')) {\r
return $default;\r
}\r
}\r
-if (!function_exists('fullname')) {\r
+if (!function_exists('set_user_preference')) {\r
// add this function for Moodle 1.x\r
- function fullname($user) {\r
- return "$user->firstname $user->lastname";\r
+ function set_user_preference($name, $value, $otheruser=NULL) {\r
+ return false;\r
}\r
}\r
-\r
function hotpot_utf8_to_html_entity($char) {\r
// http://www.zend.com/codex.php?id=835&single=1\r
\r
- // array used to figure what number to decrement from character order value \r
- // according to number of characters used to map unicode to ascii by utf-8 \r
+ // array used to figure what number to decrement from character order value\r
+ // according to number of characters used to map unicode to ascii by utf-8\r
static $HOTPOT_UTF8_DECREMENT = array(\r
1=>0, 2=>192, 3=>224, 4=>240\r
);\r
\r
- // the number of bits to shift each character by \r
+ // the number of bits to shift each character by\r
static $HOTPOT_UTF8_SHIFT = array(\r
1=>array(0=>0),\r
2=>array(0=>6, 1=>0),\r
3=>array(0=>12, 1=>6, 2=>0),\r
4=>array(0=>18, 1=>12, 2=>6, 3=>0)\r
);\r
- \r
- $dec = 0; \r
+\r
+ $dec = 0;\r
$len = strlen($char);\r
for ($pos=0; $pos<$len; $pos++) {\r
$ord = ord ($char{$pos});\r
- $ord -= ($pos ? 128 : $HOTPOT_UTF8_DECREMENT[$len]); \r
- $dec += ($ord << $HOTPOT_UTF8_SHIFT[$len][$pos]); \r
- } \r
- return '&#x'.sprintf('%04X', $dec).';'; \r
+ $ord -= ($pos ? 128 : $HOTPOT_UTF8_DECREMENT[$len]);\r
+ $dec += ($ord << $HOTPOT_UTF8_SHIFT[$len][$pos]);\r
+ }\r
+ return '&#x'.sprintf('%04X', $dec).';';\r
}\r
\r
function hotpot_print_show_links($course, $location, $reference, $actions='', $spacer=' ', $new_window=false) {\r