Removed tabs

This commit is contained in:
moodler 2006-08-09 13:45:49 +00:00
parent bee7ee3815
commit dabfd0ed85
67 changed files with 8204 additions and 8204 deletions

View file

@ -107,10 +107,10 @@ class assignment_base {
*/ */
function view() { function view() {
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id); $context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
has_capability('mod/assignment:view', $context->id, true); has_capability('mod/assignment:view', $context->id, true);
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}",
$this->assignment->id, $this->cm->id); $this->assignment->id, $this->cm->id);
$this->view_header(); $this->view_header();
@ -281,7 +281,7 @@ class assignment_base {
// if this user can mark and is put in a group // if this user can mark and is put in a group
// then he can only see/mark submission in his own groups // then he can only see/mark submission in his own groups
if (user_group($this->course->id, $USER->id)) { if (user_group($this->course->id, $USER->id)) {
$count = $this->count_real_submissions($this->currentgroup); // Only their groups $count = $this->count_real_submissions($this->currentgroup); // Only their groups
} else { } else {
$count = $this->count_real_submissions(); // Everyone $count = $this->count_real_submissions(); // Everyone

View file

@ -35,7 +35,7 @@
var availableitems = ['availableday','availablemonth','availableyear','availablehour', 'availableminute']; var availableitems = ['availableday','availablemonth','availableyear','availablehour', 'availableminute'];
</script> </script>
<form name="form" method="post" action="../mod/assignment/details.php"> <form name="form" method="post" action="../mod/assignment/details.php">
<table cellpadding="5"> <table cellpadding="5">
<tr valign="top"> <tr valign="top">
<td align="right"><b><?php print_string("assignmentname", "assignment") ?>:</b></td> <td align="right"><b><?php print_string("assignmentname", "assignment") ?>:</b></td>

View file

@ -17,17 +17,17 @@
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
error('Course Module ID was incorrect'); error('Course Module ID was incorrect');
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id, false, $cm);
has_capability('mod/chat:chat',$context->id, true); has_capability('mod/chat:chat',$context->id, true);
/* /*
if (isguest()) { if (isguest()) {
error('Guest does not have access to chat rooms'); error('Guest does not have access to chat rooms');
} }
*/ */
if (!$cm->visible and !isteacher($course->id)) { if (!$cm->visible and !isteacher($course->id)) {
print_header(); print_header();
notice(get_string("activityiscurrentlyhidden")); notice(get_string("activityiscurrentlyhidden"));

View file

@ -200,17 +200,17 @@ function chat_print_recent_activity($course, $isteacher, $timestart) {
} }
if ($chat = get_record('chat', 'id', $chatuser->chatid)) { if ($chat = get_record('chat', 'id', $chatuser->chatid)) {
// we find the course module id // we find the course module id
$chatmod = get_record('modules', 'name', 'chat'); $chatmod = get_record('modules', 'name', 'chat');
$SQL = "select * from {$CFG->prefix}course_modules where $SQL = "select * from {$CFG->prefix}course_modules where
course = $course->id course = $course->id
and module = $chatmod->id and module = $chatmod->id
and instance = $chat->id"; and instance = $chat->id";
$cm = get_records_sql($SQL); $cm = get_records_sql($SQL);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
// needs to be fixed // needs to be fixed
if (!(has_capability('mod/chat:readlog', $context->id) or instance_is_visible('chat', $chat))) { // Chat hidden to students if (!(has_capability('mod/chat:readlog', $context->id) or instance_is_visible('chat', $chat))) { // Chat hidden to students
//if (!($isteacher or instance_is_visible('chat', $chat))) { // Chat hidden to students //if (!($isteacher or instance_is_visible('chat', $chat))) { // Chat hidden to students
continue; continue;
} }

View file

@ -21,16 +21,16 @@
error('Course is misconfigured'); error('Course is misconfigured');
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$isteacher = isteacher($course->id); $isteacher = isteacher($course->id);
$isteacheredit = isteacheredit($course->id); $isteacheredit = isteacheredit($course->id);
//if (isguest() or (!$isteacher and !$chat->studentlogs)) { //if (isguest() or (!$isteacher and !$chat->studentlogs)) {
//error('You can not view these chat reports'); //error('You can not view these chat reports');
//} //}
has_capability('mod/chat:readlog', $context->id, true); // if can't even read, kill has_capability('mod/chat:readlog', $context->id, true); // if can't even read, kill
add_to_log($course->id, 'chat', 'report', "report.php?id=$cm->id", $chat->id, $cm->id); add_to_log($course->id, 'chat', 'report', "report.php?id=$cm->id", $chat->id, $cm->id);
@ -89,7 +89,7 @@
print_simple_box_end('center'); print_simple_box_end('center');
} }
if (!$deletesession or !has_capability('mod/chat:deletelog', $context->id)) { if (!$deletesession or !has_capability('mod/chat:deletelog', $context->id)) {
//if (!$deletesession or !$isteacheredit) { //if (!$deletesession or !$isteacheredit) {
print_continue("report.php?id=$cm->id"); print_continue("report.php?id=$cm->id");
} }
@ -124,7 +124,7 @@
/// Delete a session if one has been specified /// Delete a session if one has been specified
if ($deletesession and has_capability('mod/chat:deletelog', $context->id) and $confirmdelete and $start and $end and confirm_sesskey()) { if ($deletesession and has_capability('mod/chat:deletelog', $context->id) and $confirmdelete and $start and $end and confirm_sesskey()) {
//if ($deletesession and $isteacheredit and $confirmdelete and $start and $end and confirm_sesskey()) { //if ($deletesession and $isteacheredit and $confirmdelete and $start and $end and confirm_sesskey()) {
delete_records_select('chat_messages', "chatid = $chat->id AND delete_records_select('chat_messages', "chatid = $chat->id AND
timestamp >= '$start' AND timestamp >= '$start' AND
@ -194,7 +194,7 @@
echo '<p align="right">'; echo '<p align="right">';
echo "<a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend\">$strseesession</a>"; echo "<a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend\">$strseesession</a>";
//if ($isteacheredit) //if ($isteacheredit)
if (has_capability('mod/chat:deletelog', $context->id)) { if (has_capability('mod/chat:deletelog', $context->id)) {
echo "<br /><a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend&amp;deletesession=1\">$strdeletesession</a>"; echo "<br /><a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend&amp;deletesession=1\">$strdeletesession</a>";
} }
echo '</p>'; echo '</p>';

View file

@ -43,9 +43,9 @@
require_course_login($course, true, $cm); require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id); add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id);
// Initialize $PAGE, compute blocks // Initialize $PAGE, compute blocks
@ -76,7 +76,7 @@
echo '<td id="middle-column">'; echo '<td id="middle-column">';
if ($chat->studentlogs or has_capability('mod/chat:readlog',$context->id)) { if ($chat->studentlogs or has_capability('mod/chat:readlog',$context->id)) {
//if (($chat->studentlogs or isteacher($course->id)) and !isguest()) { //if (($chat->studentlogs or isteacher($course->id)) and !isguest()) {
echo '<div class="reportlink">'; echo '<div class="reportlink">';
echo "<a href=\"report.php?id=$cm->id\">". echo "<a href=\"report.php?id=$cm->id\">".

View file

@ -144,7 +144,7 @@ function choice_update_instance($choice) {
} }
function choice_show_form($choice, $user, $cm) { function choice_show_form($choice, $user, $cm) {
//$cdisplay is an array of the display info for a choice $cdisplay[$optionid]->text - text name of option. //$cdisplay is an array of the display info for a choice $cdisplay[$optionid]->text - text name of option.
// ->maxanswers -maxanswers for this option // ->maxanswers -maxanswers for this option
// ->full - whether this option is full or not. 0=not full, 1=full // ->full - whether this option is full or not. 0=not full, 1=full
@ -157,9 +157,9 @@ $cdisplay = array();
$countans = 0; $countans = 0;
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!empty($countanswers)) { if (!empty($countanswers)) {
foreach ($countanswers as $ca) { //only return enrolled users. foreach ($countanswers as $ca) { //only return enrolled users.
if (has_capability('mod/choice:choose', $context->id)) { if (has_capability('mod/choice:choose', $context->id)) {
//if (isstudent($cm->course, $ca->userid) or isteacher($cm->course, $ca->userid)) { //if (isstudent($cm->course, $ca->userid) or isteacher($cm->course, $ca->userid)) {
$countans = $countans+1; $countans = $countans+1;
} }
} }
@ -171,21 +171,21 @@ $cdisplay = array();
} }
$maxans = $choice->maxanswers[$optionid]; $maxans = $choice->maxanswers[$optionid];
$cdisplay[$aid]->optionid = $optionid; $cdisplay[$aid]->optionid = $optionid;
$cdisplay[$aid]->text = $text; $cdisplay[$aid]->text = $text;
$cdisplay[$aid]->maxanswers = $maxans; $cdisplay[$aid]->maxanswers = $maxans;
$cdisplay[$aid]->countanswers = $countans; $cdisplay[$aid]->countanswers = $countans;
if ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id, 'optionid', $optionid)) { if ($current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user->id, 'optionid', $optionid)) {
$cdisplay[$aid]->checked = ' checked="checked" '; $cdisplay[$aid]->checked = ' checked="checked" ';
} else { } else {
$cdisplay[$aid]->checked = ''; $cdisplay[$aid]->checked = '';
} }
if ($choice->limitanswers && ($countans >= $maxans) && (empty($cdisplay[$aid]->checked)) ) { if ($choice->limitanswers && ($countans >= $maxans) && (empty($cdisplay[$aid]->checked)) ) {
$cdisplay[$aid]->disabled = ' disabled="disabled" '; $cdisplay[$aid]->disabled = ' disabled="disabled" ';
} else { } else {
$cdisplay[$aid]->disabled = ''; $cdisplay[$aid]->disabled = '';
} }
$aid++; $aid++;
} }
} }
@ -193,13 +193,13 @@ $cdisplay = array();
switch ($choice->display) { switch ($choice->display) {
case CHOICE_DISPLAY_HORIZONTAL: case CHOICE_DISPLAY_HORIZONTAL:
echo "<table cellpadding=\"20\" cellspacing=\"20\" align=\"center\"><tr>"; echo "<table cellpadding=\"20\" cellspacing=\"20\" align=\"center\"><tr>";
foreach ($cdisplay as $cd) { foreach ($cdisplay as $cd) {
echo "<td align=\"center\" valign=\"top\">"; echo "<td align=\"center\" valign=\"top\">";
echo "<input type=\"radio\" name=\"answer\" value=\"".$cd->optionid."\" alt=\"".strip_tags(format_text($cd->text))."\"". $cd->checked.$cd->disabled." />"; echo "<input type=\"radio\" name=\"answer\" value=\"".$cd->optionid."\" alt=\"".strip_tags(format_text($cd->text))."\"". $cd->checked.$cd->disabled." />";
if (!empty($cd->disabled)) { if (!empty($cd->disabled)) {
echo format_text($cd->text."<br /><strong>".get_string('full', 'choice')."</strong>"); echo format_text($cd->text."<br /><strong>".get_string('full', 'choice')."</strong>");
} else { } else {
echo format_text($cd->text); echo format_text($cd->text);
} }
echo "</td>"; echo "</td>";
@ -222,8 +222,8 @@ $cdisplay = array();
if (!empty($cd->disabled)) { if (!empty($cd->disabled)) {
echo get_string('full', 'choice'); echo get_string('full', 'choice');
} elseif(!empty($cd->checked)) { } elseif(!empty($cd->checked)) {
//currently do nothing - maybe some text could be added here to signfy that the choice has been 'selected' //currently do nothing - maybe some text could be added here to signfy that the choice has been 'selected'
} elseif ($cd->maxanswers-$cd->countanswers==1) { } elseif ($cd->maxanswers-$cd->countanswers==1) {
echo ($cd->maxanswers - $cd->countanswers); echo ($cd->maxanswers - $cd->countanswers);
echo " ".get_string('spaceleft', 'choice'); echo " ".get_string('spaceleft', 'choice');
@ -256,26 +256,26 @@ $cdisplay = array();
function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $cm) { function choice_user_submit_response($formanswer, $choice, $userid, $courseid, $cm) {
$current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $userid); $current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $userid);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$countanswers = get_records("choice_answers", "optionid", $formanswer); $countanswers = get_records("choice_answers", "optionid", $formanswer);
if ($countanswers) { if ($countanswers) {
$countans = 0; $countans = 0;
foreach ($countanswers as $ca) { //only return enrolled users. foreach ($countanswers as $ca) { //only return enrolled users.
if (has_capability('mod/choice:choose', $context->id)) { if (has_capability('mod/choice:choose', $context->id)) {
//if (isstudent($courseid, $ca->userid) or isteacher($courseid, $ca->userid)) { //if (isstudent($courseid, $ca->userid) or isteacher($courseid, $ca->userid)) {
$countans = $countans+1; $countans = $countans+1;
} }
} }
$countanswers = count($countans); $countanswers = count($countans);
} else { } else {
$countanswers = 0; $countanswers = 0;
} }
$maxans = $choice->maxanswers[$formanswer]; $maxans = $choice->maxanswers[$formanswer];
if (!($choice->limitanswers && ($countanswers >= $maxans) )) { if (!($choice->limitanswers && ($countanswers >= $maxans) )) {
if ($current) { if ($current) {
$newanswer = $current; $newanswer = $current;
$newanswer->optionid = $formanswer; $newanswer->optionid = $formanswer;
$newanswer->timemodified = time(); $newanswer->timemodified = time();
@ -304,11 +304,11 @@ $current = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $user
function choice_show_reportlink($choice, $courseid, $cmid) { function choice_show_reportlink($choice, $courseid, $cmid) {
$context = get_context_instance(CONTEXT_MODULE, $cmid); $context = get_context_instance(CONTEXT_MODULE, $cmid);
if ( $allanswers = get_records("choice_answers", "choiceid", $choice->id)) { if ( $allanswers = get_records("choice_answers", "choiceid", $choice->id)) {
$responsecount = 0; $responsecount = 0;
foreach ($allanswers as $aa) { foreach ($allanswers as $aa) {
if (has_capability('mod/choice:readresponses', $context->id)) { if (has_capability('mod/choice:readresponses', $context->id)) {
//if (isstudent($courseid, $aa->userid) or isteacher($courseid, $aa->userid)) { //check to make sure user is enrolled in course. //if (isstudent($courseid, $aa->userid) or isteacher($courseid, $aa->userid)) { //check to make sure user is enrolled in course.
$responsecount++; $responsecount++;
} }
} }
@ -323,12 +323,12 @@ function choice_show_reportlink($choice, $courseid, $cmid) {
function choice_show_results($choice, $course, $cm, $forcepublish='') { function choice_show_results($choice, $course, $cm, $forcepublish='') {
global $CFG, $COLUMN_HEIGHT, $USER; global $CFG, $COLUMN_HEIGHT, $USER;
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
print_heading(get_string("responses", "choice")); print_heading(get_string("responses", "choice"));
if (empty($forcepublish)) { //alow the publish setting to be overridden if (empty($forcepublish)) { //alow the publish setting to be overridden
$forcepublish = $choice->publish; $forcepublish = $choice->publish;
} }
/// Check to see if groups are being used in this choice /// Check to see if groups are being used in this choice
if ($groupmode = groupmode($course, $cm)) { // Groups are being used if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = setup_and_print_groups($course, $groupmode, $_SERVER['PHP_SELF']."?id=$cm->id"); $currentgroup = setup_and_print_groups($course, $groupmode, $_SERVER['PHP_SELF']."?id=$cm->id");
@ -383,9 +383,9 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
//$isteacher = isteacher($course->id); //$isteacher = isteacher($course->id);
$tablewidth = (int) (100.0 / count($useranswer)); $tablewidth = (int) (100.0 / count($useranswer));
if (has_capability('mod/choice:readresponses', $context->id)) { if (has_capability('mod/choice:readresponses', $context->id)) {
//if (isteacher($course->id, $USER->id)) { //if (isteacher($course->id, $USER->id)) {
echo '<div id="tablecontainer">'; echo '<div id="tablecontainer">';
echo '<form id="attemptsform" method="post" action="'.$_SERVER['PHP_SELF'].'" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \''.addslashes(get_string('deleteattemptcheck','quiz')).'\' : true);">'; echo '<form id="attemptsform" method="post" action="'.$_SERVER['PHP_SELF'].'" onsubmit="var menu = document.getElementById(\'menuaction\'); return (menu.options[menu.selectedIndex].value == \'delete\' ? \''.addslashes(get_string('deleteattemptcheck','quiz')).'\' : true);">';
echo '<input type="hidden" name="id" value="'.$cm->id.'" />'; echo '<input type="hidden" name="id" value="'.$cm->id.'" />';
echo '<input type="hidden" name="mode" value="overview" />'; echo '<input type="hidden" name="mode" value="overview" />';
@ -420,7 +420,7 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
echo "<table width=\"100%\">"; echo "<table width=\"100%\">";
foreach ($userlist as $user) { foreach ($userlist as $user) {
// this needs to be fixed // this needs to be fixed
if (!($optionid==0 && isadmin($user->id)) && !($optionid==0 && isteacher($course->id, $user->id) && !(isteacheredit($course->id, $user->id)) ) ) { //make sure admins and hidden teachers are not shown in not answered yet column. if (!($optionid==0 && isadmin($user->id)) && !($optionid==0 && isteacher($course->id, $user->id) && !(isteacheredit($course->id, $user->id)) ) ) { //make sure admins and hidden teachers are not shown in not answered yet column.
echo "<tr>"; echo "<tr>";
if (isteacher($course->id, $USER->id) && !($optionid==0)) { if (isteacher($course->id, $USER->id) && !($optionid==0)) {
@ -450,12 +450,12 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
$countanswers = get_records("choice_answers", "optionid", $optionid); $countanswers = get_records("choice_answers", "optionid", $optionid);
$countans = 0; $countans = 0;
if (!empty($countanswers)) { if (!empty($countanswers)) {
foreach ($countanswers as $ca) { //only return enrolled users. foreach ($countanswers as $ca) { //only return enrolled users.
// needs fixing too // needs fixing too
if (isstudent($course->id, $ca->userid) or isteacher($course->id, $ca->userid)) { if (isstudent($course->id, $ca->userid) or isteacher($course->id, $ca->userid)) {
$countans = $countans+1; $countans = $countans+1;
} }
} }
} }
if ($choice->limitanswers && !$optionid==0) { if ($choice->limitanswers && !$optionid==0) {
echo get_string("taken", "choice").":"; echo get_string("taken", "choice").":";
@ -490,8 +490,8 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
echo "</tr></table>"; echo "</tr></table>";
//if (isteacher($course->id, $USER->id)) { //if (isteacher($course->id, $USER->id)) {
if (has_capability('mod/choice:readresponses', $context->id)) { if (has_capability('mod/choice:readresponses', $context->id)) {
echo "</form></div>"; echo "</form></div>";
} }
break; break;
@ -572,13 +572,13 @@ function choice_show_results($choice, $course, $cm, $forcepublish='') {
echo "</tr></table>"; echo "</tr></table>";
break; break;
} }
} }
function choice_delete_responses($attemptids) { function choice_delete_responses($attemptids) {
if(!is_array($attemptids) || empty($attemptids)) { if(!is_array($attemptids) || empty($attemptids)) {
return false; return false;
} }

View file

@ -18,11 +18,11 @@
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/choice:readresponses', $context->id, true); has_capability('mod/choice:readresponses', $context->id, true);
//if (!isteacher($course->id)) { //if (!isteacher($course->id)) {
// error("Only teachers can look at this page"); // error("Only teachers can look at this page");
//} //}
@ -40,7 +40,7 @@
//if ($action == 'delete') { //some responses need to be deleted //if ($action == 'delete') { //some responses need to be deleted
$attemptids = isset($_POST['attemptid']) ? $_POST['attemptid'] : array(); //get array of repsonses to delete. $attemptids = isset($_POST['attemptid']) ? $_POST['attemptid'] : array(); //get array of repsonses to delete.
choice_delete_responses($attemptids); //delete responses. choice_delete_responses($attemptids); //delete responses.
redirect("report.php?id=$cm->id"); redirect("report.php?id=$cm->id");
} }
if ($download <> "xls" and $download <> "txt" ) { if ($download <> "xls" and $download <> "txt" ) {
@ -123,9 +123,9 @@
$ug2 = ''; $ug2 = '';
if ($usergrps = user_group($course->id, $user->id)) { if ($usergrps = user_group($course->id, $user->id)) {
foreach ($usergrps as $ug) { foreach ($usergrps as $ug) {
$ug2 = $ug2. $ug->name; $ug2 = $ug2. $ug->name;
} }
} }
$myxls->write_string($row,3,$ug2); $myxls->write_string($row,3,$ug2);
$useroption = choice_get_option_text($choice, $answers[$user->id]->optionid); $useroption = choice_get_option_text($choice, $answers[$user->id]->optionid);
@ -144,7 +144,7 @@
exit; exit;
} }
// print text file // print text file
//if ($download == "txt") { //if ($download == "txt") {
if ($download == "txt" && has_capability('mod/choice:downloadresponses', $context->id, true)) { if ($download == "txt" && has_capability('mod/choice:downloadresponses', $context->id, true)) {
$filename = clean_filename("$course->shortname ".strip_tags(format_string($choice->name,true))).'.txt'; $filename = clean_filename("$course->shortname ".strip_tags(format_string($choice->name,true))).'.txt';
@ -172,15 +172,15 @@
echo "\t".$user->firstname; echo "\t".$user->firstname;
$studentid = " "; $studentid = " ";
if (!empty($user->idnumber)) { if (!empty($user->idnumber)) {
$studentid = $user->idnumber; $studentid = $user->idnumber;
} }
echo "\t". $studentid."\t"; echo "\t". $studentid."\t";
$ug2 = ''; $ug2 = '';
if ($usergrps = user_group($course->id, $user->id)) { if ($usergrps = user_group($course->id, $user->id)) {
foreach ($usergrps as $ug) { foreach ($usergrps as $ug) {
$ug2 = $ug2. $ug->name; $ug2 = $ug2. $ug->name;
} }
} }
echo $ug2. "\t"; echo $ug2. "\t";
echo format_string(choice_get_option_text($choice, $answers[$user->id]->optionid),true). "\n"; echo format_string(choice_get_option_text($choice, $answers[$user->id]->optionid),true). "\n";
} }

View file

@ -33,7 +33,7 @@
if ($form = data_submitted()) { if ($form = data_submitted()) {
$timenow = time(); $timenow = time();
if (has_capability('mod/choice:deleteresponses', $context->id)) { if (has_capability('mod/choice:deleteresponses', $context->id)) {
//if (isteacher($course->id, $USER->id)) { //if (isteacher($course->id, $USER->id)) {
if ($action == 'delete') { //some responses need to be deleted if ($action == 'delete') { //some responses need to be deleted
choice_delete_responses($attemptids); //delete responses. choice_delete_responses($attemptids); //delete responses.
@ -59,7 +59,7 @@
"<a href=\"index.php?id=$course->id\">$strchoices</a> -> ".format_string($choice->name), "", "", true, "<a href=\"index.php?id=$course->id\">$strchoices</a> -> ".format_string($choice->name), "", "", true,
update_module_button($cm->id, $course->id, $strchoice), navmenu($course, $cm)); update_module_button($cm->id, $course->id, $strchoice), navmenu($course, $cm));
if (has_capability('mod/choice:readresponses', $context->id)) { if (has_capability('mod/choice:readresponses', $context->id)) {
//if (isteacher($course->id)) { //if (isteacher($course->id)) {
choice_show_reportlink($choice, $course->id, $cm->id); choice_show_reportlink($choice, $course->id, $cm->id);
} else if (!$cm->visible) { } else if (!$cm->visible) {
@ -102,7 +102,7 @@
( $choice->showresults == CHOICE_SHOWRESULTS_AFTER_ANSWER and $current ) or ( $choice->showresults == CHOICE_SHOWRESULTS_AFTER_ANSWER and $current ) or
( $choice->showresults == CHOICE_SHOWRESULTS_AFTER_CLOSE and $choice->timeclose <= time() ) ) { ( $choice->showresults == CHOICE_SHOWRESULTS_AFTER_CLOSE and $choice->timeclose <= time() ) ) {
choice_show_results($choice, $course, $cm); choice_show_results($choice, $course, $cm);
} }
print_footer($course); print_footer($course);

View file

@ -26,11 +26,11 @@
} }
require_login($course->id); require_login($course->id);
$cm = data_get_cm($data);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($commentid) { $cm = data_get_cm($data);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($commentid) {
if (! $comment = get_record('data_comments', 'id', $commentid)) { if (! $comment = get_record('data_comments', 'id', $commentid)) {
error('Comment ID is misconfigured'); error('Comment ID is misconfigured');
} }

View file

@ -65,8 +65,8 @@
require_course_login($course, true, $cm); require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/data:managetemplates', $context->id, true); has_capability('mod/data:managetemplates', $context->id, true);
if (!isteacheredit($course->id)){ if (!isteacheredit($course->id)){

View file

@ -57,8 +57,8 @@
} }
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/data:uploadentries', $context->id, true); has_capability('mod/data:uploadentries', $context->id, true);
if (has_capability('mod/data:managetemplates', $context->id)) { if (has_capability('mod/data:managetemplates', $context->id)) {
if (!count_records('data_fields','dataid',$data->id)) { // Brand new database! if (!count_records('data_fields','dataid',$data->id)) { // Brand new database!

View file

@ -557,7 +557,7 @@ function data_add_record($data, $groupid=0){
$record->groupid = $groupid; $record->groupid = $groupid;
$record->timecreated = $record->timemodified = time(); $record->timecreated = $record->timemodified = time();
if (has_capability('mod/data:approve', $context->id)) { if (has_capability('mod/data:approve', $context->id)) {
//if (isteacher($data->course)) { //if (isteacher($data->course)) {
$record->approved = 1; $record->approved = 1;
} else { } else {
$record->approved = 0; $record->approved = 0;
@ -839,8 +839,8 @@ function data_get_coursemodule_info($coursemodule) {
function data_print_template($template, $records, $data, $search='',$page=0, $return=false) { function data_print_template($template, $records, $data, $search='',$page=0, $return=false) {
global $CFG; global $CFG;
$cm = data_get_cm($data); $cm = data_get_cm($data);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
static $fields = NULL; static $fields = NULL;
static $isteacher; static $isteacher;
@ -991,9 +991,9 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order='
function data_print_ratings($data, $record) { function data_print_ratings($data, $record) {
global $USER; global $USER;
$cm = data_get_cm($data); $cm = data_get_cm($data);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$ratingsmenuused = false; $ratingsmenuused = false;
if ($data->ratings and !empty($USER->id)) { if ($data->ratings and !empty($USER->id)) {
if ($ratings->scale = make_grades_menu($data->scale)) { if ($ratings->scale = make_grades_menu($data->scale)) {
@ -1165,10 +1165,10 @@ function data_print_comment($data, $comment, $page=0) {
global $USER, $CFG; global $USER, $CFG;
$cm = data_get_cm($data); $cm = data_get_cm($data);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$stredit = get_string('edit'); $stredit = get_string('edit');
$strdelete = get_string('delete'); $strdelete = get_string('delete');
$user = get_record('user','id',$comment->userid); $user = get_record('user','id',$comment->userid);
@ -1254,13 +1254,13 @@ function data_convert_arrays_to_strings(&$fieldinput) {
// returns the $cm given $data // returns the $cm given $data
function data_get_cm($data) { function data_get_cm($data) {
global $CFG, $course; global $CFG, $course;
$datamod = get_record('modules', 'name', 'data'); $datamod = get_record('modules', 'name', 'data');
$SQL = "select * from {$CFG->prefix}course_modules $SQL = "select * from {$CFG->prefix}course_modules
where course = $course->id and where course = $course->id and
module = $datamod->id and module = $datamod->id and
instance = $data->id"; instance = $data->id";
return get_record_sql($SQL); return get_record_sql($SQL);
} }
?> ?>

View file

@ -92,11 +92,11 @@ function data_restore_mods($mod,$restore) {
$mod->id, $newid); $mod->id, $newid);
//Now check if want to restore user data and do it. //Now check if want to restore user data and do it.
if (function_exists('restore_userdata_selected')) { if (function_exists('restore_userdata_selected')) {
// Moodle 1.6 // Moodle 1.6
$restore_userdata_selected = restore_userdata_selected($restore, 'data', $mod->id); $restore_userdata_selected = restore_userdata_selected($restore, 'data', $mod->id);
} else { } else {
// Moodle 1.5 // Moodle 1.5
$restore_userdata_selected = $restore->mods['data']->userinfo; $restore_userdata_selected = $restore->mods['data']->userinfo;
} }
if ($restore_userdata_selected) { if ($restore_userdata_selected) {
//Restore data_fields first!!! need to hold an array of [oldid]=>newid due to double dependencies //Restore data_fields first!!! need to hold an array of [oldid]=>newid due to double dependencies

View file

@ -30,7 +30,7 @@
} }
$cm = data_get_cm($data); $cm = data_get_cm($data);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$inactive = NULL; $inactive = NULL;
$row = array(); $row = array();
@ -46,7 +46,7 @@
//if (isloggedin() and !isguest()) { //if (isloggedin() and !isguest()) {
if (isloggedin()) { if (isloggedin()) {
if (has_capability('mod/data:writeentry', $context->id)) { // took out participation list here! if (has_capability('mod/data:writeentry', $context->id)) { // took out participation list here!
$addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data'); $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
$row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring, '', true); $row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring, '', true);
} }
if (has_capability('mod/data:managetemplates', $context->id)) { if (has_capability('mod/data:managetemplates', $context->id)) {

View file

@ -56,9 +56,9 @@
} }
require_course_login($course, true, $cm); require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/data:managetemplates', $context->id, true); has_capability('mod/data:managetemplates', $context->id, true);
/* /*
if (!isteacheredit($course->id)){ if (!isteacheredit($course->id)){
error(get_string('noaccess','data')); error(get_string('noaccess','data'));
} }

View file

@ -82,9 +82,9 @@
} }
require_course_login($course, true, $cm); require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/data:readentry', $context->id, true); has_capability('mod/data:readentry', $context->id, true);
/// If it's hidden then it's don't show anything. :) /// If it's hidden then it's don't show anything. :)
if (empty($cm->visible) and !has_capability('mod/data:managetemplates', $context->id)) { if (empty($cm->visible) and !has_capability('mod/data:managetemplates', $context->id)) {

View file

@ -55,7 +55,7 @@
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$strexercises = get_string("modulenameplural", "exercise"); $strexercises = get_string("modulenameplural", "exercise");
$strexercise = get_string("modulename", "exercise"); $strexercise = get_string("modulename", "exercise");

View file

@ -38,7 +38,7 @@
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
// ...log activity... // ...log activity...
add_to_log($course->id, "exercise", "view", "view.php?id=$cm->id", $exercise->id, $cm->id); add_to_log($course->id, "exercise", "view", "view.php?id=$cm->id", $exercise->id, $cm->id);

View file

@ -22,9 +22,9 @@
} }
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:approve', $context->id, true); has_capability('mod/glossary:approve', $context->id, true);
$newentry->id = $eid; $newentry->id = $eid;
$newentry->approved = 1; $newentry->approved = 1;

View file

@ -38,9 +38,9 @@
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (isguest()) { if (isguest()) {
error('Guests are not allowed to post comments', $_SERVER['HTTP_REFERER']); error('Guests are not allowed to post comments', $_SERVER['HTTP_REFERER']);
} }
add_to_log($course->id, 'glossary', 'view', "view.php?id=$cm->id", "$glossary->id",$cm->id); add_to_log($course->id, 'glossary', 'view', "view.php?id=$cm->id", "$glossary->id",$cm->id);

View file

@ -25,7 +25,7 @@
error("Entry is incorrect"); error("Entry is incorrect");
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id, false, $cm); require_login($course->id, false, $cm);

View file

@ -29,8 +29,8 @@
} }
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (isguest()) { if (isguest()) {
error("Guests are not allowed to edit or delete entries", $_SERVER["HTTP_REFERER"]); error("Guests are not allowed to edit or delete entries", $_SERVER["HTTP_REFERER"]);
} }

View file

@ -166,7 +166,7 @@ if ( $confirm ) {
error("Could not update this glossary entry because this concept already exist."); error("Could not update this glossary entry because this concept already exist.");
} }
} else { } else {
$newentry->userid = $USER->id; $newentry->userid = $USER->id;
$newentry->timecreated = $timenow; $newentry->timecreated = $timenow;
$newentry->sourceglossaryid = 0; $newentry->sourceglossaryid = 0;
@ -332,7 +332,7 @@ $tab = GLOSSARY_ADDENTRY_VIEW;
include("tabs.html"); include("tabs.html");
if (!$e) { if (!$e) {
has_capability('glossary_write', $context->id, true); has_capability('glossary_write', $context->id, true);
} }
include("edit.html"); include("edit.html");

View file

@ -44,7 +44,7 @@
require_login($course->id, false); require_login($course->id, false);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:managecategories', $context->id, true); has_capability('mod/glossary:managecategories', $context->id, true);
$strglossaries = get_string("modulenameplural", "glossary"); $strglossaries = get_string("modulenameplural", "glossary");
$strglossary = get_string("modulename", "glossary"); $strglossary = get_string("modulename", "glossary");

View file

@ -22,10 +22,10 @@
error("Course module is incorrect"); error("Course module is incorrect");
} }
require_login($course->id, false); require_login($course->id, false);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:export', $context->id, true); has_capability('mod/glossary:export', $context->id, true);
$strglossaries = get_string("modulenameplural", "glossary"); $strglossaries = get_string("modulenameplural", "glossary");
$strglossary = get_string("modulename", "glossary"); $strglossary = get_string("modulename", "glossary");

View file

@ -29,8 +29,8 @@
$lcase = 'lcase'; $lcase = 'lcase';
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:export', $context->id, true); has_capability('mod/glossary:export', $context->id, true);
if (! $course = get_record('course', 'id', $cm->course)) { if (! $course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured'); error('Course is misconfigured');

View file

@ -21,10 +21,10 @@
} }
require_login($course->id, false); require_login($course->id, false);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:export', $context->id, true); has_capability('mod/glossary:export', $context->id, true);
$filename = clean_filename(strip_tags(format_string($glossary->name,true)).'.xml'); $filename = clean_filename(strip_tags(format_string($glossary->name,true)).'.xml');
$content = glossary_generate_export_file($glossary,$l,$cat); $content = glossary_generate_export_file($glossary,$l,$cat);

View file

@ -18,7 +18,7 @@
if (! $cm = get_coursemodule_from_id('glossary', $id)) { if (! $cm = get_coursemodule_from_id('glossary', $id)) {
error("Course Module ID was incorrect"); error("Course Module ID was incorrect");
} }
if (! $course = get_record("course", "id", $cm->course)) { if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured"); error("Course is misconfigured");
} }
@ -27,10 +27,10 @@
error("Course module is incorrect"); error("Course module is incorrect");
} }
require_login($course->id, false); require_login($course->id, false);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:import', $context->id, true); has_capability('mod/glossary:import', $context->id, true);
if ($dest != 'new' and $dest != 'current') { if ($dest != 'new' and $dest != 'current') {
$dest = 'current'; $dest = 'current';

View file

@ -738,8 +738,8 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') { function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') {
global $USER, $CFG; global $USER, $CFG;
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$output = false; //To decide if we must really return text in "return". Activate when needed only! $output = false; //To decide if we must really return text in "return". Activate when needed only!
$importedentry = ($entry->sourceglossaryid == $glossary->id); $importedentry = ($entry->sourceglossaryid == $glossary->id);
@ -754,15 +754,15 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
$return .= glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook,'html'); $return .= glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook,'html');
if (has_capability('mod/glossary:comment', $context->id)) { if (has_capability('mod/glossary:comment', $context->id)) {
$output = true; $output = true;
$return .= ' <a title="' . get_string('addcomment','glossary') . '" href="comment.php?id='.$cm->id.'&amp;eid='.$entry->id.'"><img src="comment.gif" height="11" width="11" border="0" alt="'.get_string('addcomment','glossary').'" /></a>'; $return .= ' <a title="' . get_string('addcomment','glossary') . '" href="comment.php?id='.$cm->id.'&amp;eid='.$entry->id.'"><img src="comment.gif" height="11" width="11" border="0" alt="'.get_string('addcomment','glossary').'" /></a>';
} }
if (has_capability('mod/glossary:write', $context->id) or (!empty($USER->id) and $glossary->studentcanpost and $entry->userid == $USER->id)) { if (has_capability('mod/glossary:write', $context->id) or (!empty($USER->id) and $glossary->studentcanpost and $entry->userid == $USER->id)) {
// only teachers can export entries so check it out // only teachers can export entries so check it out
if (has_capability('mod/glossary:export', $context->id) and !$ismainglossary and !$importedentry) { if (has_capability('mod/glossary:export', $context->id) and !$ismainglossary and !$importedentry) {
$mainglossary = get_record('glossary','mainglossary',1,'course',$course->id); $mainglossary = get_record('glossary','mainglossary',1,'course',$course->id);
if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
$output = true; $output = true;
$return .= ' <a title="'.get_string('exporttomainglossary','glossary') . '" href="exportentry.php?id='.$cm->id.'&amp;entry='.$entry->id.'&amp;mode='.$mode.'&amp;hook='.$hook.'"><img src="export.gif" height="11" width="11" border="0" alt="'.get_string('exporttomainglossary','glossary').'" /></a>'; $return .= ' <a title="'.get_string('exporttomainglossary','glossary') . '" href="exportentry.php?id='.$cm->id.'&amp;entry='.$entry->id.'&amp;mode='.$mode.'&amp;hook='.$hook.'"><img src="export.gif" height="11" width="11" border="0" alt="'.get_string('exporttomainglossary','glossary').'" /></a>';
@ -1303,9 +1303,9 @@ function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '',
function glossary_print_categories_menu($cm, $glossary, $hook, $category) { function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
global $CFG; global $CFG;
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
echo '<table border="0" width="100%">'; echo '<table border="0" width="100%">';
echo '<tr>'; echo '<tr>';
@ -1563,8 +1563,8 @@ function glossary_print_entry_ratings($course, $entry, $ratings = NULL) {
$glossary = get_record('glossary', 'id', $entry->glossaryid); $glossary = get_record('glossary', 'id', $entry->glossaryid);
$glossarymod = get_record('modules','name','glossary'); $glossarymod = get_record('modules','name','glossary');
$cm = get_record_sql("select * from {$CFG->prefix}course_modules where course = $course->id $cm = get_record_sql("select * from {$CFG->prefix}course_modules where course = $course->id
and module = $glossarymod->id and instance = $glossary->id"); and module = $glossarymod->id and instance = $glossary->id");
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
$ratingsmenuused = false; $ratingsmenuused = false;

View file

@ -21,8 +21,8 @@
$module = get_record("modules","name","glossary"); $module = get_record("modules","name","glossary");
$cm = get_record("course_modules","module",$module->id,"instance",$entry->glossaryid); $cm = get_record("course_modules","module",$module->id,"instance",$entry->glossaryid);
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/glossary:manageentries', $context->id) and $USER->id != $entry->userid) { if (!has_capability('mod/glossary:manageentries', $context->id) and $USER->id != $entry->userid) {
error("You can only look at results for your own entries"); error("You can only look at results for your own entries");
} }

View file

@ -23,8 +23,8 @@
} }
if (has_capability('mod/glossary:import', $context->id)) { if (has_capability('mod/glossary:import', $context->id)) {
$data[GLOSSARY_IMPORT_VIEW]->caption = get_string("importentries", "glossary"); $data[GLOSSARY_IMPORT_VIEW]->caption = get_string("importentries", "glossary");
$data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id"; $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
} }
if (has_capability('mod/glossary:export', $context->id)) { if (has_capability('mod/glossary:export', $context->id)) {
$data[GLOSSARY_EXPORT_VIEW]->caption = get_string("exportentries", "glossary"); $data[GLOSSARY_EXPORT_VIEW]->caption = get_string("exportentries", "glossary");
@ -39,8 +39,8 @@
$data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&amp;mode=cat"; $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&amp;mode=cat";
$data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&amp;mode=author"; $data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&amp;mode=author";
if (has_capability('mod/glossary:approve', $context->id)) { if (has_capability('mod/glossary:approve', $context->id)) {
$data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary"); $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
$data[GLOSSARY_APPROVAL_VIEW]->link = ""; $data[GLOSSARY_APPROVAL_VIEW]->link = "";
$hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0"); $hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0");

View file

@ -44,8 +44,8 @@
error("Must specify glossary ID or course module ID"); error("Must specify glossary ID or course module ID");
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/glossary:view', $context->id, true); // kill the page if user can't even read has_capability('mod/glossary:view', $context->id, true); // kill the page if user can't even read
if ($CFG->forcelogin) { if ($CFG->forcelogin) {
require_login(); require_login();

File diff suppressed because it is too large Load diff

View file

@ -2,24 +2,24 @@
<INPUT type="hidden" name="sesskey" value="<?PHP print isset($USER->sesskey) ? $USER->sesskey : '' ?>"> <INPUT type="hidden" name="sesskey" value="<?PHP print isset($USER->sesskey) ? $USER->sesskey : '' ?>">
<TABLE cellpadding="9" cellspacing="0"> <TABLE cellpadding="9" cellspacing="0">
<TR valign="top"> <TR valign="top">
<TD align="right"><P>hotpot_showtimes:</TD> <TD align="right"><P>hotpot_showtimes:</TD>
<TD><?PHP <TD><?PHP
unset($choices); unset($choices);
$choices["0"] = get_string("no"); $choices["0"] = get_string("no");
$choices["1"] = get_string("yes"); $choices["1"] = get_string("yes");
choose_from_menu ($choices, "hotpot_showtimes", $CFG->hotpot_showtimes, ""); choose_from_menu ($choices, "hotpot_showtimes", $CFG->hotpot_showtimes, "");
?></TD> ?></TD>
<TD><?PHP print_string("configshowtimes", "hotpot") ?></TD> <TD><?PHP print_string("configshowtimes", "hotpot") ?></TD>
</TR> </TR>
<TR valign=top> <TR valign=top>
<TD align="right"><P>hotpot_excelencodings:</TD> <TD align="right"><P>hotpot_excelencodings:</TD>
<TD><INPUT name=hotpot_excelencodings type=text size=30 value="<?PHP p($CFG->hotpot_excelencodings) ?>"></TD> <TD><INPUT name=hotpot_excelencodings type=text size=30 value="<?PHP p($CFG->hotpot_excelencodings) ?>"></TD>
<TD><?PHP print_string("configexcelencodings", "hotpot") ?></TD> <TD><?PHP print_string("configexcelencodings", "hotpot") ?></TD>
</TR> </TR>
<TR> <TR>
<TD colspan="3" align="center"><INPUT type="submit" value="<?PHP print_string("savechanges") ?>"></TD> <TD colspan="3" align="center"><INPUT type="submit" value="<?PHP print_string("savechanges") ?>"></TD>
</TR> </TR>
</TABLE> </TABLE>
</FORM> </FORM>

View file

@ -1,43 +1,43 @@
<?PHP <?PHP
function hotpot_upgrade($oldversion) { function hotpot_upgrade($oldversion) {
global $CFG; global $CFG;
$ok = true; $ok = true;
if ($oldversion < 2004021400) { if ($oldversion < 2004021400) {
execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `starttime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`"); execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `starttime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `endtime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`"); execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `endtime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`");
} }
// set path to update functions // set path to update functions
$update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php"; $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php";
// update from HotPot v1 to HotPot v2 // update from HotPot v1 to HotPot v2
if ($oldversion < 2005031400) { if ($oldversion < 2005031400) {
require_once $update_to_v2; require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_from_v1(); $ok = $ok && hotpot_update_to_v2_from_v1();
} }
if ($oldversion < 2005090700) { if ($oldversion < 2005090700) {
require_once $update_to_v2; require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1(); $ok = $ok && hotpot_update_to_v2_1();
} }
if ($oldversion > 2005031419 && $oldversion < 2005090702) { if ($oldversion > 2005031419 && $oldversion < 2005090702) {
// update to from HotPot v2.1.0 or v2.1.1 // update to from HotPot v2.1.0 or v2.1.1
require_once $update_to_v2; require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_2(); $ok = $ok && hotpot_update_to_v2_1_2();
} }
if ($oldversion < 2006042103) { if ($oldversion < 2006042103) {
require_once $update_to_v2; require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_16(); $ok = $ok && hotpot_update_to_v2_1_16();
} }
if ($oldversion < 2006042601) { if ($oldversion < 2006042601) {
require_once $update_to_v2; require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_17(); $ok = $ok && hotpot_update_to_v2_1_17();
} }
if ($oldversion < 2006042803) { if ($oldversion < 2006042803) {
require_once $update_to_v2; require_once $update_to_v2;
$ok = $ok && hotpot_update_to_v2_1_18(); $ok = $ok && hotpot_update_to_v2_1_18();
} }
return $ok; return $ok;
} }
?> ?>

File diff suppressed because it is too large Load diff

View file

@ -2,420 +2,420 @@
// This page lists all the instances of hotpot in a particular course // This page lists all the instances of hotpot in a particular course
require_once("../../config.php"); require_once("../../config.php");
require_once("../../course/lib.php"); require_once("../../course/lib.php");
require_once("lib.php"); require_once("lib.php");
$id = required_param("id"); // course $id = required_param("id"); // course
if (! $course = get_record("course", "id", $id)) { if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect"); error("Course ID is incorrect");
} }
require_login($course->id); require_login($course->id);
add_to_log($course->id, "hotpot", "view all", "index.php?id=$course->id", ""); add_to_log($course->id, "hotpot", "view all", "index.php?id=$course->id", "");
// Moodle 1.4+ requires sesskey to be passed in forms // Moodle 1.4+ requires sesskey to be passed in forms
if (isset($USER->sesskey)) { if (isset($USER->sesskey)) {
$sesskey = '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'; $sesskey = '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
} else { } else {
$sesskey = ''; $sesskey = '';
} }
// get message strings for titles // get message strings for titles
$strmodulenameplural = get_string("modulenameplural", "hotpot"); $strmodulenameplural = get_string("modulenameplural", "hotpot");
$strmodulename = get_string("modulename", "hotpot"); $strmodulename = get_string("modulename", "hotpot");
// string translation array for single and double quotes // string translation array for single and double quotes
$quotes = array("'"=>"\'", '"'=>'&quot;'); $quotes = array("'"=>"\'", '"'=>'&quot;');
// Print the header // Print the header
$title = "$course->shortname: $strmodulenameplural"; $title = "$course->shortname: $strmodulenameplural";
$heading = "$course->fullname"; $heading = "$course->fullname";
$navigation = "$strmodulenameplural"; $navigation = "$strmodulenameplural";
if ($course->category) { if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> $navigation"; $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> $navigation";
} }
print_header($title, $heading, $navigation, "", "", true, "", navmenu($course)); print_header($title, $heading, $navigation, "", "", true, "", navmenu($course));
$next_url = "$CFG->wwwroot/course/view.php?id=$course->id"; $next_url = "$CFG->wwwroot/course/view.php?id=$course->id";
// get display section, if any // get display section, if any
$section = optional_param('section', 0); $section = optional_param('section', 0);
if ($section) { if ($section) {
$displaysection = course_set_display($course->id, $section); $displaysection = course_set_display($course->id, $section);
} else { } else {
if (isset($USER->display[$course->id])) { if (isset($USER->display[$course->id])) {
$displaysection = $USER->display[$course->id]; $displaysection = $USER->display[$course->id];
} else { } else {
$displaysection = 0; $displaysection = 0;
} }
} }
// Get all instances of this module // Get all instances of this module
if (!$hotpots = hotpot_get_all_instances_in_course("hotpot", $course)) { if (!$hotpots = hotpot_get_all_instances_in_course("hotpot", $course)) {
$hotpots = array(); $hotpots = array();
} }
// if necessary, remove hotpots that are not in section0 or this $USER's display section // if necessary, remove hotpots that are not in section0 or this $USER's display section
if ($displaysection) { if ($displaysection) {
foreach ($hotpots as $coursemodule=>$hotpot) { foreach ($hotpots as $coursemodule=>$hotpot) {
if ($hotpot->section!=0 && $hotpot->section!=$displaysection) { if ($hotpot->section!=0 && $hotpot->section!=$displaysection) {
unset($hotpots[$coursemodule]); unset($hotpots[$coursemodule]);
} }
} }
} }
if (empty($hotpots)) { if (empty($hotpots)) {
notice("There are no $strmodulenameplural", $next_url); notice("There are no $strmodulenameplural", $next_url);
exit; exit;
} }
// get list of hotpot ids // get list of hotpot ids
$hotpotids = array(); $hotpotids = array();
foreach ($hotpots as $cmid=>$hotpot) { foreach ($hotpots as $cmid=>$hotpot) {
$hotpotids[] = $hotpot->id; $hotpotids[] = $hotpot->id;
} }
$hotpotids = implode(',', $hotpotids); $hotpotids = implode(',', $hotpotids);
if (isadmin()) { if (isadmin()) {
// get regrade settings, if any // get regrade settings, if any
$regrade = optional_param("regrade"); $regrade = optional_param("regrade");
$confirm = optional_param("confirm"); $confirm = optional_param("confirm");
// check regrade is valid // check regrade is valid
unset($regrade_cmid); unset($regrade_cmid);
if (isset($regrade)) { if (isset($regrade)) {
foreach ($hotpots as $cmid=>$hotpot) { foreach ($hotpots as $cmid=>$hotpot) {
$found = false; $found = false;
if ($hotpot->id==$regrade) { if ($hotpot->id==$regrade) {
$regrade_cmid = $cmid; $regrade_cmid = $cmid;
} }
} }
} }
// regrade, if necessary // regrade, if necessary
if (isset($regrade_cmid)) { if (isset($regrade_cmid)) {
if (empty($confirm)) { if (empty($confirm)) {
$strregradecheck = get_string('regradecheck', 'hotpot', $hotpots[$regrade_cmid]->name); $strregradecheck = get_string('regradecheck', 'hotpot', $hotpots[$regrade_cmid]->name);
print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox"); print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox");
print_heading($strregradecheck); print_heading($strregradecheck);
print '' print ''
. '<table border="0"><tr><td>' . '<table border="0"><tr><td>'
. '<form target="_parent" method="post" action="'.$ME.'">' . '<form target="_parent" method="post" action="'.$ME.'">'
. '<input type="hidden" name="id" value="'.$course->id.'">' . '<input type="hidden" name="id" value="'.$course->id.'">'
. '<input type="hidden" name="regrade" value="'.$regrade.'" />' . '<input type="hidden" name="regrade" value="'.$regrade.'" />'
. '<input type="hidden" name="confirm" value="1" />' . '<input type="hidden" name="confirm" value="1" />'
. $sesskey . $sesskey
. '<input type="submit" value="'.get_string("yes").'" />' . '<input type="submit" value="'.get_string("yes").'" />'
. '</form>' . '</form>'
. '</td><td> &nbsp; </td><td>' . '</td><td> &nbsp; </td><td>'
. '<form target="_parent" method="post" action="'.$ME.'">' . '<form target="_parent" method="post" action="'.$ME.'">'
. '<input type="hidden" name="id" value="'.$course->id.'">' . '<input type="hidden" name="id" value="'.$course->id.'">'
. $sesskey . $sesskey
. '<input type="submit" value="'.get_string("no").'" />' . '<input type="submit" value="'.get_string("no").'" />'
. '</form>' . '</form>'
. '</td></tr></table>' . '</td></tr></table>'
; ;
print_simple_box_end(); print_simple_box_end();
print_footer($course); print_footer($course);
exit; exit;
} else { // regrade has been confirmed, so proceed } else { // regrade has been confirmed, so proceed
if ($regrade=='all') { if ($regrade=='all') {
$select = "hotpot IN ($hotpotids)"; $select = "hotpot IN ($hotpotids)";
} else { } else {
$select = "hotpot=$regrade"; $select = "hotpot=$regrade";
} }
$questionids = array(); $questionids = array();
if ($questions = get_records_select("hotpot_questions", $select)) { if ($questions = get_records_select("hotpot_questions", $select)) {
$questionids = array_keys($questions); $questionids = array_keys($questions);
} }
$questionids = implode(',', $questionids); $questionids = implode(',', $questionids);
if ($questionids) { if ($questionids) {
hotpot_delete_and_notify('hotpot_questions', "id IN ($questionids)", get_string('question', 'quiz')); hotpot_delete_and_notify('hotpot_questions', "id IN ($questionids)", get_string('question', 'quiz'));
hotpot_delete_and_notify('hotpot_responses', "question IN ($questionids)", get_string('answer', 'quiz')); hotpot_delete_and_notify('hotpot_responses', "question IN ($questionids)", get_string('answer', 'quiz'));
} }
if ($attempts = get_records_select('hotpot_attempts', $select)) { if ($attempts = get_records_select('hotpot_attempts', $select)) {
// start counter and timer // start counter and timer
$start = microtime(); $start = microtime();
$count = 0; $count = 0;
// use while loop instead of foreach loop // use while loop instead of foreach loop
// to allow the possibility of splitting a regrade // to allow the possibility of splitting a regrade
// and so avoid "maximum script time exceeded" errors // and so avoid "maximum script time exceeded" errors
$attemptids = array_keys($attempts); $attemptids = array_keys($attempts);
$i_max = count($attemptids); $i_max = count($attemptids);
$i = 0; $i = 0;
while ($i<$i_max) { while ($i<$i_max) {
$attemptid = $attemptids[$i]; $attemptid = $attemptids[$i];
$attempt =&$attempts[$attemptid]; $attempt =&$attempts[$attemptid];
$attempt->details = get_field('hotpot_details', 'details', 'attempt', $attemptid); $attempt->details = get_field('hotpot_details', 'details', 'attempt', $attemptid);
if ($attempt->details) { if ($attempt->details) {
hotpot_add_attempt_details($attempt); hotpot_add_attempt_details($attempt);
if (! update_record('hotpot_attempts', $attempt)) { if (! update_record('hotpot_attempts', $attempt)) {
error("Could not update attempt record: ".$db->ErrorMsg(), $next_url); error("Could not update attempt record: ".$db->ErrorMsg(), $next_url);
} }
} }
$count++; $count++;
$i++; $i++;
} }
if ($count) { if ($count) {
notify(get_string('added', 'moodle', "$count x ".get_string('attempts', 'quiz'))); notify(get_string('added', 'moodle', "$count x ".get_string('attempts', 'quiz')));
} }
$msg = get_string('regradecomplete', 'quiz'); $msg = get_string('regradecomplete', 'quiz');
if (!empty($CFG->hotpot_showtimes)) { if (!empty($CFG->hotpot_showtimes)) {
$duration = format_time(sprintf("%0.2f", microtime_diff($start, microtime()))); $duration = format_time(sprintf("%0.2f", microtime_diff($start, microtime())));
$msg .= " ($duration)"; $msg .= " ($duration)";
} }
notify($msg); notify($msg);
} }
} }
} // end regrade } // end regrade
//print '<center><form action="'.$ME.'" method="post">'; //print '<center><form action="'.$ME.'" method="post">';
//print '<input type="hidden" name="id" value="'.$course->id.'">'; //print '<input type="hidden" name="id" value="'.$course->id.'">';
//print '<input type="submit" name="regrade" value="'.get_string('regrade', 'quiz').'">'; //print '<input type="submit" name="regrade" value="'.get_string('regrade', 'quiz').'">';
//print '</form></center>'."\n"; //print '</form></center>'."\n";
// get duplicate hotpot-name questions // get duplicate hotpot-name questions
// - JMatch LHS is longer than 255 bytes // - JMatch LHS is longer than 255 bytes
// - JQuiz question text is longer than 255 bytes // - JQuiz question text is longer than 255 bytes
// - other unidentified situations ?!? // - other unidentified situations ?!?
$field = ''; $field = '';
$questions = false; $questions = false;
$regradehotpots = array(); $regradehotpots = array();
switch (strtolower($CFG->dbtype)) { switch (strtolower($CFG->dbtype)) {
case 'mysql' : case 'mysql' :
$field = "CONCAT(hotpot, '_', name)"; $field = "CONCAT(hotpot, '_', name)";
break; break;
case 'postgres7' : case 'postgres7' :
$field = "hotpot||'_'||name"; $field = "hotpot||'_'||name";
break; break;
} }
if ($field) { if ($field) {
$questions = get_records_sql(" $questions = get_records_sql("
SELECT $field, COUNT(*), hotpot, name SELECT $field, COUNT(*), hotpot, name
FROM {$CFG->prefix}hotpot_questions FROM {$CFG->prefix}hotpot_questions
WHERE hotpot IN ($hotpotids) WHERE hotpot IN ($hotpotids)
GROUP BY hotpot, name GROUP BY hotpot, name
HAVING COUNT(*) >1 HAVING COUNT(*) >1
"); ");
} }
if ($questions) { if ($questions) {
foreach ($questions as $question) { foreach ($questions as $question) {
$regradehotpots[] = $question->hotpot; $regradehotpots[] = $question->hotpot;
} }
$regradehotpots = array_unique($regradehotpots); $regradehotpots = array_unique($regradehotpots);
sort($regradehotpots); sort($regradehotpots);
} }
} }
// start timer // start timer
$start = microtime(); $start = microtime();
// get total number of attempts, users and details for these hotpots // get total number of attempts, users and details for these hotpots
$tables = "{$CFG->prefix}hotpot_attempts AS a"; $tables = "{$CFG->prefix}hotpot_attempts AS a";
$fields = " $fields = "
a.hotpot AS hotpot, a.hotpot AS hotpot,
COUNT(DISTINCT a.clickreportid) AS attemptcount, COUNT(DISTINCT a.clickreportid) AS attemptcount,
COUNT(DISTINCT a.userid) AS usercount, COUNT(DISTINCT a.userid) AS usercount,
MAX(a.score) AS maxscore MAX(a.score) AS maxscore
"; ";
$select = "a.hotpot IN ($hotpotids)"; $select = "a.hotpot IN ($hotpotids)";
if (isteacher($course->id)) { if (isteacher($course->id)) {
// do nothing (=get all users) // do nothing (=get all users)
} else { } else {
// restrict results to this user only // restrict results to this user only
$select .= " AND a.userid='$USER->id'"; $select .= " AND a.userid='$USER->id'";
} }
$usejoin = 1; $usejoin = 1;
if (isadmin() && $usejoin) { if (isadmin() && $usejoin) {
// join attempts table and details table // join attempts table and details table
$tables .= ",{$CFG->prefix}hotpot_details AS d"; $tables .= ",{$CFG->prefix}hotpot_details AS d";
$fields .= ',COUNT(DISTINCT d.id) AS detailcount'; $fields .= ',COUNT(DISTINCT d.id) AS detailcount';
$select .= " AND a.id=d.attempt"; $select .= " AND a.id=d.attempt";
// this may take about twice as long as getting the gradecounts separately :-( // this may take about twice as long as getting the gradecounts separately :-(
// so this operation could be done after getting the $totals from the attempts table // so this operation could be done after getting the $totals from the attempts table
} }
$totals = get_records_sql("SELECT $fields FROM $tables WHERE $select GROUP BY a.hotpot"); $totals = get_records_sql("SELECT $fields FROM $tables WHERE $select GROUP BY a.hotpot");
if (isadmin() && empty($usejoin)) { if (isadmin() && empty($usejoin)) {
foreach ($hotpots as $hotpot) { foreach ($hotpots as $hotpot) {
$totals[$hotpot->id]->detailcount = 0; $totals[$hotpot->id]->detailcount = 0;
if ($ids = get_records('hotpot_attempts', 'hotpot', $hotpot->id)) { if ($ids = get_records('hotpot_attempts', 'hotpot', $hotpot->id)) {
$ids = join(',', array_keys($ids)); $ids = join(',', array_keys($ids));
$totals[$hotpot->id]->detailcount = count_records_select('hotpot_details', "attempt IN ($ids)"); $totals[$hotpot->id]->detailcount = count_records_select('hotpot_details', "attempt IN ($ids)");
} }
} }
} }
// message strings for main table // message strings for main table
$strusers = get_string('users'); $strusers = get_string('users');
$strupdate = get_string('update'); $strupdate = get_string('update');
$strregrade = get_string('regrade', 'hotpot'); $strregrade = get_string('regrade', 'hotpot');
$strneverclosed = get_string('neverclosed', 'hotpot'); $strneverclosed = get_string('neverclosed', 'hotpot');
$strregraderequired = get_string('regraderequired', 'hotpot'); $strregraderequired = get_string('regraderequired', 'hotpot');
// column headings and attributes // column headings and attributes
$table->head = array(); $table->head = array();
$table->align = array(); $table->align = array();
if (!empty($CFG->hotpot_showtimes)) { if (!empty($CFG->hotpot_showtimes)) {
print '<H3>'.sprintf("%0.3f", microtime_diff($start, microtime())).' secs'."</H3>\n"; print '<H3>'.sprintf("%0.3f", microtime_diff($start, microtime())).' secs'."</H3>\n";
} }
switch ($course->format) { switch ($course->format) {
case 'weeks' : case 'weeks' :
$title = get_string("week"); $title = get_string("week");
break; break;
case 'topics' : case 'topics' :
$title = get_string("topic"); $title = get_string("topic");
break; break;
default : default :
$title = ''; $title = '';
break; break;
} }
if ($title) { if ($title) {
array_push($table->head, $title); array_push($table->head, $title);
array_push($table->align, "center"); array_push($table->align, "center");
} }
if (isteacheredit($course->id)) { if (isteacheredit($course->id)) {
array_push($table->head, $strupdate); array_push($table->head, $strupdate);
array_push($table->align, "center"); array_push($table->align, "center");
} }
array_push($table->head, array_push($table->head,
get_string("name"), get_string("name"),
get_string("quizcloses", "quiz"), get_string("quizcloses", "quiz"),
get_string("bestgrade", "quiz"), get_string("bestgrade", "quiz"),
get_string("attempts", "quiz") get_string("attempts", "quiz")
); );
array_push($table->align, array_push($table->align,
"left", "left", "center", "left" "left", "left", "center", "left"
); );
if (isadmin()) { if (isadmin()) {
array_push($table->head, $strregrade); array_push($table->head, $strregrade);
array_push($table->align, "center"); array_push($table->align, "center");
} }
$currentsection = -1; $currentsection = -1;
foreach ($hotpots as $hotpot) { foreach ($hotpots as $hotpot) {
$printsection = ""; $printsection = "";
if ($hotpot->section != $currentsection) { if ($hotpot->section != $currentsection) {
if ($hotpot->section) { if ($hotpot->section) {
$printsection = $hotpot->section; $printsection = $hotpot->section;
if ($course->format=='weeks' || $course->format=='topics') { if ($course->format=='weeks' || $course->format=='topics') {
// Show the zoom boxes // Show the zoom boxes
if ($displaysection==$hotpot->section) { if ($displaysection==$hotpot->section) {
$strshowall = get_string('showall'.$course->format); $strshowall = get_string('showall'.$course->format);
$printsection .= '<br /><a href="index.php?id='.$course->id.'&section=all" title="'.$strshowall.'"><img src="'.$CFG->pixpath.'/i/all.gif" height=25 width=16 border=0></a><br />'; $printsection .= '<br /><a href="index.php?id='.$course->id.'&section=all" title="'.$strshowall.'"><img src="'.$CFG->pixpath.'/i/all.gif" height=25 width=16 border=0></a><br />';
} else { } else {
$strshowone = get_string('showonly'.preg_replace('|s$|', '', $course->format, 1), '', $hotpot->section); $strshowone = get_string('showonly'.preg_replace('|s$|', '', $course->format, 1), '', $hotpot->section);
$printsection .= '<br /><a href="index.php?id='.$course->id.'&section='.$hotpot->section.'" title="'.$strshowone.'"><img src="'.$CFG->pixpath.'/i/one.gif" height=16 width=16 border=0></a><br />'; $printsection .= '<br /><a href="index.php?id='.$course->id.'&section='.$hotpot->section.'" title="'.$strshowone.'"><img src="'.$CFG->pixpath.'/i/one.gif" height=16 width=16 border=0></a><br />';
} }
} }
} }
if ($currentsection>=0) { if ($currentsection>=0) {
$table->data[] = 'hr'; $table->data[] = 'hr';
} }
$currentsection = $hotpot->section; $currentsection = $hotpot->section;
} }
$class = ($hotpot->visible) ? '' : 'class="dimmed" '; $class = ($hotpot->visible) ? '' : 'class="dimmed" ';
$quizname = '<a '.$class.'href="view.php?id='.$hotpot->coursemodule.'">'.$hotpot->name.'</A>'; $quizname = '<a '.$class.'href="view.php?id='.$hotpot->coursemodule.'">'.$hotpot->name.'</A>';
$quizclose = empty($hotpot->timeclose) ? $strneverclosed : userdate($hotpot->timeclose); $quizclose = empty($hotpot->timeclose) ? $strneverclosed : userdate($hotpot->timeclose);
// are there any totals for this hotpot? // are there any totals for this hotpot?
if (empty($totals[$hotpot->id]->attemptcount)) { if (empty($totals[$hotpot->id]->attemptcount)) {
$report = "&nbsp;"; $report = "&nbsp;";
$bestscore = "&nbsp;"; $bestscore = "&nbsp;";
} else { } else {
// report number of attempts and users // report number of attempts and users
$report = get_string("viewallreports","quiz", $totals[$hotpot->id]->attemptcount); $report = get_string("viewallreports","quiz", $totals[$hotpot->id]->attemptcount);
if (isteacher($course->id)) { if (isteacher($course->id)) {
$report .= " (".$totals[$hotpot->id]->usercount." $strusers)"; $report .= " (".$totals[$hotpot->id]->usercount." $strusers)";
} }
$report = '<a href="report.php?hp='.$hotpot->id.'">'.$report.'</a>'; $report = '<a href="report.php?hp='.$hotpot->id.'">'.$report.'</a>';
// get best score // get best score
if (is_numeric($totals[$hotpot->id]->maxscore)) { if (is_numeric($totals[$hotpot->id]->maxscore)) {
$bestscore = $totals[$hotpot->id]->maxscore." / $hotpot->grade"; $bestscore = $totals[$hotpot->id]->maxscore." / $hotpot->grade";
} else { } else {
$bestscore = "&nbsp;"; $bestscore = "&nbsp;";
} }
} }
if (isadmin()) { if (isadmin()) {
if (in_array($hotpot->id, $regradehotpots)) { if (in_array($hotpot->id, $regradehotpots)) {
$report .= ' <font color="red">'.$strregraderequired.'</font>'; $report .= ' <font color="red">'.$strregraderequired.'</font>';
} }
} }
$data = array (); $data = array ();
if ($course->format=="weeks" || $course->format=="topics") { if ($course->format=="weeks" || $course->format=="topics") {
array_push($data, $printsection); array_push($data, $printsection);
} }
if (isteacheredit($course->id)) { if (isteacheredit($course->id)) {
$updatebutton = '' $updatebutton = ''
. '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/course/mod.php">' . '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/course/mod.php">'
. '<input type="hidden" name="update" value="'.$hotpot->coursemodule.'" />' . '<input type="hidden" name="update" value="'.$hotpot->coursemodule.'" />'
. $sesskey . $sesskey
. '<input type="submit" value="'.$strupdate.'" />' . '<input type="submit" value="'.$strupdate.'" />'
. '</form>' . '</form>'
; ;
array_push($data, $updatebutton); array_push($data, $updatebutton);
} }
array_push($data, $quizname, $quizclose, $bestscore, $report); array_push($data, $quizname, $quizclose, $bestscore, $report);
if (isadmin()) { if (isadmin()) {
if (empty($totals[$hotpot->id]->detailcount)) { if (empty($totals[$hotpot->id]->detailcount)) {
// no details records for this hotpot, so disable regrade // no details records for this hotpot, so disable regrade
$regradebutton = '&nbsp;'; $regradebutton = '&nbsp;';
} else { } else {
$strregradecheck = get_string('regradecheck', 'hotpot', strtr($hotpot->name, $quotes)); $strregradecheck = get_string('regradecheck', 'hotpot', strtr($hotpot->name, $quotes));
$regradebutton = '' $regradebutton = ''
. '<form target="_parent" method="post" action="'.$ME.'" onsubmit="var x=window.confirm('."'$strregradecheck'".');this.confirm.value=x;return x;">' . '<form target="_parent" method="post" action="'.$ME.'" onsubmit="var x=window.confirm('."'$strregradecheck'".');this.confirm.value=x;return x;">'
. '<input type="hidden" name="id" value="'.$course->id.'">' . '<input type="hidden" name="id" value="'.$course->id.'">'
. '<input type="hidden" name="regrade" value="'.$hotpot->id.'" />' . '<input type="hidden" name="regrade" value="'.$hotpot->id.'" />'
. '<input type="hidden" name="confirm" value="" />' . '<input type="hidden" name="confirm" value="" />'
. $sesskey . $sesskey
. '<input type="submit" value="'.$strregrade.'" />' . '<input type="submit" value="'.$strregrade.'" />'
. '</form>' . '</form>'
; ;
} }
array_push($data, $regradebutton); array_push($data, $regradebutton);
} }
$table->data[] = $data; $table->data[] = $data;
} }
echo "<br />"; echo "<br />";
print_table($table); print_table($table);
// Finish the page // Finish the page
print_footer($course); print_footer($course);
?> ?>

File diff suppressed because it is too large Load diff

View file

@ -11,309 +11,309 @@ set_form_fields($form);
// commonly used array of <select> options // commonly used array of <select> options
$yes_no_options = array( $yes_no_options = array(
HOTPOT_NO => get_string("no"), HOTPOT_NO => get_string("no"),
HOTPOT_YES => get_string("yes") HOTPOT_YES => get_string("yes")
); );
$text_source_options = array( $text_source_options = array(
HOTPOT_TEXTSOURCE_QUIZ => get_string("textsourcequiz", "hotpot"), HOTPOT_TEXTSOURCE_QUIZ => get_string("textsourcequiz", "hotpot"),
HOTPOT_TEXTSOURCE_FILENAME => get_string("textsourcefilename", "hotpot"), HOTPOT_TEXTSOURCE_FILENAME => get_string("textsourcefilename", "hotpot"),
HOTPOT_TEXTSOURCE_FILEPATH => get_string("textsourcefilepath", "hotpot"), HOTPOT_TEXTSOURCE_FILEPATH => get_string("textsourcefilepath", "hotpot"),
HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot") HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot")
); );
?> ?>
<center> <center>
<form name="form" method="post" action="mod.php"> <form name="form" method="post" action="mod.php">
<table cellpadding="5"> <table cellpadding="5">
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("name") ?>:</b></td> <td align="right"><b><?PHP print_string("name") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
if ($form->mode=='add') { if ($form->mode=='add') {
choose_from_menu($text_source_options, "namesource", "$form->namesource", ""); choose_from_menu($text_source_options, "namesource", "$form->namesource", "");
} else { } else {
print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">'; print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
} }
print '<span id="nameSPAN">'; print '<span id="nameSPAN">';
print '<input type="text" name="name" size=40 value="'.$form->name.'">'; print '<input type="text" name="name" size=40 value="'.$form->name.'">';
print '</span>'; print '</span>';
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"> <td align="right">
<b><?PHP <b><?PHP
print_string("summary") print_string("summary")
?>:</b><br /> ?>:</b><br />
<FONT size="1"><?PHP <FONT size="1"><?PHP
helpbutton("summary", get_string("summary"), "resource", true, true); helpbutton("summary", get_string("summary"), "resource", true, true);
print '<br />'; print '<br />';
helpbutton("writing", get_string("helpwriting"), "moodle", true, true); helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
print '<br />'; print '<br />';
if (isset($usehtmleditor) && $usehtmleditor) { if (isset($usehtmleditor) && $usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true); helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
print '<br />'; print '<br />';
} else { } else {
helpbutton("text", get_string("helptext"), "moodle", true, true); helpbutton("text", get_string("helptext"), "moodle", true, true);
print '<br />'; print '<br />';
emoticonhelpbutton("form", "description"); emoticonhelpbutton("form", "description");
print '<br />'; print '<br />';
} }
?></FONT> ?></FONT>
</td> </td>
<td align="left"><?PHP <td align="left"><?PHP
if ($form->mode=='add') { if ($form->mode=='add') {
choose_from_menu($text_source_options, "summarysource", "$form->summarysource", ""); choose_from_menu($text_source_options, "summarysource", "$form->summarysource", "");
} else { } else {
print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">'; print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'">';
} }
print '<span id="summarySPAN">'; print '<span id="summarySPAN">';
if (function_exists("print_textarea") && isset($usehtmleditor)) { if (function_exists("print_textarea") && isset($usehtmleditor)) {
print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary); print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary);
} else { } else {
// Moodle 1.1.1 (original size was rows="5" cols="50") // Moodle 1.1.1 (original size was rows="5" cols="50")
print '<textarea name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary.'</textarea>'; print '<textarea name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary.'</textarea>';
} }
print '</span>'; print '</span>';
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("quizopen", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("quizopen", "quiz") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
$options = array( $options = array(
HOTPOT_NO => get_string("alwaysopen", "hotpot"), HOTPOT_NO => get_string("alwaysopen", "hotpot"),
HOTPOT_YES => get_string("specifictime", "hotpot") HOTPOT_YES => get_string("specifictime", "hotpot")
); );
choose_from_menu($options, "enabletimeopen", "$form->enabletimeopen", ""); choose_from_menu($options, "enabletimeopen", "$form->enabletimeopen", "");
print '<span id="timeopenSPAN">'; print '<span id="timeopenSPAN">';
print ' &nbsp; '; print ' &nbsp; ';
if (!$form->timeopen && $course->format == "weeks") { if (!$form->timeopen && $course->format == "weeks") {
$form->timeopen= $course->startdate + (($form->section - 1) * 608400); $form->timeopen= $course->startdate + (($form->section - 1) * 608400);
} }
print_date_selector("openday", "openmonth", "openyear", $form->timeopen); print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
print ' - '; print ' - ';
print_time_selector("openhour", "openminute", $form->timeopen); print_time_selector("openhour", "openminute", $form->timeopen);
helpbutton("timeopen", get_string("quizopen","quiz"), "quiz"); helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
print '</span>'; print '</span>';
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("quizclose", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("quizclose", "quiz") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
$options = array( $options = array(
HOTPOT_NO => get_string("neverclosed", "hotpot"), HOTPOT_NO => get_string("neverclosed", "hotpot"),
HOTPOT_YES => get_string("specifictime", "hotpot") HOTPOT_YES => get_string("specifictime", "hotpot")
); );
choose_from_menu($options, "enabletimeclose", "$form->enabletimeclose", ""); choose_from_menu($options, "enabletimeclose", "$form->enabletimeclose", "");
print '<span id="timecloseSPAN">'; print '<span id="timecloseSPAN">';
print ' &nbsp; '; print ' &nbsp; ';
if (!$form->timeclose && $course->format == "weeks") { if (!$form->timeclose && $course->format == "weeks") {
$form->timeclose= $course->startdate + (($form->section) * 608400); $form->timeclose= $course->startdate + (($form->section) * 608400);
} }
print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose); print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
print ' - '; print ' - ';
print_time_selector("closehour", "closeminute", $form->timeclose); print_time_selector("closehour", "closeminute", $form->timeclose);
helpbutton("timeopen", get_string("quizclose","quiz"), "quiz"); helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
print '</span>'; print '</span>';
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right" nowrap> <td align="right" nowrap>
<b><?PHP print get_string("location","hotpot") ?>:</b> <b><?PHP print get_string("location","hotpot") ?>:</b>
</td> </td>
<td align="left"><?PHP <td align="left"><?PHP
if (isadmin()) { if (isadmin()) {
$site = get_site(); $site = get_site();
if ($course->id==$site->id) { if ($course->id==$site->id) {
$id = $site->id; $id = $site->id;
$location = HOTPOT_LOCATION_SITEFILES; $location = HOTPOT_LOCATION_SITEFILES;
} else { } else {
$id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'"; $id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'";
$location = ''; $location = '';
} }
} else { // ordinary teacher or content creator } else { // ordinary teacher or content creator
$id = $course->id; $id = $course->id;
$location = HOTPOT_LOCATION_COURSEFILES; $location = HOTPOT_LOCATION_COURSEFILES;
} }
if (array_key_exists($location, $HOTPOT_LOCATION)) { if (array_key_exists($location, $HOTPOT_LOCATION)) {
print '<input type="hidden" name="location" value="'.$location.'" />'; print '<input type="hidden" name="location" value="'.$location.'" />';
print '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> &nbsp; '; print '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> &nbsp; ';
} else { // admin can select from "site" or "course" files } else { // admin can select from "site" or "course" files
choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", ""); choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", "");
} }
if (function_exists("button_to_popup_window")) { if (function_exists("button_to_popup_window")) {
// use javascript to extract wdir from the reference field // use javascript to extract wdir from the reference field
$wdir = "'+getDir(getObjValue(this.form.reference))+'"; $wdir = "'+getDir(getObjValue(this.form.reference))+'";
// set button url depending on Moodle version // set button url depending on Moodle version
if ($CFG->version < 2004083125) { // version may need refining if ($CFG->version < 2004083125) { // version may need refining
// up to and including Moodle 1.4.1 // up to and including Moodle 1.4.1
$url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir"; $url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir";
} else { } else {
// Moodle 1.4.2 and beyond // Moodle 1.4.2 and beyond
$url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference"; $url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference";
} }
$strchooseafile = get_string("chooseafile", "resource"); $strchooseafile = get_string("chooseafile", "resource");
button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile); button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
} }
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right" nowrap> <td align="right" nowrap>
<b><?PHP print_string("filename", "resource") ?>:</b> <b><?PHP print_string("filename", "resource") ?>:</b>
</td> </td>
<td align="left"><?PHP <td align="left"><?PHP
if (function_exists("button_to_popup_window")) { if (function_exists("button_to_popup_window")) {
print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;'; print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
} else if (function_exists("get_directory_list")) { } else if (function_exists("get_directory_list")) {
// Moodle 1.1 (and perhaps some others) // Moodle 1.1 (and perhaps some others)
$dirs = get_directory_list("$CFG->dataroot/$course->id"); $dirs = get_directory_list("$CFG->dataroot/$course->id");
$options = array(); $options = array();
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
$options["$dir"] = $dir; $options["$dir"] = $dir;
} }
choose_from_menu ($options, "reference", $form->reference); choose_from_menu ($options, "reference", $form->reference);
} else { } else {
// a very old Moodle (may be none left :-) // a very old Moodle (may be none left :-)
print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;'; print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
} }
print '<br />'; print '<br />';
hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true); hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true);
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP <td align="right"><b><?PHP
$quizchain = "{$form->mode}quizchain"; $quizchain = "{$form->mode}quizchain";
print_string($quizchain, "hotpot"); print_string($quizchain, "hotpot");
?>:</b></td> ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($yes_no_options, "quizchain", $form->quizchain, ""); choose_from_menu($yes_no_options, "quizchain", $form->quizchain, "");
helpbutton($quizchain, get_string($quizchain,"hotpot"), "hotpot"); helpbutton($quizchain, get_string($quizchain,"hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("outputformat", "hotpot") ?>:</b></td> <td align="right"><b><?PHP print_string("outputformat", "hotpot") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", ""); choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", "");
helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot"); helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("navigation", "hotpot") ?>:</b></td> <td align="right"><b><?PHP print_string("navigation", "hotpot") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", ""); choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", "");
helpbutton("navigation", get_string("navigation","hotpot"), "hotpot"); helpbutton("navigation", get_string("navigation","hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("studentfeedback", "hotpot") ?>:</b></td> <td align="right"><b><?PHP print_string("studentfeedback", "hotpot") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", ""); choose_from_menu($HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "");
print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">"; print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
helpbutton("studentfeedback", get_string("studentfeedback","hotpot"), "hotpot"); helpbutton("studentfeedback", get_string("studentfeedback","hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("forceplugins", "hotpot") ?>:</b></td> <td align="right"><b><?PHP print_string("forceplugins", "hotpot") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", ""); choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", "");
helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot"); helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("shownextquiz", "hotpot") ?>:</b></td> <td align="right"><b><?PHP print_string("shownextquiz", "hotpot") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", ""); choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", "");
helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot"); helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("allowreview", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("allowreview", "quiz") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($yes_no_options, "review", "$form->review", ""); choose_from_menu($yes_no_options, "review", "$form->review", "");
helpbutton("review", get_string("allowreview","quiz"), "quiz"); helpbutton("review", get_string("allowreview","quiz"), "quiz");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("maximumgrade") ?>:</b></td> <td align="right"><b><?PHP print_string("maximumgrade") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
$options = array(); $options = array();
for ($i=100; $i>=1; $i--) { for ($i=100; $i>=1; $i--) {
$options[$i] = $i; $options[$i] = $i;
} }
$options[0] = get_string("nograde"); $options[0] = get_string("nograde");
choose_from_menu($options, "grade", "$form->grade", ""); choose_from_menu($options, "grade", "$form->grade", "");
helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("grademethod", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("grademethod", "quiz") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", ""); choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", "");
helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("attemptsallowed", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("attemptsallowed", "quiz") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
$options = array( $options = array(
0 => get_string("attemptsunlimited", "quiz"), 0 => get_string("attemptsunlimited", "quiz"),
1 => '1 '.strtolower(get_string("attempt", "quiz")) 1 => '1 '.strtolower(get_string("attempt", "quiz"))
); );
for ($i=2; $i<=10; $i++) { for ($i=2; $i<=10; $i++) {
$options[$i] = "$i ".strtolower(get_string("attempts", "quiz")); $options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
} }
choose_from_menu($options, "attempts", "$form->attempts", ""); choose_from_menu($options, "attempts", "$form->attempts", "");
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("requirepassword", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("requirepassword", "quiz") ?>:</b></td>
<td align="left"> <td align="left">
<input type="text" name="password" size=40 value="<?PHP p($form->password) ?>"> <input type="text" name="password" size=40 value="<?PHP p($form->password) ?>">
<?PHP helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?> <?PHP helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("requiresubnet", "quiz") ?>:</b></td> <td align="right"><b><?PHP print_string("requiresubnet", "quiz") ?>:</b></td>
<td align="left"> <td align="left">
<input type="text" name="subnet" size=40 value="<?PHP p($form->subnet) ?>"> <input type="text" name="subnet" size=40 value="<?PHP p($form->subnet) ?>">
<?PHP helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?> <?PHP helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right"><b><?PHP print_string("clickreporting", "hotpot") ?>:</b></td> <td align="right"><b><?PHP print_string("clickreporting", "hotpot") ?>:</b></td>
<td align="left"><?PHP <td align="left"><?PHP
choose_from_menu($yes_no_options, "clickreporting", "$form->clickreporting", ""); choose_from_menu($yes_no_options, "clickreporting", "$form->clickreporting", "");
helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot"); helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot");
?></td> ?></td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<td align="right">&nbsp;</td> <td align="right">&nbsp;</td>
<td align="left"> <td align="left">
<!-- buttons --> <!-- buttons -->
<input type="submit" value="<?PHP print_string("savechanges") ?>"> &nbsp; &nbsp; <input type="submit" value="<?PHP print_string("savechanges") ?>"> &nbsp; &nbsp;
<input type="submit" name="cancel" value="<?PHP print_string("cancel") ?>" /><br /> <input type="submit" name="cancel" value="<?PHP print_string("cancel") ?>" /><br />
<?PHP <?PHP
if (isset($CFG->release) && substr($CFG->release, 0, 3)>=1.5) { if (isset($CFG->release) && substr($CFG->release, 0, 3)>=1.5) {
$options = array( $options = array(
HOTPOT_DISPLAYNEXT_QUIZ => get_string("displayhotpotnext", "hotpot"), HOTPOT_DISPLAYNEXT_QUIZ => get_string("displayhotpotnext", "hotpot"),
HOTPOT_DISPLAYNEXT_COURSE => get_string("displaycoursenext", "hotpot"), HOTPOT_DISPLAYNEXT_COURSE => get_string("displaycoursenext", "hotpot"),
HOTPOT_DISPLAYNEXT_INDEX => get_string("displayindexnext", "hotpot") HOTPOT_DISPLAYNEXT_INDEX => get_string("displayindexnext", "hotpot")
); );
choose_from_menu($options, "displaynext", "$form->displaynext", ""); choose_from_menu($options, "displaynext", "$form->displaynext", "");
} else { } else {
print '<input type="hidden" name="displaynext" value="'.HOTPOT_NO.'">'."\n"; print '<input type="hidden" name="displaynext" value="'.HOTPOT_NO.'">'."\n";
} }
?> ?>
</table> </table>
<!-- hidden fields --> <!-- hidden fields -->
@ -333,121 +333,121 @@ $text_source_options = array(
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- <!--
function hpShowHideStudentFeedbackUrl() { function hpShowHideStudentFeedbackUrl() {
var frm = document.forms['form']; var frm = document.forms['form'];
if (frm) { if (frm) {
var obj = frm.elements['studentfeedback']; var obj = frm.elements['studentfeedback'];
var url = frm.elements['studentfeedbackurl']; var url = frm.elements['studentfeedbackurl'];
if (obj && obj.type=='select-one' && url && url.style) { if (obj && obj.type=='select-one' && url && url.style) {
if (obj.onchange==null) { if (obj.onchange==null) {
obj.onchange = hpShowHideStudentFeedbackUrl; obj.onchange = hpShowHideStudentFeedbackUrl;
} }
var v = obj.options[obj.selectedIndex].value; var v = obj.options[obj.selectedIndex].value;
url.style.display = (v==1 || v==2) ? 'inline' : 'none'; url.style.display = (v==1 || v==2) ? 'inline' : 'none';
} }
} }
} }
hpShowHideStudentFeedbackUrl(); hpShowHideStudentFeedbackUrl();
function hpShowHideTime(s) { function hpShowHideTime(s) {
var frm = document.forms['form']; var frm = document.forms['form'];
if (frm) { if (frm) {
var obj = frm.elements['enabletime'+s]; var obj = frm.elements['enabletime'+s];
if (obj && obj.type=='select-one' && document.getElementById) { if (obj && obj.type=='select-one' && document.getElementById) {
if (obj.onchange==null) { if (obj.onchange==null) {
obj.onchange = new Function("hpShowHideTime('"+s+"')"); obj.onchange = new Function("hpShowHideTime('"+s+"')");
} }
var v = obj.options[obj.selectedIndex].value; var v = obj.options[obj.selectedIndex].value;
var obj = document.getElementById('time'+s+'SPAN'); var obj = document.getElementById('time'+s+'SPAN');
if (obj && obj.style) { if (obj && obj.style) {
obj.style.display = (v==0) ? 'none' : 'inline'; obj.style.display = (v==0) ? 'none' : 'inline';
} }
} }
} }
} }
hpShowHideTime('open'); hpShowHideTime('open');
hpShowHideTime('close'); hpShowHideTime('close');
function hpShowHideTextSource(s) { function hpShowHideTextSource(s) {
var frm = document.forms['form']; var frm = document.forms['form'];
if (frm) { if (frm) {
var obj = frm.elements[s+'source']; var obj = frm.elements[s+'source'];
if (obj && obj.type=='select-one' && document.getElementById) { if (obj && obj.type=='select-one' && document.getElementById) {
if (obj.onchange==null) { if (obj.onchange==null) {
obj.onchange = new Function("hpShowHideTextSource('"+s+"')"); obj.onchange = new Function("hpShowHideTextSource('"+s+"')");
} }
var v = obj.options[obj.selectedIndex].value; var v = obj.options[obj.selectedIndex].value;
var obj = document.getElementById(s+'SPAN'); var obj = document.getElementById(s+'SPAN');
if (obj && obj.style) { if (obj && obj.style) {
obj.style.display = (v==0 || v==1 || v==2) ? 'none' : 'inline'; obj.style.display = (v==0 || v==1 || v==2) ? 'none' : 'inline';
} }
} }
} }
return true; return true;
} }
hpShowHideTextSource('name'); hpShowHideTextSource('name');
//hpShowHideTextSource('summary'); //hpShowHideTextSource('summary');
// override the standard Moodle "setfocus" function, // override the standard Moodle "setfocus" function,
// which gives a js error if the "name" field is hidden // which gives a js error if the "name" field is hidden
function setfocus() { function setfocus() {
var f = document.form; var f = document.form;
if (f) { if (f) {
if (canfocus(f, 'namesource')) { if (canfocus(f, 'namesource')) {
f.namesource.focus(); f.namesource.focus();
} else if (canfocus(f, 'name')) { } else if (canfocus(f, 'name')) {
f.name.focus(); f.name.focus();
} }
} }
} }
function canfocus(f, name) { function canfocus(f, name) {
var obj = eval('f.'+name); var obj = eval('f.'+name);
return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true; return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true;
} }
//--> //-->
</script> </script>
<?PHP <?PHP
// ====================== // ======================
// functions // functions
// ====================== // ======================
function set_form_fields(&$form) { function set_form_fields(&$form) {
set_form_field($form, 'name'); set_form_field($form, 'name');
set_form_field($form, 'summary'); set_form_field($form, 'summary');
set_form_field($form, 'timeopen', get_user_preferences('hotpot_timeopen', 0)); set_form_field($form, 'timeopen', get_user_preferences('hotpot_timeopen', 0));
set_form_field($form, 'enabletimeopen', empty($form->timeopen) ? HOTPOT_NO : HOTPOT_YES); set_form_field($form, 'enabletimeopen', empty($form->timeopen) ? HOTPOT_NO : HOTPOT_YES);
set_form_field($form, 'timeclose', get_user_preferences('hotpot_timeclose', 0)); set_form_field($form, 'timeclose', get_user_preferences('hotpot_timeclose', 0));
set_form_field($form, 'enabletimeclose', empty($form->timeclose) ? HOTPOT_NO : HOTPOT_YES); set_form_field($form, 'enabletimeclose', empty($form->timeclose) ? HOTPOT_NO : HOTPOT_YES);
set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES); set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES);
set_form_field($form, 'reference'); set_form_field($form, 'reference');
set_form_field($form, 'navigation', get_user_preferences('hotpot_navigation', HOTPOT_NAVIGATION_BAR)); set_form_field($form, 'navigation', get_user_preferences('hotpot_navigation', HOTPOT_NAVIGATION_BAR));
set_form_field($form, 'outputformat', get_user_preferences('hotpot_outputformat', HOTPOT_OUTPUTFORMAT_BEST)); set_form_field($form, 'outputformat', get_user_preferences('hotpot_outputformat', HOTPOT_OUTPUTFORMAT_BEST));
set_form_field($form, 'studentfeedback', get_user_preferences('hotpot_studentfeedback', HOTPOT_FEEDBACK_NONE)); set_form_field($form, 'studentfeedback', get_user_preferences('hotpot_studentfeedback', HOTPOT_FEEDBACK_NONE));
set_form_field($form, 'studentfeedbackurl', get_user_preferences('hotpot_studentfeedbackurl', 'http://')); set_form_field($form, 'studentfeedbackurl', get_user_preferences('hotpot_studentfeedbackurl', 'http://'));
set_form_field($form, 'forceplugins', get_user_preferences('hotpot_forceplugins', HOTPOT_NO)); set_form_field($form, 'forceplugins', get_user_preferences('hotpot_forceplugins', HOTPOT_NO));
if ($form->mode=='add') { if ($form->mode=='add') {
set_form_field($form, 'namesource', get_user_preferences('hotpot_namesource', HOTPOT_TEXTSOURCE_QUIZ)); set_form_field($form, 'namesource', get_user_preferences('hotpot_namesource', HOTPOT_TEXTSOURCE_QUIZ));
set_form_field($form, 'summarysource', get_user_preferences('hotpot_summarysource', HOTPOT_TEXTSOURCE_QUIZ)); set_form_field($form, 'summarysource', get_user_preferences('hotpot_summarysource', HOTPOT_TEXTSOURCE_QUIZ));
$quizchain = get_user_preferences('hotpot_quizchain', HOTPOT_NO); $quizchain = get_user_preferences('hotpot_quizchain', HOTPOT_NO);
} else { } else {
$quizchain = empty($form->quizchain) ? HOTPOT_NO : HOTPOT_YES; $quizchain = empty($form->quizchain) ? HOTPOT_NO : HOTPOT_YES;
} }
set_form_field($form, 'quizchain', $quizchain); set_form_field($form, 'quizchain', $quizchain);
set_form_field($form, 'shownextquiz', get_user_preferences('hotpot_shownextquiz', HOTPOT_NO)); set_form_field($form, 'shownextquiz', get_user_preferences('hotpot_shownextquiz', HOTPOT_NO));
set_form_field($form, 'review', get_user_preferences('hotpot_review', HOTPOT_YES)); set_form_field($form, 'review', get_user_preferences('hotpot_review', HOTPOT_YES));
set_form_field($form, 'grade', get_user_preferences('hotpot_grade', 100)); set_form_field($form, 'grade', get_user_preferences('hotpot_grade', 100));
set_form_field($form, 'grademethod', get_user_preferences('hotpot_grademethod', HOTPOT_GRADEMETHOD_HIGHEST)); set_form_field($form, 'grademethod', get_user_preferences('hotpot_grademethod', HOTPOT_GRADEMETHOD_HIGHEST));
set_form_field($form, 'attempts', get_user_preferences('hotpot_attempts', 0)); // 0=unlimited set_form_field($form, 'attempts', get_user_preferences('hotpot_attempts', 0)); // 0=unlimited
set_form_field($form, 'password'); set_form_field($form, 'password');
set_form_field($form, 'subnet', get_user_preferences('hotpot_subnet')); set_form_field($form, 'subnet', get_user_preferences('hotpot_subnet'));
set_form_field($form, 'clickreporting', HOTPOT_NO); set_form_field($form, 'clickreporting', HOTPOT_NO);
set_form_field($form, 'displaynext', get_user_preferences('hotpot_displaynext', HOTPOT_DISPLAYNEXT_QUIZ)); set_form_field($form, 'displaynext', get_user_preferences('hotpot_displaynext', HOTPOT_DISPLAYNEXT_QUIZ));
} }
function set_form_field(&$form, $fieldname, $defaultvalue='') { function set_form_field(&$form, $fieldname, $defaultvalue='') {
if (!isset($form->$fieldname)) { if (!isset($form->$fieldname)) {
$form->$fieldname = $defaultvalue; $form->$fieldname = $defaultvalue;
} }
} }
?> ?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,240 +1,240 @@
<?PHP // $Id$ <?PHP // $Id$
// This page prints a review of a particular quiz attempt // This page prints a review of a particular quiz attempt
require_once("../../config.php"); require_once("../../config.php");
require_once("lib.php"); require_once("lib.php");
$id = optional_param("id"); // Course Module ID, or $id = optional_param("id"); // Course Module ID, or
$hp = optional_param("hp"); // hotpot ID $hp = optional_param("hp"); // hotpot ID
$attempt = required_param("attempt"); // A particular attempt ID for review $attempt = required_param("attempt"); // A particular attempt ID for review
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('hotpot', $id)) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
error("Course Module ID was incorrect"); error("Course Module ID was incorrect");
} }
if (! $course = get_record("course", "id", $cm->course)) { if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured"); error("Course is misconfigured");
} }
if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { if (! $hotpot = get_record("hotpot", "id", $cm->instance)) {
error("Course module is incorrect"); error("Course module is incorrect");
} }
} else { } else {
if (! $hotpot = get_record("hotpot", "id", $hp)) { if (! $hotpot = get_record("hotpot", "id", $hp)) {
error("Course module is incorrect"); error("Course module is incorrect");
} }
if (! $course = get_record("course", "id", $hotpot->course)) { if (! $course = get_record("course", "id", $hotpot->course)) {
error("Course is misconfigured"); error("Course is misconfigured");
} }
if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
error("Course Module ID was incorrect"); error("Course Module ID was incorrect");
} }
} }
if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) { if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) {
error("Attempt ID was incorrect"); error("Attempt ID was incorrect");
} }
require_login($course->id); require_login($course->id);
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
if (!$hotpot->review) { if (!$hotpot->review) {
error(get_string("noreview", "quiz")); error(get_string("noreview", "quiz"));
} }
//if (time() < $hotpot->timeclose) { //if (time() < $hotpot->timeclose) {
// error(get_string("noreviewuntil", "quiz", userdate($hotpot->timeclose))); // error(get_string("noreviewuntil", "quiz", userdate($hotpot->timeclose)));
//} //}
if ($attempt->userid != $USER->id) { if ($attempt->userid != $USER->id) {
error("This is not your attempt!"); error("This is not your attempt!");
} }
} }
add_to_log($course->id, "hotpot", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id"); add_to_log($course->id, "hotpot", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id");
// Print the page header // Print the page header
$strmodulenameplural = get_string("modulenameplural", "hotpot"); $strmodulenameplural = get_string("modulenameplural", "hotpot");
$strmodulename = get_string("modulename", "hotpot"); $strmodulename = get_string("modulename", "hotpot");
// print header // print header
$title = "$course->shortname: $hotpot->name"; $title = "$course->shortname: $hotpot->name";
$heading = "$course->fullname"; $heading = "$course->fullname";
$navigation = "<a href=\"index.php?id=$course->id\">$strmodulenameplural</a> -> ".get_string("review", "quiz"); $navigation = "<a href=\"index.php?id=$course->id\">$strmodulenameplural</a> -> ".get_string("review", "quiz");
if ($course->category) { if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> $navigation"; $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> $navigation";
} }
$button = update_module_button($cm->id, $course->id, $strmodulename); $button = update_module_button($cm->id, $course->id, $strmodulename);
print_header($title, $heading, $navigation, "", "", true, $button, navmenu($course, $cm)); print_header($title, $heading, $navigation, "", "", true, $button, navmenu($course, $cm));
print '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib print '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
print_heading($hotpot->name); print_heading($hotpot->name);
hotpot_print_attempt_summary($hotpot, $attempt); hotpot_print_attempt_summary($hotpot, $attempt);
hotpot_print_review_buttons($course, $hotpot, $attempt); hotpot_print_review_buttons($course, $hotpot, $attempt);
$action = isteacher($course->id) ? optional_param('action') : ''; $action = isteacher($course->id) ? optional_param('action') : '';
if ($action) { if ($action) {
$xml = get_field('hotpot_details', 'details', 'attempt', $attempt->id); $xml = get_field('hotpot_details', 'details', 'attempt', $attempt->id);
print '<hr>'; print '<hr>';
switch ($action) { switch ($action) {
case 'showxmltree': case 'showxmltree':
print '<pre id="contents">'; print '<pre id="contents">';
$xml_tree = new hotpot_xml_tree($xml, "['hpjsresult']['#']"); $xml_tree = new hotpot_xml_tree($xml, "['hpjsresult']['#']");
print_r ($xml_tree->xml_value('fields')); print_r ($xml_tree->xml_value('fields'));
print '</pre>'; print '</pre>';
break; break;
case 'showxmlsource': case 'showxmlsource':
print htmlspecialchars($xml); print htmlspecialchars($xml);
break; break;
default: default:
print "Action '$action' not recognized"; print "Action '$action' not recognized";
} }
print '<hr>'; print '<hr>';
} else { } else {
hotpot_print_attempt_details($hotpot, $attempt); hotpot_print_attempt_details($hotpot, $attempt);
} }
hotpot_print_review_buttons($course, $hotpot, $attempt); hotpot_print_review_buttons($course, $hotpot, $attempt);
print_footer($course); print_footer($course);
/////////////////////////// ///////////////////////////
// functions // functions
/////////////////////////// ///////////////////////////
function hotpot_print_attempt_summary(&$hotpot, &$attempt) { function hotpot_print_attempt_summary(&$hotpot, &$attempt) {
// start table // start table
print_simple_box_start("center", "80%", "#ffffff", 0); print_simple_box_start("center", "80%", "#ffffff", 0);
print '<table width="100%" border="1" valign="top" align="center" cellpadding="2" cellspacing="2" class="generaltable">'."\n"; print '<table width="100%" border="1" valign="top" align="center" cellpadding="2" cellspacing="2" class="generaltable">'."\n";
// add attempt properties // add attempt properties
$fields = array('attempt', 'score', 'penalties', 'status', 'timetaken', 'timerecorded'); $fields = array('attempt', 'score', 'penalties', 'status', 'timetaken', 'timerecorded');
foreach ($fields as $field) { foreach ($fields as $field) {
switch ($field) { switch ($field) {
case 'score': case 'score':
$value = hotpot_format_score($attempt); $value = hotpot_format_score($attempt);
break; break;
case 'status': case 'status':
$value = hotpot_format_status($attempt); $value = hotpot_format_status($attempt);
break; break;
case 'timerecorded': case 'timerecorded':
$value = empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish); $value = empty($attempt->timefinish) ? '-' : userdate($attempt->timefinish);
break; break;
case 'timetaken': case 'timetaken':
$value = empty($attempt->timefinish) ? '-' : format_time($attempt->timefinish - $attempt->timestart); $value = empty($attempt->timefinish) ? '-' : format_time($attempt->timefinish - $attempt->timestart);
break; break;
default: default:
$value = isset($attempt->$field) ? $attempt->$field : NULL; $value = isset($attempt->$field) ? $attempt->$field : NULL;
} }
if (isset($value)) { if (isset($value)) {
switch ($field) { switch ($field) {
case 'status': case 'status':
case 'timerecorded': case 'timerecorded':
$name = get_string('report'.$field, 'hotpot'); $name = get_string('report'.$field, 'hotpot');
break; break;
case 'penalties': case 'penalties':
$name = get_string('penalties', 'hotpot'); $name = get_string('penalties', 'hotpot');
break; break;
default: default:
$name = get_string($field, 'quiz'); $name = get_string($field, 'quiz');
} }
print '<tr><th align="right" width="100" class="generaltableheader">'.$name.':</th><td class="generaltablecell">'.$value.'</td></tr>'; print '<tr><th align="right" width="100" class="generaltableheader">'.$name.':</th><td class="generaltablecell">'.$value.'</td></tr>';
} }
} }
// finish table // finish table
print '</table>'; print '</table>';
print_simple_box_end(); print_simple_box_end();
} }
function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt) { function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt) {
print "\n".'<table border="0" align="center" cellpadding="2" cellspacing="2" class="generaltable">'; print "\n".'<table border="0" align="center" cellpadding="2" cellspacing="2" class="generaltable">';
print "\n<tr>\n".'<td align="center">'; print "\n<tr>\n".'<td align="center">';
print_single_button("report.php?hp=$hotpot->id", NULL, get_string('continue'), 'post'); print_single_button("report.php?hp=$hotpot->id", NULL, get_string('continue'), 'post');
if (isteacher($course->id) && record_exists('hotpot_details', 'attempt', $attempt->id)) { if (isteacher($course->id) && record_exists('hotpot_details', 'attempt', $attempt->id)) {
print "</td>\n".'<td align="center">'; print "</td>\n".'<td align="center">';
print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot'), 'post'); print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot'), 'post');
print "</td>\n".'<td align="center">'; print "</td>\n".'<td align="center">';
print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmltree", NULL, get_string('showxmltree', 'hotpot'), 'post'); print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmltree", NULL, get_string('showxmltree', 'hotpot'), 'post');
$colspan = 3; $colspan = 3;
} else { } else {
$colspan = 1; $colspan = 1;
} }
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
print '<tr><td colspan="'.$colspan.'">'; print '<tr><td colspan="'.$colspan.'">';
print_spacer(4, 1, false); // height=4, width=1, no <br /> print_spacer(4, 1, false); // height=4, width=1, no <br />
print "</td></tr>\n"; print "</td></tr>\n";
print "</table>\n"; print "</table>\n";
} }
function hotpot_print_attempt_details(&$hotpot, &$attempt) { function hotpot_print_attempt_details(&$hotpot, &$attempt) {
// define fields to print // define fields to print
$textfields = array('correct', 'ignored', 'wrong'); $textfields = array('correct', 'ignored', 'wrong');
$numfields = array('score', 'weighting', 'hints', 'clues', 'checks'); $numfields = array('score', 'weighting', 'hints', 'clues', 'checks');
$fields = array_merge($textfields, $numfields); $fields = array_merge($textfields, $numfields);
$q = array(); // questions $q = array(); // questions
$f = array(); // fields $f = array(); // fields
foreach ($fields as $field) { foreach ($fields as $field) {
$name = get_string($field, 'hotpot'); $name = get_string($field, 'hotpot');
$f[$field] = array('count'=>0, 'name'=>$name); $f[$field] = array('count'=>0, 'name'=>$name);
} }
// get questions and responses for this attempt // get questions and responses for this attempt
$questions = get_records_select('hotpot_questions', "hotpot='$hotpot->id'", 'id'); $questions = get_records_select('hotpot_questions', "hotpot='$hotpot->id'", 'id');
$responses = get_records_select('hotpot_responses', "attempt='$attempt->id'", 'id'); $responses = get_records_select('hotpot_responses', "attempt='$attempt->id'", 'id');
if ($questions && $responses) { if ($questions && $responses) {
foreach ($responses as $response) { foreach ($responses as $response) {
$id = $response->question; $id = $response->question;
foreach ($fields as $field) { foreach ($fields as $field) {
if (!isset($f[$field])) { if (!isset($f[$field])) {
$name = get_string($field, 'hotpot'); $name = get_string($field, 'hotpot');
$f[$field] = array('count'=>0, 'name'=>$name); $f[$field] = array('count'=>0, 'name'=>$name);
} }
if (isset($response->$field)) { if (isset($response->$field)) {
$f[$field]['count']++; $f[$field]['count']++;
if (!isset($q[$id])) { if (!isset($q[$id])) {
$name = hotpot_get_question_name($questions[$id]); $name = hotpot_get_question_name($questions[$id]);
$q[$id] = array('name'=>$name); $q[$id] = array('name'=>$name);
} }
$q[$id][$field] = $response->$field; $q[$id][$field] = $response->$field;
} }
} }
} }
} }
// count the number of columns required in the table // count the number of columns required in the table
$colspan = 0; $colspan = 0;
foreach ($numfields as $field) { foreach ($numfields as $field) {
if ($f[$field]['count']) { if ($f[$field]['count']) {
$colspan += 2; $colspan += 2;
} }
} }
$colspan = max(2, $colspan); $colspan = max(2, $colspan);
// start table of questions and responses // start table of questions and responses
print_simple_box_start("center", "80%", "#ffffff", 0); print_simple_box_start("center", "80%", "#ffffff", 0);
print '<table width="100%" border="1" valign="top" align="center" cellpadding="2" cellspacing="2" class="generaltable">'."\n"; print '<table width="100%" border="1" valign="top" align="center" cellpadding="2" cellspacing="2" class="generaltable">'."\n";
if (empty($q)) { if (empty($q)) {
print '<tr><td align="center" class="generaltablecell"><b>'.get_string("noresponses", "hotpot")."</b></td></tr>\n"; print '<tr><td align="center" class="generaltablecell"><b>'.get_string("noresponses", "hotpot")."</b></td></tr>\n";
} else { } else {
// flag to ensure separators are only printed before the 2nd and subsequent questions // flag to ensure separators are only printed before the 2nd and subsequent questions
$printseparator = false; $printseparator = false;
foreach ($q as $i=>$question) { foreach ($q as $i=>$question) {
// flag to ensure questions are only printed when there is at least one response // flag to ensure questions are only printed when there is at least one response
$printedquestion = false; $printedquestion = false;
// add rows of text fields // add rows of text fields
foreach ($textfields as $field) { foreach ($textfields as $field) {
if (isset($question[$field])) { if (isset($question[$field])) {
$text = hotpot_strings($question[$field]); $text = hotpot_strings($question[$field]);
if (trim($text)) { if (trim($text)) {
// print question if necessary // print question if necessary
if (!$printedquestion) { if (!$printedquestion) {
if ($printseparator) { if ($printseparator) {
print '<tr><td colspan="'.$colspan.'"><div class="tabledivider"></div></td></tr>'."\n"; print '<tr><td colspan="'.$colspan.'"><div class="tabledivider"></div></td></tr>'."\n";
} }
$printseparator = true; $printseparator = true;
print '<tr><td colspan="'.$colspan.'" class="generaltablecell"><b>'.$question['name'].'</b></td></tr>'."\n"; print '<tr><td colspan="'.$colspan.'" class="generaltablecell"><b>'.$question['name'].'</b></td></tr>'."\n";
$printedquestion = true; $printedquestion = true;
} }
// print response // print response
print '<tr><th align="right" width="100" class="generaltableheader">'.$f[$field]['name'].':</th><td colspan="'.($colspan-1).'" class="generaltablecell">'.$text.'</td></tr>'."\n"; print '<tr><th align="right" width="100" class="generaltableheader">'.$f[$field]['name'].':</th><td colspan="'.($colspan-1).'" class="generaltablecell">'.$text.'</td></tr>'."\n";
} }
} }
} }
// add row of numeric fields // add row of numeric fields
print '<tr>'; print '<tr>';
foreach ($numfields as $field) { foreach ($numfields as $field) {
if ($f[$field]['count']) { if ($f[$field]['count']) {
// print question if necessary // print question if necessary
if (!$printedquestion) { if (!$printedquestion) {
print '<td colspan="'.$colspan.'" class="generaltablecell"><b>'.$question['name']."</b></td></tr>\n<tr>"; print '<td colspan="'.$colspan.'" class="generaltablecell"><b>'.$question['name']."</b></td></tr>\n<tr>";
$printedquestion = true; $printedquestion = true;
} }
// print numeric response // print numeric response
$value = isset($question[$field]) ? $question[$field] : '-'; $value = isset($question[$field]) ? $question[$field] : '-';
print '<th align="right" width="100" class="generaltableheader">'.$f[$field]['name'].':</th><td class="generaltablecell">'.$value.'</td>'; print '<th align="right" width="100" class="generaltableheader">'.$f[$field]['name'].':</th><td class="generaltablecell">'.$value.'</td>';
} }
} }
print "</tr>\n"; print "</tr>\n";
} // foreach $q } // foreach $q
} }
// finish table // finish table
print "</table>\n"; print "</table>\n";
print_simple_box_end(); print_simple_box_end();
} }
?> ?>

View file

@ -1,68 +1,68 @@
<?php // $Id$ <?php // $Id$
require_once("../../config.php"); require_once("../../config.php");
require_once("lib.php"); require_once("lib.php");
require_login(); require_login();
// fetch and clean the required $_GET parameters // fetch and clean the required $_GET parameters
// (script stops here if any parameters are missing) // (script stops here if any parameters are missing)
unset($params); unset($params);
$params->action = required_param('action'); $params->action = required_param('action');
$params->course = required_param('course'); $params->course = required_param('course');
$params->reference = required_param('reference'); $params->reference = required_param('reference');
require_login($params->course); require_login($params->course);
if (!isteacher($params->course)) { if (!isteacher($params->course)) {
error("You are not allowed to view this page!"); error("You are not allowed to view this page!");
} }
if (isadmin()) { if (isadmin()) {
$params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES); $params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES);
} else { } else {
$params->location = HOTPOT_LOCATION_COURSEFILES; $params->location = HOTPOT_LOCATION_COURSEFILES;
} }
$title = get_string($params->action, 'hotpot').': '.$params->reference; $title = get_string($params->action, 'hotpot').': '.$params->reference;
print_header($title, $title); print_header($title, $title);
hotpot_print_show_links($params->course, $params->location, $params->reference); hotpot_print_show_links($params->course, $params->location, $params->reference);
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- <!--
// http://www.krikkit.net/howto_javascript_copy_clipboard.html // http://www.krikkit.net/howto_javascript_copy_clipboard.html
function copy_contents(id) { function copy_contents(id) {
if (id==null) { if (id==null) {
id = 'contents'; id = 'contents';
} }
var obj = null; var obj = null;
if (document.getElementById) { if (document.getElementById) {
obj = document.getElementById(id); obj = document.getElementById(id);
} }
if (obj && window.clipboardData) { if (obj && window.clipboardData) {
window.clipboardData.setData("Text", obj.innerText); window.clipboardData.setData("Text", obj.innerText);
alert('<?php print_string('copiedtoclipboard', 'hotpot') ?>'); alert('<?php print_string('copiedtoclipboard', 'hotpot') ?>');
} }
} }
document.write('<span class="helplink"> &nbsp; <a href="javascript:copy_contents()"><?php print_string('copytoclipboard', 'hotpot') ?></A></span>'); document.write('<span class="helplink"> &nbsp; <a href="javascript:copy_contents()"><?php print_string('copytoclipboard', 'hotpot') ?></A></span>');
--> -->
</script> </script>
<?php <?php
print_simple_box_start("center", "96%"); print_simple_box_start("center", "96%");
if($hp = new hotpot_xml_quiz($params)) { if($hp = new hotpot_xml_quiz($params)) {
print '<pre id="contents">'; print '<pre id="contents">';
switch ($params->action) { switch ($params->action) {
case 'showxmlsource': case 'showxmlsource':
print htmlspecialchars($hp->source); print htmlspecialchars($hp->source);
break; break;
case 'showxmltree': case 'showxmltree':
print_r($hp->xml); print_r($hp->xml);
break; break;
case 'showhtmlsource': case 'showhtmlsource':
print htmlspecialchars($hp->html); print htmlspecialchars($hp->html);
break; break;
case 'showhtmlquiz': case 'showhtmlquiz':
print $hp->html; print $hp->html;
break; break;
} }
print '</pre>'; print '</pre>';
} else { } else {
print_simple_box("Could not open Hot Potatoes XML file", "center", "", "#FFBBBB"); print_simple_box("Could not open Hot Potatoes XML file", "center", "", "#FFBBBB");
} }
print_simple_box_end(); print_simple_box_end();
print '<br />'; print '<br />';
close_window_button(); close_window_button();
?> ?>

View file

@ -1,110 +1,110 @@
<?PHP <?PHP
class hotpot_xml_template_default { class hotpot_xml_template_default {
function read_template($filename, $tag='temporary') { function read_template($filename, $tag='temporary') {
// create the file path to the template // create the file path to the template
$filepath = $this->parent->template_dirpath.DIRECTORY_SEPARATOR.$filename; $filepath = $this->parent->template_dirpath.DIRECTORY_SEPARATOR.$filename;
// try and open the template file // try and open the template file
if (!file_exists($filepath) || !is_readable($filepath)) { if (!file_exists($filepath) || !is_readable($filepath)) {
$msg = 'Could not open the '.$this->parent->template_dir.' template file &quot;'.$filepath.'&quot;'; $msg = 'Could not open the '.$this->parent->template_dir.' template file &quot;'.$filepath.'&quot;';
error($msg, $this->parent->course_homeurl); error($msg, $this->parent->course_homeurl);
} }
// read in the template and close the file // read in the template and close the file
$this->$tag = file_get_contents($filepath); $this->$tag = file_get_contents($filepath);
// expand the blocks and strings in the template // expand the blocks and strings in the template
$this->expand_blocks($tag); $this->expand_blocks($tag);
$this->expand_strings($tag); $this->expand_strings($tag);
if ($tag=='temporary') { if ($tag=='temporary') {
$template = $this->$tag; $template = $this->$tag;
$this->$tag = ''; $this->$tag = '';
return $template; return $template;
} }
} }
function expand_blocks($tag) { function expand_blocks($tag) {
// get block $names // get block $names
// [1] the full block name (including optional leading 'str' or 'incl') // [1] the full block name (including optional leading 'str' or 'incl')
// [2] leading 'incl' or 'str', if any // [2] leading 'incl' or 'str', if any
// [3] the real block name ([1] without [2]) // [3] the real block name ([1] without [2])
$search = '/\[\/((incl|str)?(\w+))\]/'; $search = '/\[\/((incl|str)?(\w+))\]/';
preg_match_all($search, $this->$tag, $names); preg_match_all($search, $this->$tag, $names);
$i_max = count($names[0]); $i_max = count($names[0]);
for ($i=0; $i<$i_max; $i++) { for ($i=0; $i<$i_max; $i++) {
$method = $this->parent->template_dir.'_expand_'.$names[3][$i]; $method = $this->parent->template_dir.'_expand_'.$names[3][$i];
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
eval('$value=$this->'.$method.'();'); eval('$value=$this->'.$method.'();');
$search = '/\['.$names[1][$i].'\](.*?)\[\/'.$names[1][$i].'\]/s'; $search = '/\['.$names[1][$i].'\](.*?)\[\/'.$names[1][$i].'\]/s';
preg_match_all($search, $this->$tag, $blocks); preg_match_all($search, $this->$tag, $blocks);
$ii_max = count($blocks[0]); $ii_max = count($blocks[0]);
for ($ii=0; $ii<$ii_max; $ii++) { for ($ii=0; $ii<$ii_max; $ii++) {
$replace = empty($value) ? '' : $blocks[1][$ii]; $replace = empty($value) ? '' : $blocks[1][$ii];
$this->$tag = str_replace($blocks[0][$ii], $replace, $this->$tag); $this->$tag = str_replace($blocks[0][$ii], $replace, $this->$tag);
} }
} else { } else {
$msg = 'Template block expand method not found: &quot;'.$method.'&quot;'; $msg = 'Template block expand method not found: &quot;'.$method.'&quot;';
error($msg, $this->parent->course_homeurl); error($msg, $this->parent->course_homeurl);
} }
} }
} }
function expand_strings($tag, $search='') { function expand_strings($tag, $search='') {
if (empty($search)) { if (empty($search)) {
// default $search $pattern // default $search $pattern
$search = '/\[(?:bool|int|str)(\\w+)\]/'; $search = '/\[(?:bool|int|str)(\\w+)\]/';
} }
preg_match_all($search, $this->$tag, $matches); preg_match_all($search, $this->$tag, $matches);
$i_max = count($matches[0]); $i_max = count($matches[0]);
for ($i=0; $i<$i_max; $i++) { for ($i=0; $i<$i_max; $i++) {
$method = $this->parent->template_dir.'_expand_'.$matches[1][$i]; $method = $this->parent->template_dir.'_expand_'.$matches[1][$i];
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
eval('$replace=$this->'.$method.'();'); eval('$replace=$this->'.$method.'();');
$this->$tag = str_replace($matches[0][$i], $replace, $this->$tag); $this->$tag = str_replace($matches[0][$i], $replace, $this->$tag);
} }
} }
} }
function bool_value($tags, $more_tags="[0]['#']") { function bool_value($tags, $more_tags="[0]['#']") {
$value = $this->parent->xml_value($tags, $more_tags); $value = $this->parent->xml_value($tags, $more_tags);
return empty($value) ? 'false' : 'true'; return empty($value) ? 'false' : 'true';
} }
function int_value($tags, $more_tags="[0]['#']") { function int_value($tags, $more_tags="[0]['#']") {
return intval($this->parent->xml_value($tags, $more_tags)); return intval($this->parent->xml_value($tags, $more_tags));
} }
function js_value($tags, $more_tags="[0]['#']", $convert_to_unicode=false) { function js_value($tags, $more_tags="[0]['#']", $convert_to_unicode=false) {
return $this->js_safe($this->parent->xml_value($tags, $more_tags), $convert_to_unicode); return $this->js_safe($this->parent->xml_value($tags, $more_tags), $convert_to_unicode);
} }
function js_safe($str, $convert_to_unicode=false) { function js_safe($str, $convert_to_unicode=false) {
// encode a string for javascript // encode a string for javascript
// decode "<" and ">" - not necesary as it was done by xml_value() // decode "<" and ">" - not necesary as it was done by xml_value()
// $str = strtr($str, array('&#x003C;' => '<', '&#x003E;' => '>')); // $str = strtr($str, array('&#x003C;' => '<', '&#x003E;' => '>'));
// escape single quotes and backslashes // escape single quotes and backslashes
$str = strtr($str, array("'"=>"\\'", '\\'=>'\\\\')); $str = strtr($str, array("'"=>"\\'", '\\'=>'\\\\'));
// convert newlines (win = "\r\n", mac="\r", linix/unix="\n") // convert newlines (win = "\r\n", mac="\r", linix/unix="\n")
$nl = '\\n'; // javascript newline $nl = '\\n'; // javascript newline
$str = strtr($str, array("\r\n"=>$nl, "\r"=>$nl, "\n"=>$nl)); $str = strtr($str, array("\r\n"=>$nl, "\r"=>$nl, "\n"=>$nl));
// convert (hex and decimal) html entities to unicode, if required // convert (hex and decimal) html entities to unicode, if required
if ($convert_to_unicode) { if ($convert_to_unicode) {
$str = preg_replace('|&#x([0-9A-F]+);|i', '\\u\\1', $str); $str = preg_replace('|&#x([0-9A-F]+);|i', '\\u\\1', $str);
$str = preg_replace('|&#(\d+);|e', "'\\u'.sprintf('%04X', '\\1')", $str); $str = preg_replace('|&#(\d+);|e', "'\\u'.sprintf('%04X', '\\1')", $str);
} }
return $str; return $str;
} }
function get_halfway_color($x, $y) { function get_halfway_color($x, $y) {
// returns the $color that is half way between $x and $y // returns the $color that is half way between $x and $y
$color = $x; // default $color = $x; // default
$rgb = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i'; $rgb = '/^\#?([0-9a-f])([0-9a-f])([0-9a-f])$/i';
$rrggbb = '/^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i'; $rrggbb = '/^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i';
if (( if ((
preg_match($rgb, $x, $x_matches) || preg_match($rgb, $x, $x_matches) ||
preg_match($rrggbb, $x, $x_matches) preg_match($rrggbb, $x, $x_matches)
) && ( ) && (
preg_match($rgb, $y, $y_matches) || preg_match($rgb, $y, $y_matches) ||
preg_match($rrggbb, $y, $y_matches) preg_match($rrggbb, $y, $y_matches)
)) { )) {
$color = '#'; $color = '#';
for ($i=1; $i<=3; $i++) { for ($i=1; $i<=3; $i++) {
$x_dec = hexdec($x_matches[$i]); $x_dec = hexdec($x_matches[$i]);
$y_dec = hexdec($y_matches[$i]); $y_dec = hexdec($y_matches[$i]);
$color .= sprintf('%02x', min($x_dec, $y_dec) + abs($x_dec-$y_dec)/2); $color .= sprintf('%02x', min($x_dec, $y_dec) + abs($x_dec-$y_dec)/2);
} }
} }
return $color; return $color;
} }
} }
?> ?>

File diff suppressed because it is too large Load diff

View file

@ -1,455 +1,455 @@
<?PHP // $Id$ <?PHP // $Id$
/// This page prints a hotpot quiz /// This page prints a hotpot quiz
if (defined('HOTPOT_FIRST_ATTEMPT') && HOTPOT_FIRST_ATTEMPT==false) { if (defined('HOTPOT_FIRST_ATTEMPT') && HOTPOT_FIRST_ATTEMPT==false) {
// this script is being included (by attempt.php) // this script is being included (by attempt.php)
} else { } else {
// this script is being called directly from the browser // this script is being called directly from the browser
define('HOTPOT_FIRST_ATTEMPT', true); define('HOTPOT_FIRST_ATTEMPT', true);
require_once("../../config.php"); require_once("../../config.php");
require_once("lib.php"); require_once("lib.php");
$id = optional_param("id"); // Course Module ID, or $id = optional_param("id"); // Course Module ID, or
$hp = optional_param("hp"); // hotpot ID $hp = optional_param("hp"); // hotpot ID
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('hotpot', $id)) { if (! $cm = get_coursemodule_from_id('hotpot', $id)) {
error("Course Module ID was incorrect"); error("Course Module ID was incorrect");
} }
if (! $course = get_record("course", "id", $cm->course)) { if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured"); error("Course is misconfigured");
} }
if (! $hotpot = get_record("hotpot", "id", $cm->instance)) { if (! $hotpot = get_record("hotpot", "id", $cm->instance)) {
error("Course module is incorrect"); error("Course module is incorrect");
} }
} else { } else {
if (! $hotpot = get_record("hotpot", "id", $hp)) { if (! $hotpot = get_record("hotpot", "id", $hp)) {
error("Course module is incorrect"); error("Course module is incorrect");
} }
if (! $course = get_record("course", "id", $hotpot->course)) { if (! $course = get_record("course", "id", $hotpot->course)) {
error("Course is misconfigured"); error("Course is misconfigured");
} }
if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) { if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
error("Course Module ID was incorrect"); error("Course Module ID was incorrect");
} }
} }
require_login($course->id); require_login($course->id);
} }
// set nextpage (for error messages) // set nextpage (for error messages)
$nextpage = "$CFG->wwwroot/course/view.php?id=$course->id"; $nextpage = "$CFG->wwwroot/course/view.php?id=$course->id";
// header strings // header strings
$title = strip_tags($course->shortname.': '.$hotpot->name); $title = strip_tags($course->shortname.': '.$hotpot->name);
$heading = "$course->fullname"; $heading = "$course->fullname";
$target = empty($CFG->framename) ? '' : ' target="'.$CFG->framename.'"'; $target = empty($CFG->framename) ? '' : ' target="'.$CFG->framename.'"';
$navigation = '<a'.$target.' href="'.$CFG->wwwroot.'/mod/hotpot/index.php?id='.$course->id.'">'.get_string("modulenameplural", "hotpot")."</a> -> $hotpot->name"; $navigation = '<a'.$target.' href="'.$CFG->wwwroot.'/mod/hotpot/index.php?id='.$course->id.'">'.get_string("modulenameplural", "hotpot")."</a> -> $hotpot->name";
if ($course->category) { if ($course->category) {
$navigation = '<a'.$target.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> -> '.$navigation; $navigation = '<a'.$target.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> -> '.$navigation;
} }
$button = update_module_button($cm->id, $course->id, get_string("modulename", "hotpot").'" style="font-size:0.75em;'); $button = update_module_button($cm->id, $course->id, get_string("modulename", "hotpot").'" style="font-size:0.75em;');
$loggedinas = '<span class="logininfo">'.user_login_string($course, $USER).'</span>'; $loggedinas = '<span class="logininfo">'.user_login_string($course, $USER).'</span>';
$time = time(); $time = time();
$hppassword = optional_param('hppassword'); $hppassword = optional_param('hppassword');
if (HOTPOT_FIRST_ATTEMPT && !isteacher($course->id)) { if (HOTPOT_FIRST_ATTEMPT && !isteacher($course->id)) {
// check this quiz is available to this student // check this quiz is available to this student
// error message, if quiz is unavailable // error message, if quiz is unavailable
$error = ''; $error = '';
// check quiz is visible // check quiz is visible
if (!hotpot_is_visible($cm)) { if (!hotpot_is_visible($cm)) {
$error = get_string("activityiscurrentlyhidden"); $error = get_string("activityiscurrentlyhidden");
// check network address // check network address
} else if ($hotpot->subnet && !address_in_subnet($_SERVER['REMOTE_ADDR'], $hotpot->subnet)) { } else if ($hotpot->subnet && !address_in_subnet($_SERVER['REMOTE_ADDR'], $hotpot->subnet)) {
$error = get_string("subneterror", "quiz"); $error = get_string("subneterror", "quiz");
// check number of attempts // check number of attempts
} else if ($hotpot->attempts && $hotpot->attempts <= count_records('hotpot_attempts', 'hotpot', $hotpot->id, 'userid', $USER->id)) { } else if ($hotpot->attempts && $hotpot->attempts <= count_records('hotpot_attempts', 'hotpot', $hotpot->id, 'userid', $USER->id)) {
$error = get_string("nomoreattempts", "quiz"); $error = get_string("nomoreattempts", "quiz");
// get password // get password
} else if ($hotpot->password && empty($hppassword)) { } else if ($hotpot->password && empty($hppassword)) {
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas, false); print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas, false);
print_heading($hotpot->name); print_heading($hotpot->name);
$boxalign = 'center'; $boxalign = 'center';
$boxwidth = 500; $boxwidth = 500;
if (trim(strip_tags($hotpot->summary))) { if (trim(strip_tags($hotpot->summary))) {
print_simple_box_start($boxalign, $boxwidth); print_simple_box_start($boxalign, $boxwidth);
print '<div align="center">'.format_text($hotpot->summary)."</div>\n"; print '<div align="center">'.format_text($hotpot->summary)."</div>\n";
print_simple_box_end(); print_simple_box_end();
print "<br />\n"; print "<br />\n";
} }
print '<form name="passwordform" method="post" action="view.php?id='.$cm->id.'">'."\n"; print '<form name="passwordform" method="post" action="view.php?id='.$cm->id.'">'."\n";
print_simple_box_start($boxalign, $boxwidth); print_simple_box_start($boxalign, $boxwidth);
print '<div align="center">'; print '<div align="center">';
print get_string('requirepasswordmessage', 'quiz').'<br /><br />'; print get_string('requirepasswordmessage', 'quiz').'<br /><br />';
print '<b>'.get_string('password').':</b> '; print '<b>'.get_string('password').':</b> ';
print '<input name="hppassword" type="password" value=""> '; print '<input name="hppassword" type="password" value=""> ';
print '<input type="submit" value="'.get_string("ok").'"> '; print '<input type="submit" value="'.get_string("ok").'"> ';
print "</div>\n"; print "</div>\n";
print_simple_box_end(); print_simple_box_end();
print "</form>\n"; print "</form>\n";
print_footer(); print_footer();
exit; exit;
// check password // check password
} else if ($hotpot->password && strcmp($hotpot->password, $hppassword)) { } else if ($hotpot->password && strcmp($hotpot->password, $hppassword)) {
$error = get_string("passworderror", "quiz"); $error = get_string("passworderror", "quiz");
$nextpage = "view.php?id=$cm->id"; $nextpage = "view.php?id=$cm->id";
// check quiz is open // check quiz is open
} else if ($hotpot->timeopen && $hotpot->timeopen > $time) { } else if ($hotpot->timeopen && $hotpot->timeopen > $time) {
$error = get_string("quiznotavailable", "quiz", userdate($hotpot->timeopen))."<br />\n"; $error = get_string("quiznotavailable", "quiz", userdate($hotpot->timeopen))."<br />\n";
// check quiz is not closed // check quiz is not closed
} else if ($hotpot->timeclose && $hotpot->timeclose < $time) { } else if ($hotpot->timeclose && $hotpot->timeclose < $time) {
$error = get_string("quizclosed", "quiz", userdate($hotpot->timeclose))."<br />\n"; $error = get_string("quizclosed", "quiz", userdate($hotpot->timeclose))."<br />\n";
} }
if ($error) { if ($error) {
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas, false); print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas, false);
notice($error, $nextpage); notice($error, $nextpage);
// //
// script stops here, if quiz is unavailable to student // script stops here, if quiz is unavailable to student
// //
} }
} }
$available_msg = ''; $available_msg = '';
if (!empty($hotpot->timeclose) && $hotpot->timeclose > $time) { if (!empty($hotpot->timeclose) && $hotpot->timeclose > $time) {
// quiz is available until 'timeclose' // quiz is available until 'timeclose'
$available_msg = get_string("quizavailable", "quiz", userdate($hotpot->timeclose))."<br />\n"; $available_msg = get_string("quizavailable", "quiz", userdate($hotpot->timeclose))."<br />\n";
} }
// open and parse the source file // open and parse the source file
if(!$hp = new hotpot_xml_quiz($hotpot)) { if(!$hp = new hotpot_xml_quiz($hotpot)) {
error("Quiz is unavailable at the moment"); error("Quiz is unavailable at the moment");
} }
$get_js = optional_param('js'); $get_js = optional_param('js');
$get_css = optional_param('css'); $get_css = optional_param('css');
$framename = optional_param('framename'); $framename = optional_param('framename');
// look for <frameset> (HP5 v5) // look for <frameset> (HP5 v5)
$frameset = ''; $frameset = '';
$frameset_tags = ''; $frameset_tags = '';
if (preg_match_all('|<frameset([^>]*)>(.*?)</frameset>|is', $hp->html, $matches)) { if (preg_match_all('|<frameset([^>]*)>(.*?)</frameset>|is', $hp->html, $matches)) {
$last = count($matches[0])-1; $last = count($matches[0])-1;
$frameset = $matches[2][$last]; $frameset = $matches[2][$last];
$frameset_tags = $matches[1][$last]; $frameset_tags = $matches[1][$last];
} }
// if HTML is being requested ... // if HTML is being requested ...
if (empty($get_js) && empty($get_css)) { if (empty($get_js) && empty($get_css)) {
if (empty($frameset)) { if (empty($frameset)) {
// HP v6 // HP v6
if ($hotpot->navigation==HOTPOT_NAVIGATION_FRAME || $hotpot->navigation==HOTPOT_NAVIGATION_IFRAME) { if ($hotpot->navigation==HOTPOT_NAVIGATION_FRAME || $hotpot->navigation==HOTPOT_NAVIGATION_IFRAME) {
$get_html = ($framename=='main') ? true : false; $get_html = ($framename=='main') ? true : false;
} else { } else {
$get_html = true; $get_html = true;
} }
} else { } else {
// HP5 v5 // HP5 v5
$get_html = empty($framename) ? true : false; $get_html = empty($framename) ? true : false;
} }
if ($get_html) { if ($get_html) {
if (HOTPOT_FIRST_ATTEMPT) { if (HOTPOT_FIRST_ATTEMPT) {
add_to_log($course->id, "hotpot", "view", "view.php?id=$cm->id", "$hotpot->id", "$cm->id"); add_to_log($course->id, "hotpot", "view", "view.php?id=$cm->id", "$hotpot->id", "$cm->id");
$attemptid = hotpot_add_attempt($hotpot->id); $attemptid = hotpot_add_attempt($hotpot->id);
if (! is_numeric($attemptid)) { if (! is_numeric($attemptid)) {
error('Could not insert attempt record: '.$db->ErrorMsg); error('Could not insert attempt record: '.$db->ErrorMsg);
} }
} }
$hp->adjust_media_urls(); $hp->adjust_media_urls();
if (empty($frameset)) { if (empty($frameset)) {
// HP6 v6 // HP6 v6
switch ($hotpot->navigation) { switch ($hotpot->navigation) {
case HOTPOT_NAVIGATION_BUTTONS: case HOTPOT_NAVIGATION_BUTTONS:
// do nothing (i.e. leave buttons as they are) // do nothing (i.e. leave buttons as they are)
break; break;
case HOTPOT_NAVIGATION_GIVEUP: case HOTPOT_NAVIGATION_GIVEUP:
$hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->'); $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
break; break;
default: default:
$hp->remove_nav_buttons(); $hp->remove_nav_buttons();
} }
if (isset($hp->real_outputformat) && $hp->real_outputformat==HOTPOT_OUTPUTFORMAT_MOBILE) { if (isset($hp->real_outputformat) && $hp->real_outputformat==HOTPOT_OUTPUTFORMAT_MOBILE) {
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->', true); $hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->', true);
} else { } else {
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->'); $hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->');
} }
} else { } else {
// HP5 v5 // HP5 v5
switch ($hotpot->navigation) { switch ($hotpot->navigation) {
case HOTPOT_NAVIGATION_BUTTONS: case HOTPOT_NAVIGATION_BUTTONS:
// convert URLs in nav buttons // convert URLs in nav buttons
break; break;
case HOTPOT_NAVIGATION_GIVEUP: case HOTPOT_NAVIGATION_GIVEUP:
// $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->'); // $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
break; break;
default: default:
// remove navigation buttons // remove navigation buttons
$hp->html = preg_replace('#NavBar\+=(.*);#', '', $hp->html); $hp->html = preg_replace('#NavBar\+=(.*);#', '', $hp->html);
} }
$hp->insert_submission_form($attemptid, "var NavBar='", "';"); $hp->insert_submission_form($attemptid, "var NavBar='", "';");
} }
} }
} }
//FEEDBACK = new Array(); //FEEDBACK = new Array();
//FEEDBACK[0] = ''; // url of feedback page/script //FEEDBACK[0] = ''; // url of feedback page/script
//FEEDBACK[1] = ''; // array of array('teachername', 'value'); //FEEDBACK[1] = ''; // array of array('teachername', 'value');
//FEEDBACK[2] = ''; // 'student name' [formmail only] //FEEDBACK[2] = ''; // 'student name' [formmail only]
//FEEDBACK[3] = ''; // 'student email' [formmail only] //FEEDBACK[3] = ''; // 'student email' [formmail only]
//FEEDBACK[4] = ''; // window width //FEEDBACK[4] = ''; // window width
//FEEDBACK[5] = ''; // window height //FEEDBACK[5] = ''; // window height
//FEEDBACK[6] = ''; // 'Send a message to teacher' [prompt/button text] //FEEDBACK[6] = ''; // 'Send a message to teacher' [prompt/button text]
//FEEDBACK[7] = ''; // 'Title' //FEEDBACK[7] = ''; // 'Title'
//FEEDBACK[8] = ''; // 'Teacher' //FEEDBACK[8] = ''; // 'Teacher'
//FEEDBACK[9] = ''; // 'Message' //FEEDBACK[9] = ''; // 'Message'
//FEEDBACK[10] = ''; // 'Close this window' //FEEDBACK[10] = ''; // 'Close this window'
$feedback = array(); $feedback = array();
switch ($hotpot->studentfeedback) { switch ($hotpot->studentfeedback) {
case HOTPOT_FEEDBACK_NONE: case HOTPOT_FEEDBACK_NONE:
// do nothing // do nothing
break; break;
case HOTPOT_FEEDBACK_WEBPAGE: case HOTPOT_FEEDBACK_WEBPAGE:
if (empty($hotpot->studentfeedbackurl)) { if (empty($hotpot->studentfeedbackurl)) {
$hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE; $hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE;
} else { } else {
$feedback[0] = "'$hotpot->studentfeedbackurl'"; $feedback[0] = "'$hotpot->studentfeedbackurl'";
} }
break; break;
case HOTPOT_FEEDBACK_FORMMAIL: case HOTPOT_FEEDBACK_FORMMAIL:
$teachers = hotpot_feedback_teachers($course, $hotpot); $teachers = hotpot_feedback_teachers($course, $hotpot);
if (empty($teachers) || empty($hotpot->studentfeedbackurl)) { if (empty($teachers) || empty($hotpot->studentfeedbackurl)) {
$hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE; $hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE;
} else { } else {
$feedback[0] = "'$hotpot->studentfeedbackurl'"; $feedback[0] = "'$hotpot->studentfeedbackurl'";
$feedback[1] = $teachers; $feedback[1] = $teachers;
$feedback[2] = "'".fullname($USER)."'"; $feedback[2] = "'".fullname($USER)."'";
$feedback[3] = "'".$USER->email."'"; $feedback[3] = "'".$USER->email."'";
$feedback[4] = 500; // width $feedback[4] = 500; // width
$feedback[5] = 300; // height $feedback[5] = 300; // height
} }
break; break;
case HOTPOT_FEEDBACK_MOODLEFORUM: case HOTPOT_FEEDBACK_MOODLEFORUM:
$module = get_record('modules', 'name', 'forum'); $module = get_record('modules', 'name', 'forum');
$forums = get_records('forum', 'course', "$course->id"); $forums = get_records('forum', 'course', "$course->id");
if (empty($module) || empty($module->visible) || empty($forums)) { if (empty($module) || empty($module->visible) || empty($forums)) {
$hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE; $hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE;
} else { } else {
$feedback[0] = "'$CFG->wwwroot/mod/forum/index.php?id=$course->id'"; $feedback[0] = "'$CFG->wwwroot/mod/forum/index.php?id=$course->id'";
} }
break; break;
case HOTPOT_FEEDBACK_MOODLEMESSAGING: case HOTPOT_FEEDBACK_MOODLEMESSAGING:
$teachers = hotpot_feedback_teachers($course, $hotpot); $teachers = hotpot_feedback_teachers($course, $hotpot);
if (empty($CFG->messaging) || empty($teachers)) { if (empty($CFG->messaging) || empty($teachers)) {
$hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE; $hotpot->studentfeedback = HOTPOT_FEEDBACK_NONE;
} else { } else {
$feedback[0] = "'$CFG->wwwroot/message/discussion.php?id='"; $feedback[0] = "'$CFG->wwwroot/message/discussion.php?id='";
$feedback[1] = $teachers; $feedback[1] = $teachers;
$feedback[4] = 400; // width $feedback[4] = 400; // width
$feedback[5] = 500; // height $feedback[5] = 500; // height
} }
break; break;
default: default:
// do nothing // do nothing
} }
if ($hotpot->studentfeedback != HOTPOT_FEEDBACK_NONE) { if ($hotpot->studentfeedback != HOTPOT_FEEDBACK_NONE) {
$feedback[6] = "'Send a message to teacher'"; $feedback[6] = "'Send a message to teacher'";
$feedback[7] = "'Title'"; $feedback[7] = "'Title'";
$feedback[8] = "'Teacher'"; $feedback[8] = "'Teacher'";
$feedback[9] = "'Message'"; $feedback[9] = "'Message'";
$feedback[10] = "'Close this window'"; $feedback[10] = "'Close this window'";
$js = ''; $js = '';
foreach ($feedback as $i=>$str) { foreach ($feedback as $i=>$str) {
$js .= 'FEEDBACK['.$i."] = $str;\n"; $js .= 'FEEDBACK['.$i."] = $str;\n";
} }
$js = '<script type="text/javascript" language="javascript">'."<!--\n"."FEEDBACK = new Array();\n".$js."//--></script>\n"; $js = '<script type="text/javascript" language="javascript">'."<!--\n"."FEEDBACK = new Array();\n".$js."//--></script>\n";
$hp->html = preg_replace('|</head>|i', "$js</head>", $hp->html, 1); $hp->html = preg_replace('|</head>|i', "$js</head>", $hp->html, 1);
} }
// insert hot-potatoes.js // insert hot-potatoes.js
$hp->insert_script(HOTPOT_JS); $hp->insert_script(HOTPOT_JS);
// extract first <head> tag // extract first <head> tag
$head = ''; $head = '';
$pattern = '|<head([^>]*)>(.*?)</head>|is'; $pattern = '|<head([^>]*)>(.*?)</head>|is';
if (preg_match($pattern, $hp->html, $matches)) { if (preg_match($pattern, $hp->html, $matches)) {
$head = $matches[2]; $head = $matches[2];
// remove <title> // remove <title>
$head = preg_replace('|<title[^>]*>(.*?)</title>|is', '', $head); $head = preg_replace('|<title[^>]*>(.*?)</title>|is', '', $head);
} }
// extract <style> tags (and remove from $head) // extract <style> tags (and remove from $head)
$styles = ''; $styles = '';
$pattern = '|<style([^>]*)>(.*?)</style>|is'; $pattern = '|<style([^>]*)>(.*?)</style>|is';
if (preg_match_all($pattern, $head, $matches)) { if (preg_match_all($pattern, $head, $matches)) {
$count = count($matches[0]); $count = count($matches[0]);
for ($i=0; $i<$count; $i++) { for ($i=0; $i<$count; $i++) {
$styles .= $matches[0][$i]."\n"; $styles .= $matches[0][$i]."\n";
$head = str_replace($matches[0][$i], '', $head); $head = str_replace($matches[0][$i], '', $head);
} }
} }
// extract <script> tags (and remove from $head) // extract <script> tags (and remove from $head)
$scripts = ''; $scripts = '';
$pattern = '|<script([^>]*)>(.*?)</script>|is'; $pattern = '|<script([^>]*)>(.*?)</script>|is';
if (preg_match_all($pattern, $head, $matches)) { if (preg_match_all($pattern, $head, $matches)) {
$count = count($matches[0]); $count = count($matches[0]);
for ($i=0; $i<$count; $i++) { for ($i=0; $i<$count; $i++) {
$scripts .= $matches[0][$i]."\n"; $scripts .= $matches[0][$i]."\n";
$head = str_replace($matches[0][$i], '', $head); $head = str_replace($matches[0][$i], '', $head);
} }
} }
// extract <body> tags // extract <body> tags
$body = ''; $body = '';
$body_tags = ''; $body_tags = '';
$footer = '</html>'; $footer = '</html>';
// HP6 and some HP5 (v6 and v4) // HP6 and some HP5 (v6 and v4)
if (preg_match('|<body'.'([^>]*'.'onLoad=(["\'])(.*?)(\\2)'.'[^>]*)'.'>(.*)</body>|is', $hp->html, $matches)) { if (preg_match('|<body'.'([^>]*'.'onLoad=(["\'])(.*?)(\\2)'.'[^>]*)'.'>(.*)</body>|is', $hp->html, $matches)) {
$body = $matches[5]; // contents of first <body onload="StartUp()">...</body> block $body = $matches[5]; // contents of first <body onload="StartUp()">...</body> block
$body_tags = $matches[1]; $body_tags = $matches[1];
// workaround to ensure javascript onload routine for quiz is always executed // workaround to ensure javascript onload routine for quiz is always executed
// $body_tags will only be inserted into the <body ...> tag // $body_tags will only be inserted into the <body ...> tag
// if it is included in the theme/$CFG->theme/header.html, // if it is included in the theme/$CFG->theme/header.html,
// so some old or modified themes may not insert $body_tags // so some old or modified themes may not insert $body_tags
$body .= "" $body .= ""
. '<script type="text/javascript">'."\n" . '<script type="text/javascript">'."\n"
. "<!--\n" . "<!--\n"
. " var s = (typeof(window.onload)=='function') ? onload.toString() : '';\n" . " var s = (typeof(window.onload)=='function') ? onload.toString() : '';\n"
. " if (s.indexOf('".$matches[3]."')<0) {\n" . " if (s.indexOf('".$matches[3]."')<0) {\n"
. " if (s=='') {\n" // no previous onload . " if (s=='') {\n" // no previous onload
. " window.onload = new Function('".$matches[3]."');\n" . " window.onload = new Function('".$matches[3]."');\n"
. " } else {\n" . " } else {\n"
. " window.onload_hotpot = onload;\n" . " window.onload_hotpot = onload;\n"
. " window.onload = new Function('window.onload_hotpot();'+'".$matches[3]."');\n" . " window.onload = new Function('window.onload_hotpot();'+'".$matches[3]."');\n"
. " }\n" . " }\n"
. " }\n" . " }\n"
. "//-->\n" . "//-->\n"
. "</script>\n" . "</script>\n"
; ;
$footer = '</body>'.$footer; $footer = '</body>'.$footer;
} else if ($frameset) { // HP5 v5 } else if ($frameset) { // HP5 v5
switch ($framename) { switch ($framename) {
case 'top': case 'top':
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas); print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas);
print $footer; print $footer;
break; break;
default: default:
// add a HotPot navigation frame at the top of the page // add a HotPot navigation frame at the top of the page
//$rows = empty($CFG->resource_framesize) ? 85 : $CFG->resource_framesize; //$rows = empty($CFG->resource_framesize) ? 85 : $CFG->resource_framesize;
//$frameset = "\n\t".'<frame src="view.php?id='.$cm->id.'&framename=top" frameborder="0" name="top"></frame>'.$frameset; //$frameset = "\n\t".'<frame src="view.php?id='.$cm->id.'&framename=top" frameborder="0" name="top"></frame>'.$frameset;
//$frameset_tags = preg_replace('|rows="(.*?)"|', 'rows="'.$rows.',\\1"', $frameset_tags); //$frameset_tags = preg_replace('|rows="(.*?)"|', 'rows="'.$rows.',\\1"', $frameset_tags);
// put navigation into var NavBar=''; // put navigation into var NavBar='';
// add form to TopFrame in "WriteFeedback" function // add form to TopFrame in "WriteFeedback" function
// OR add form to BottomFrame in "DisplayExercise" function // OR add form to BottomFrame in "DisplayExercise" function
// submission form: '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->' // submission form: '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->'
// give up form: '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->' // give up form: '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->'
print "<html>\n"; print "<html>\n";
print "<head>\n<title>$title</title>\n$styles\n$scripts</head>\n"; print "<head>\n<title>$title</title>\n$styles\n$scripts</head>\n";
print "<frameset$frameset_tags>$frameset</frameset>\n"; print "<frameset$frameset_tags>$frameset</frameset>\n";
print "</html>\n"; print "</html>\n";
break; break;
} // end switch $framename } // end switch $framename
exit; exit;
// other files (maybe not even a HotPots) // other files (maybe not even a HotPots)
} else if (preg_match('|<body'.'([^>]*)'.'>(.*)</body>|is', $hp->html, $matches)) { } else if (preg_match('|<body'.'([^>]*)'.'>(.*)</body>|is', $hp->html, $matches)) {
$body = $matches[2]; $body = $matches[2];
$body_tags = $matches[1]; $body_tags = $matches[1];
} }
// print the quiz to the browser // print the quiz to the browser
if ($get_js) { if ($get_js) {
print($scripts); print($scripts);
exit; exit;
} }
if ($get_css) { if ($get_css) {
print($styles); print($styles);
exit; exit;
} }
switch ($hotpot->navigation) { switch ($hotpot->navigation) {
case HOTPOT_NAVIGATION_BAR: case HOTPOT_NAVIGATION_BAR:
//update_module_button($cm->id, $course->id, $strmodulename.'" style="font-size:0.8em') //update_module_button($cm->id, $course->id, $strmodulename.'" style="font-size:0.8em')
print_header( print_header(
$title, $heading, $navigation, $title, $heading, $navigation,
"", $head.$styles.$scripts, true, $button, "", $head.$styles.$scripts, true, $button,
$loggedinas, false, $body_tags $loggedinas, false, $body_tags
); );
if (!empty($available_msg)) { if (!empty($available_msg)) {
notify($available_msg); notify($available_msg);
} }
print $body.$footer; print $body.$footer;
break; break;
case HOTPOT_NAVIGATION_FRAME: case HOTPOT_NAVIGATION_FRAME:
switch ($framename) { switch ($framename) {
case 'top': case 'top':
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas); print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas);
print $footer; print $footer;
break; break;
case 'main': case 'main':
if (!empty($available_msg)) { if (!empty($available_msg)) {
$hp->insert_message('<!-- BeginTopNavButtons -->', $available_msg); $hp->insert_message('<!-- BeginTopNavButtons -->', $available_msg);
} }
print $hp->html; print $hp->html;
break; break;
default: default:
$rows = empty($CFG->resource_framesize) ? 85 : $CFG->resource_framesize; $rows = empty($CFG->resource_framesize) ? 85 : $CFG->resource_framesize;
print "<html>\n"; print "<html>\n";
print "<head><title>$title</title></head>\n"; print "<head><title>$title</title></head>\n";
print "<frameset rows=$rows,*>\n"; print "<frameset rows=$rows,*>\n";
print "<frame src=\"view.php?id=$cm->id&framename=top\">\n"; print "<frame src=\"view.php?id=$cm->id&framename=top\">\n";
print "<frame src=\"view.php?id=$cm->id&framename=main\">\n"; print "<frame src=\"view.php?id=$cm->id&framename=main\">\n";
print "</frameset>\n"; print "</frameset>\n";
print "</html>\n"; print "</html>\n";
break; break;
} // end switch $framename } // end switch $framename
break; break;
case HOTPOT_NAVIGATION_IFRAME: case HOTPOT_NAVIGATION_IFRAME:
switch ($framename) { switch ($framename) {
case 'main': case 'main':
print $hp->html; print $hp->html;
break; break;
default: default:
$iframe_id = 'hotpot_iframe'; $iframe_id = 'hotpot_iframe';
$body_tags = " onload=\"set_iframe_height('$iframe_id')\""; $body_tags = " onload=\"set_iframe_height('$iframe_id')\"";
$iframe_js = '<script src="iframe.js" type="text/javascript" language="javascript"></script>'."\n"; $iframe_js = '<script src="iframe.js" type="text/javascript" language="javascript"></script>'."\n";
print_header( print_header(
$title, $heading, $navigation, $title, $heading, $navigation,
"", $head.$styles.$scripts.$iframe_js, true, $button, "", $head.$styles.$scripts.$iframe_js, true, $button,
$loggedinas, false, $body_tags $loggedinas, false, $body_tags
); );
if (!empty($available_msg)) { if (!empty($available_msg)) {
notify($available_msg); notify($available_msg);
} }
print "<iframe id=\"$iframe_id\" src=\"view.php?id=$cm->id&framename=main\" height=\"100%\" width=\"100%\">"; print "<iframe id=\"$iframe_id\" src=\"view.php?id=$cm->id&framename=main\" height=\"100%\" width=\"100%\">";
print "<ilayer name=\"$iframe_id\" src=\"view.php?id=$cm->id&framename=main\" height=\"100%\" width=\"100%\">"; print "<ilayer name=\"$iframe_id\" src=\"view.php?id=$cm->id&framename=main\" height=\"100%\" width=\"100%\">";
print "</ilayer>\n"; print "</ilayer>\n";
print "</iframe>\n"; print "</iframe>\n";
print $footer; print $footer;
break; break;
} // end switch $framename } // end switch $framename
break; break;
default: default:
// HOTPOT_NAVIGATION_BUTTONS // HOTPOT_NAVIGATION_BUTTONS
// HOTPOT_NAVIGATION_GIVEUP // HOTPOT_NAVIGATION_GIVEUP
// HOTPOT_NAVIGATION_NONE // HOTPOT_NAVIGATION_NONE
if (!empty($available_msg)) { if (!empty($available_msg)) {
$hp->insert_message('<!-- BeginTopNavButtons -->', $available_msg); $hp->insert_message('<!-- BeginTopNavButtons -->', $available_msg);
} }
print($hp->html); print($hp->html);
} }
/////////////////////////////////// ///////////////////////////////////
/// functions /// functions
/////////////////////////////////// ///////////////////////////////////
function hotpot_feedback_teachers(&$course, &$hotpot) { function hotpot_feedback_teachers(&$course, &$hotpot) {
global $CFG; global $CFG;
$teachers = get_records_sql(" $teachers = get_records_sql("
SELECT SELECT
u.* u.*
FROM FROM
{$CFG->prefix}user AS u, {$CFG->prefix}user AS u,
{$CFG->prefix}user_teachers AS t {$CFG->prefix}user_teachers AS t
WHERE WHERE
t.userid = u.id t.userid = u.id
AND t.course = $course->id AND t.course = $course->id
"); ");
$teacherdetails = ''; $teacherdetails = '';
if (!empty($teachers)) { if (!empty($teachers)) {
$details = array(); $details = array();
foreach ($teachers as $teacher) { foreach ($teachers as $teacher) {
if ($hotpot->studentfeedback==HOTPOT_FEEDBACK_MOODLEMESSAGING) { if ($hotpot->studentfeedback==HOTPOT_FEEDBACK_MOODLEMESSAGING) {
$detail = $teacher->id; $detail = $teacher->id;
} else { } else {
$detail =$teacher->email; $detail =$teacher->email;
} }
$details[] = "new Array('".fullname($teacher)."', '$detail')"; $details[] = "new Array('".fullname($teacher)."', '$detail')";
} }
$teacherdetails = 'new Array('.implode(',', $details).");\n"; $teacherdetails = 'new Array('.implode(',', $details).");\n";
} }
return $teacherdetails; return $teacherdetails;
} }
?> ?>

View file

@ -136,8 +136,8 @@
error('Flash is not supported yet'); error('Flash is not supported yet');
} else if ($mimetype == "audio/x-pn-realaudio") { // It's a realmedia file } else if ($mimetype == "audio/x-pn-realaudio") { // It's a realmedia file
echo '<object id="rvocx" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="600" height="50">'; echo '<object id="rvocx" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="600" height="50">';
echo "<param name=\"src\" value=\"$fullurl\">"; echo "<param name=\"src\" value=\"$fullurl\">";
echo '<param name="console" value="video">'; // not sure what the console param should equal echo '<param name="console" value="video">'; // not sure what the console param should equal
echo '<param name="controls" value="ControlPanel">'; echo '<param name="controls" value="ControlPanel">';

View file

@ -461,9 +461,9 @@ if ($form->mode == "add") {
$select = "course = $course->id AND id != $form->instance"; $select = "course = $course->id AND id != $form->instance";
} }
if ($lessons = get_records_select('lesson', $select, 'name ASC')) { if ($lessons = get_records_select('lesson', $select, 'name ASC')) {
foreach($lessons as $lesson) { foreach($lessons as $lesson) {
$options[$lesson->id] = $lesson->name; $options[$lesson->id] = $lesson->name;
} }
} }
choose_from_menu($options, "dependency", $form->dependency, ""); choose_from_menu($options, "dependency", $form->dependency, "");

View file

@ -493,8 +493,8 @@
var ourForm = document.forms['responseform']; var ourForm = document.forms['responseform'];
ourForm.page.value=page; ourForm.page.value=page;
if (ourForm.onsubmit) { if (ourForm.onsubmit) {
ourForm.onsubmit(); ourForm.onsubmit();
} }
ourForm.submit(); ourForm.submit();
} }
</script> </script>

View file

@ -552,22 +552,22 @@ function quiz_upgrade($oldversion) {
if ($oldversion < 2005051400) { if ($oldversion < 2005051400) {
modify_database('', 'ALTER TABLE prefix_quiz_rqp_type RENAME prefix_quiz_rqp_types;'); modify_database('', 'ALTER TABLE prefix_quiz_rqp_type RENAME prefix_quiz_rqp_types;');
modify_database('', "CREATE TABLE `prefix_quiz_rqp_servers` ( modify_database('', "CREATE TABLE `prefix_quiz_rqp_servers` (
id int(10) unsigned NOT NULL auto_increment, id int(10) unsigned NOT NULL auto_increment,
typeid int(10) unsigned NOT NULL default '0', typeid int(10) unsigned NOT NULL default '0',
url varchar(255) NOT NULL default '', url varchar(255) NOT NULL default '',
can_render tinyint(2) unsigned NOT NULL default '0', can_render tinyint(2) unsigned NOT NULL default '0',
can_author tinyint(2) unsigned NOT NULL default '0', can_author tinyint(2) unsigned NOT NULL default '0',
PRIMARY KEY (id) PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='Information about RQP servers';"); ) TYPE=MyISAM COMMENT='Information about RQP servers';");
if ($types = get_records('quiz_rqp_types')) { if ($types = get_records('quiz_rqp_types')) {
foreach($types as $type) { foreach($types as $type) {
$server->typeid = $type->id; $server->typeid = $type->id;
$server->url = $type->rendering_server; $server->url = $type->rendering_server;
$server->can_render = 1; $server->can_render = 1;
insert_record('quiz_rqp_servers', $server); insert_record('quiz_rqp_servers', $server);
} }
} }
modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP rendering_server'); modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP rendering_server');
modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP cloning_server'); modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP cloning_server');
modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP flags'); modify_database('', 'ALTER TABLE prefix_quiz_rqp_types DROP flags');

View file

@ -1143,7 +1143,7 @@ function quiz_upgrade($oldversion) {
} }
if ($oldversion < 2006032100) { if ($oldversion < 2006032100) {
// change from the old questiontype numbers to using the questiontype names // change from the old questiontype numbers to using the questiontype names
table_column('question', 'qtype', 'qtype', 'varchar', 20, '', '', 'not null'); table_column('question', 'qtype', 'qtype', 'varchar', 20, '', '', 'not null');
set_field('question', 'qtype', 'shortanswer', 'qtype', 1); set_field('question', 'qtype', 'shortanswer', 'qtype', 1);
set_field('question', 'qtype', 'truefalse', 'qtype', 2); set_field('question', 'qtype', 'truefalse', 'qtype', 2);
@ -1362,11 +1362,11 @@ function quiz_upgrade($oldversion) {
modify_database('', 'ALTER TABLE prefix_question_multichoice DROP CONSTRAINT prefix_quiz_multichoice_pkey'); modify_database('', 'ALTER TABLE prefix_question_multichoice DROP CONSTRAINT prefix_quiz_multichoice_pkey');
modify_database('', 'ALTER TABLE prefix_question_multichoice ADD CONSTRAINT prefix_question_multichoice_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_multichoice ADD CONSTRAINT prefix_question_multichoice_pkey PRIMARY KEY (id)');
modify_database('', 'ALTER TABLE prefix_question_rqp_states DROP CONSTRAINT prefix_quiz_rqp_states_pkey'); modify_database('', 'ALTER TABLE prefix_question_rqp_states DROP CONSTRAINT prefix_quiz_rqp_states_pkey');
modify_database('', 'ALTER TABLE prefix_question_rqp_states ADD CONSTRAINT prefix_question_rqp_states_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_rqp_states ADD CONSTRAINT prefix_question_rqp_states_pkey PRIMARY KEY (id)');
modify_database('', 'ALTER TABLE prefix_question_categories DROP CONSTRAINT prefix_quiz_categories_pkey'); modify_database('', 'ALTER TABLE prefix_question_categories DROP CONSTRAINT prefix_quiz_categories_pkey');
modify_database('', 'ALTER TABLE prefix_question_categories ADD CONSTRAINT prefix_question_categories_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_categories ADD CONSTRAINT prefix_question_categories_pkey PRIMARY KEY (id)');
modify_database('', 'ALTER TABLE prefix_question_shortanswer DROP CONSTRAINT prefix_quiz_shortanswer_pkey'); modify_database('', 'ALTER TABLE prefix_question_shortanswer DROP CONSTRAINT prefix_quiz_shortanswer_pkey');
modify_database('', 'ALTER TABLE prefix_question_shortanswer ADD CONSTRAINT prefix_question_shortanswer_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_shortanswer ADD CONSTRAINT prefix_question_shortanswer_pkey PRIMARY KEY (id)');
@ -1377,8 +1377,8 @@ function quiz_upgrade($oldversion) {
modify_database('', 'ALTER TABLE prefix_question_sessions DROP CONSTRAINT prefix_quiz_newest_states_pkey'); modify_database('', 'ALTER TABLE prefix_question_sessions DROP CONSTRAINT prefix_quiz_newest_states_pkey');
modify_database('', 'ALTER TABLE prefix_question_sessions ADD CONSTRAINT prefix_question_sessions_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_sessions ADD CONSTRAINT prefix_question_sessions_pkey PRIMARY KEY (id)');
modify_database('', 'ALTER TABLE prefix_question_calculated DROP CONSTRAINT prefix_quiz_calculated_pkey'); modify_database('', 'ALTER TABLE prefix_question_calculated DROP CONSTRAINT prefix_quiz_calculated_pkey');
modify_database('', 'ALTER TABLE prefix_question_calculated ADD CONSTRAINT prefix_question_calculated_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_calculated ADD CONSTRAINT prefix_question_calculated_pkey PRIMARY KEY (id)');
modify_database('', 'ALTER TABLE prefix_question_answers DROP CONSTRAINT prefix_quiz_answers_pkey'); modify_database('', 'ALTER TABLE prefix_question_answers DROP CONSTRAINT prefix_quiz_answers_pkey');
modify_database('', 'ALTER TABLE prefix_question_answers ADD CONSTRAINT prefix_question_answers_pkey PRIMARY KEY (id)'); modify_database('', 'ALTER TABLE prefix_question_answers ADD CONSTRAINT prefix_question_answers_pkey PRIMARY KEY (id)');

View file

@ -36,7 +36,7 @@
'quiz_fix_timelimit' => 0, 'quiz_fix_timelimit' => 0,
'quiz_fix_adaptive' => 0, 'quiz_fix_adaptive' => 0,
'quiz_fix_penaltyscheme' => 0, 'quiz_fix_penaltyscheme' => 0,
'quiz_fix_delay1' => 0, 'quiz_fix_delay1' => 0,
'quiz_fix_delay2' => 0, 'quiz_fix_delay2' => 0,
); );

View file

@ -85,7 +85,7 @@ body#mod-quiz-grading table#grading td
} }
#mod-quiz-attempt #page { #mod-quiz-attempt #page {
text-align: center; text-align: center;
} }
#mod-quiz-attempt #timer .generalbox { #mod-quiz-attempt #timer .generalbox {

View file

@ -2,7 +2,7 @@
require_once("../../config.php"); require_once("../../config.php");
require_once('locallib.php'); require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID $a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID $scoid = required_param('scoid', PARAM_INT); // sco ID

View file

@ -2,7 +2,7 @@
require_once("../../config.php"); require_once("../../config.php");
require_once('locallib.php'); require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID $a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID $b = optional_param('b', '', PARAM_INT); // SCO ID
@ -58,8 +58,8 @@
$strscorm = get_string("modulename", "scorm"); $strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm"); $strreport = get_string("report", "scorm");
$strname = get_string('name'); $strname = get_string('name');
$strcoefficient = get_string('coefficient',"scorm"); $strcoefficient = get_string('coefficient',"scorm");
$strcoefficient = "Thiet lap he so"; $strcoefficient = "Thiet lap he so";
if (empty($b)) { if (empty($b)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a> "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
@ -77,32 +77,32 @@
$scormpixdir = $CFG->modpixpath.'/scorm/pix'; $scormpixdir = $CFG->modpixpath.'/scorm/pix';
//Phan trinh bay chinh //Phan trinh bay chinh
?> ?>
<?php <?php
$examScoes = get_records_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1'); $examScoes = get_records_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1');
foreach ($examScoes as $examSco){ foreach ($examScoes as $examSco){
$newcoefficient = optional_param($examSco->id,'',PARAM_INT); $newcoefficient = optional_param($examSco->id,'',PARAM_INT);
$sco = get_record('scorm_scoes','scorm',$scorm->id,'id',$examSco->id,'',''); $sco = get_record('scorm_scoes','scorm',$scorm->id,'id',$examSco->id,'','');
$sco->score_coefficient = $newcoefficient; $sco->score_coefficient = $newcoefficient;
$ketqua = update_record('scorm_scoes',$sco); $ketqua = update_record('scorm_scoes',$sco);
//echo "Cap nhat $examSco->id voi he so diem ".$newcoefficient."<br>"; //echo "Cap nhat $examSco->id voi he so diem ".$newcoefficient."<br>";
} }
if ($ketqua) if ($ketqua)
{ {
echo "".get_string('updatesuccess','scorm'); echo "".get_string('updatesuccess','scorm');
} }
else else
{ {
echo "".get_string('updatefail','scorm'); echo "".get_string('updatefail','scorm');
} }
echo "<br><br><a href=coefficientsetting.php?id=$id>".get_string('back','scorm')."</a>" echo "<br><br><a href=coefficientsetting.php?id=$id>".get_string('back','scorm')."</a>"
?> ?>
<?php <?php
//ket thuc phan trinh bay chinh //ket thuc phan trinh bay chinh
if (empty($noheader)) { if (empty($noheader)) {
print_footer($course); print_footer($course);

View file

@ -2,7 +2,7 @@
require_once("../../config.php"); require_once("../../config.php");
require_once('locallib.php'); require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID $a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID $b = optional_param('b', '', PARAM_INT); // SCO ID
@ -58,7 +58,7 @@
$strscorm = get_string("modulename", "scorm"); $strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm"); $strreport = get_string("report", "scorm");
$strname = get_string('name'); $strname = get_string('name');
$strcoefficient = get_string('coefficient','scorm'); $strcoefficient = get_string('coefficient','scorm');
if (empty($b)) { if (empty($b)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a> "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
@ -76,12 +76,12 @@
$scormpixdir = $CFG->modpixpath.'/scorm/pix'; $scormpixdir = $CFG->modpixpath.'/scorm/pix';
//Phan trinh bay chinh //Phan trinh bay chinh
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function validate_form() function validate_form()
{ {
return true; return true;
} }
</script> </script>
<form name="form" method="post" action="coefficientconfirm.php" onsubmit="return validate_form();" > <form name="form" method="post" action="coefficientconfirm.php" onsubmit="return validate_form();" >
@ -92,15 +92,15 @@ function validate_form()
</tr> </tr>
<?php <?php
$examScoes = get_records_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1'); $examScoes = get_records_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1');
if(!empty($examScoes)) if(!empty($examScoes))
{ {
foreach ($examScoes as $examSco){ foreach ($examScoes as $examSco){
echo "<tr><td>"; echo "<tr><td>";
echo "$examSco->identifier.</td><td><input type='text' name='$examSco->id' class='scormtextbox' value=$examSco->score_coefficient /></td></tr><br>"; echo "$examSco->identifier.</td><td><input type='text' name='$examSco->id' class='scormtextbox' value=$examSco->score_coefficient /></td></tr><br>";
} }
} }
?> ?>
</table> </table>
@ -109,7 +109,7 @@ function validate_form()
<input type="submit" value="<?php print_string('savechanges') ?>" /> <input type="submit" value="<?php print_string('savechanges') ?>" />
</form> </form>
<?php <?php
//ket thuc phan trinh bay chinh //ket thuc phan trinh bay chinh
if (empty($noheader)) { if (empty($noheader)) {
print_footer($course); print_footer($course);

View file

@ -91,7 +91,7 @@ function SCORMapi1_3() {
'cmi.learner_preference.language':{'defaultvalue':'', 'format':CMIString250, 'mod':'rw'}, 'cmi.learner_preference.language':{'defaultvalue':'', 'format':CMIString250, 'mod':'rw'},
'cmi.learner_preference.delivery_speed':{'defaultvalue':'0', 'format':CMIDecimal, 'range':speed_range, 'mod':'rw'}, 'cmi.learner_preference.delivery_speed':{'defaultvalue':'0', 'format':CMIDecimal, 'range':speed_range, 'mod':'rw'},
'cmi.learner_preference.audio_caption':{'defaultvalue':'0', 'format':CMISInteger, 'range':text_range, 'mod':'rw'}, 'cmi.learner_preference.audio_caption':{'defaultvalue':'0', 'format':CMISInteger, 'range':text_range, 'mod':'rw'},
'cmi.location':{'defaultvalue':<?php echo isset($userdata->{'cmi.location'})?'\''.$userdata->{'cmi.location'}.'\'':'null' ?>, 'format':CMIString1000, 'mod':'rw'}, 'cmi.location':{'defaultvalue':<?php echo isset($userdata->{'cmi.location'})?'\''.$userdata->{'cmi.location'}.'\'':'null' ?>, 'format':CMIString1000, 'mod':'rw'},
'cmi.max_time_allowed':{'defaultvalue':<?php echo isset($userdata->maxtimeallowed)?'\''.$userdata->maxtimeallowed.'\'':'null' ?>, 'mod':'r'}, 'cmi.max_time_allowed':{'defaultvalue':<?php echo isset($userdata->maxtimeallowed)?'\''.$userdata->maxtimeallowed.'\'':'null' ?>, 'mod':'r'},
'cmi.mode':{'defaultvalue':'<?php echo $userdata->mode ?>', 'mod':'r'}, 'cmi.mode':{'defaultvalue':'<?php echo $userdata->mode ?>', 'mod':'r'},
'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r'}, 'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r'},

View file

@ -189,7 +189,7 @@ function scorm_upgrade($oldversion) {
foreach($scorms as $scorm) { foreach($scorms as $scorm) {
if ($scorm->browsemode = 1) { if ($scorm->browsemode = 1) {
$scorm->hidebrowse = 0; $scorm->hidebrowse = 0;
} else { } else {
$scorm->hidebrowse = 1; $scorm->hidebrowse = 1;
} }
update_record('scorm',$scorm); update_record('scorm',$scorm);

View file

@ -205,7 +205,7 @@ function scorm_upgrade($oldversion) {
foreach($scorms as $scorm) { foreach($scorms as $scorm) {
if ($scorm->browsemode = 1) { if ($scorm->browsemode = 1) {
$scorm->hidebrowse = 0; $scorm->hidebrowse = 0;
} else { } else {
$scorm->hidebrowse = 1; $scorm->hidebrowse = 1;
} }
update_record('scorm',$scorm); update_record('scorm',$scorm);

View file

@ -71,8 +71,8 @@
} else if (isstudent($course->id)) { } else if (isstudent($course->id)) {
require_once('locallib.php'); require_once('locallib.php');
$report = scorm_grade_user_new(get_records('scorm_scoes','scorm',$scorm->id), $USER->id, $scorm->grademethod); $report = scorm_grade_user_new(get_records('scorm_scoes','scorm',$scorm->id), $USER->id, $scorm->grademethod);
$sco_count = scorm_get_user_sco_count($scorm->id,$USER->id); $sco_count = scorm_get_user_sco_count($scorm->id,$USER->id);
$reportshow = get_string('implement','scorm').$sco_count.get_string('lesson','scorm') ."<br><table width=".($report*100)."% bgcolor=#800000><tr><td height=15></td></tr></table>".get_string('scoreRate','scorm').": ".($report*100)."%"; } $reportshow = get_string('implement','scorm').$sco_count.get_string('lesson','scorm') ."<br><table width=".($report*100)."% bgcolor=#800000><tr><td height=15></td></tr></table>".get_string('scoreRate','scorm').": ".($report*100)."%"; }
if (!$scorm->visible) { if (!$scorm->visible) {
//Show dimmed if the mod is hidden //Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>", $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",

View file

@ -112,10 +112,10 @@ function scorm_update_instance($scorm) {
// Check if scorm manifest needs to be reparsed // Check if scorm manifest needs to be reparsed
if ($scorm->launch == 0) { if ($scorm->launch == 0) {
//$f = "D:\\test.txt"; //$f = "D:\\test.txt";
//@$ft = fopen($f,"a"); //@$ft = fopen($f,"a");
//fwrite($ft,"\n Xu ly trong update trong lib.php \n"); //fwrite($ft,"\n Xu ly trong update trong lib.php \n");
//fwrite($ft,"\n Lauch co gia tri \n".($scorm->launch)); //fwrite($ft,"\n Lauch co gia tri \n".($scorm->launch));
// Delete old related records // Delete old related records
delete_records('scorm_scoes','scorm',$scorm->id); delete_records('scorm_scoes','scorm',$scorm->id);
@ -124,9 +124,9 @@ function scorm_update_instance($scorm) {
delete_records('scorm_sequencing_rolluprules','scormid',$scorm->id); delete_records('scorm_sequencing_rolluprules','scormid',$scorm->id);
delete_records('scorm_sequencing_rolluprule','scormid',$scorm->id); delete_records('scorm_sequencing_rolluprule','scormid',$scorm->id);
delete_records('scorm_sequencing_rollupruleconditions','scormid',$scorm->id); delete_records('scorm_sequencing_rollupruleconditions','scormid',$scorm->id);
delete_records('scorm_sequencing_rolluprulecondition','scormid',$scorm->id); delete_records('scorm_sequencing_rolluprulecondition','scormid',$scorm->id);
delete_records('scorm_sequencing_ruleconditions','scormid',$scorm->id); delete_records('scorm_sequencing_ruleconditions','scormid',$scorm->id);
delete_records('scorm_sequencing_rulecondition','scormid',$scorm->id); delete_records('scorm_sequencing_rulecondition','scormid',$scorm->id);
$scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm'; $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
@ -193,7 +193,7 @@ function scorm_delete_instance($id) {
} }
if (! delete_records('scorm_sequencing_ruleconditions', 'scormid', $scorm->id)) { if (! delete_records('scorm_sequencing_ruleconditions', 'scormid', $scorm->id)) {
$result = false; $result = false;
} }
return $result; return $result;
} }
@ -220,8 +220,8 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
require_once('locallib.php'); require_once('locallib.php');
foreach ($scoes as $sco) { foreach ($scoes as $sco) {
if ($sco->launch!='') { if ($sco->launch!='') {
$scores->count++; $scores->count++;
if ($userdata = scorm_get_tracks($sco->id, $user->id)) { if ($userdata = scorm_get_tracks($sco->id, $user->id)) {
if (!isset($scores->{$userdata->status})) { if (!isset($scores->{$userdata->status})) {
$scores->{$userdata->status} = 1; $scores->{$userdata->status} = 1;
} else { } else {
@ -240,7 +240,7 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
} }
switch ($scorm->grademethod) { switch ($scorm->grademethod) {
case GRADEHIGHEST: case GRADEHIGHEST:
if ($scores->values > 0) { if ($scores->values > 0) {
$return->info = get_string('score','scorm').':&nbsp;'.$scores->max; $return->info = get_string('score','scorm').':&nbsp;'.$scores->max;
$return->time = $scores->lastmodify; $return->time = $scores->lastmodify;
} }
@ -261,30 +261,30 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
$return->info = ''; $return->info = '';
$scores->notattempted = $scores->count; $scores->notattempted = $scores->count;
if (isset($scores->completed)) { if (isset($scores->completed)) {
$return->info .= get_string('completed','scorm').':&nbsp;'.$scores->completed.'<br />'; $return->info .= get_string('completed','scorm').':&nbsp;'.$scores->completed.'<br />';
$scores->notattempted -= $scores->completed; $scores->notattempted -= $scores->completed;
} }
if (isset($scores->passed)) { if (isset($scores->passed)) {
$return->info .= get_string('passed','scorm').':&nbsp;'.$scores->passed.'<br />'; $return->info .= get_string('passed','scorm').':&nbsp;'.$scores->passed.'<br />';
$scores->notattempted -= $scores->passed; $scores->notattempted -= $scores->passed;
} }
if (isset($scores->failed)) { if (isset($scores->failed)) {
$return->info .= get_string('failed','scorm').':&nbsp;'.$scores->failed.'<br />'; $return->info .= get_string('failed','scorm').':&nbsp;'.$scores->failed.'<br />';
$scores->notattempted -= $scores->failed; $scores->notattempted -= $scores->failed;
} }
if (isset($scores->incomplete)) { if (isset($scores->incomplete)) {
$return->info .= get_string('incomplete','scorm').':&nbsp;'.$scores->incomplete.'<br />'; $return->info .= get_string('incomplete','scorm').':&nbsp;'.$scores->incomplete.'<br />';
$scores->notattempted -= $scores->incomplete; $scores->notattempted -= $scores->incomplete;
} }
if (isset($scores->browsed)) { if (isset($scores->browsed)) {
$return->info .= get_string('browsed','scorm').':&nbsp;'.$scores->browsed.'<br />'; $return->info .= get_string('browsed','scorm').':&nbsp;'.$scores->browsed.'<br />';
$scores->notattempted -= $scores->browsed; $scores->notattempted -= $scores->browsed;
} }
$return->time = $scores->lastmodify; $return->time = $scores->lastmodify;
if ($return->info == '') { if ($return->info == '') {
$return = NULL; $return = NULL;
} else { } else {
$return->info .= get_string('notattempted','scorm').':&nbsp;'.$scores->notattempted.'<br />'; $return->info .= get_string('notattempted','scorm').':&nbsp;'.$scores->notattempted.'<br />';
} }
break; break;
} }
@ -422,7 +422,7 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
echo get_string('report','scorm').":<br />\n"; echo get_string('report','scorm').":<br />\n";
echo $report; echo $report;
} else { } else {
print_string('noactivity','scorm'); print_string('noactivity','scorm');
} }
return true; return true;

View file

@ -1,7 +1,7 @@
<?php <?php
require_once("../../config.php"); require_once("../../config.php");
require_once('locallib.php'); require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID $a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID $scoid = required_param('scoid', PARAM_INT); // sco ID

View file

@ -145,8 +145,8 @@
result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs); result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
} }
alert(result); alert(result);
alert("Khong tuan chuan Scorm"); alert("Khong tuan chuan Scorm");
document.form.name.focus(); document.form.name.focus();
return false; return false;
} }

View file

@ -4,7 +4,7 @@
require_once("../../config.php"); require_once("../../config.php");
require_once('locallib.php'); require_once('locallib.php');
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // SCORM ID $a = optional_param('a', '', PARAM_INT); // SCORM ID
$b = optional_param('b', '', PARAM_INT); // SCO ID $b = optional_param('b', '', PARAM_INT); // SCO ID
@ -314,54 +314,54 @@
error('Missing script parameter'); error('Missing script parameter');
} }
} }
print_heading(format_string(get_string('timestatistic','scorm'))); print_heading(format_string(get_string('timestatistic','scorm')));
$scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid"); $scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid");
$attempt = scorm_get_last_attempt($scorm->id,$USER->id); $attempt = scorm_get_last_attempt($scorm->id,$USER->id);
foreach($scousers as $scouser){ foreach($scousers as $scouser){
$str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc'; $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc';
$endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified'); $endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified');
} }
//Phan trinh bay thong ke theo thoi gian //Phan trinh bay thong ke theo thoi gian
$table = new stdClass(); $table = new stdClass();
$table->head = array('&nbsp;', get_string('name','scorm')); $table->head = array('&nbsp;', get_string('name','scorm'));
$table->align = array('center', 'left'); $table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap'); $table->wrap = array('nowrap', 'nowrap');
$table->width = '100%'; $table->width = '100%';
$table->size = array(10, '*'); $table->size = array(10, '*');
$table->head[]=scorm_string_wrap(get_string('beginTime','scorm')); $table->head[]=scorm_string_wrap(get_string('beginTime','scorm'));
$table->align[] = 'center'; $table->align[] = 'center';
$table->wrap[] = 'nowrap'; $table->wrap[] = 'nowrap';
$table->size[] = '*'; $table->size[] = '*';
$table->head[]=scorm_string_wrap(get_string('endTime','scorm')); $table->head[]=scorm_string_wrap(get_string('endTime','scorm'));
$table->align[] = 'center'; $table->align[] = 'center';
$table->wrap[] = 'nowrap'; $table->wrap[] = 'nowrap';
$table->size[] = '*'; $table->size[] = '*';
$row = array(); $row = array();
$row[] = ""; $row[] = "";
$row[] = "(".get_string('coefficient','scorm').")"; $row[] = "(".get_string('coefficient','scorm').")";
foreach($scousers as $scouser){ foreach($scousers as $scouser){
$userdata = scorm_get_user_data($scouser->userid); $userdata = scorm_get_user_data($scouser->userid);
$row = array(); $row = array();
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". $row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>"; "$userdata->firstname $userdata->lastname</a>";
$str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc'; $str = 'scormid ='.($scorm->id).' and userid = '.$scouser->userid.' and attempt = '.$attempt.' ORDER BY timemodified asc';
$begintrack = get_record_select("scorm_scoes_track", $str,'min(timemodified) as mintimemodified'); $begintrack = get_record_select("scorm_scoes_track", $str,'min(timemodified) as mintimemodified');
$row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $begintrack->mintimemodified); $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $begintrack->mintimemodified);
$endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified'); $endtrack = get_record_select("scorm_scoes_track", $str,'max(timemodified) as maxtimemodified');
$row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $endtrack->maxtimemodified); $row[] = strftime( "%H h -%M ' - %S s - %d -%m-%Y", $endtrack->maxtimemodified);
$table->data[] = $row; $table->data[] = $row;
} }
print_table($table); print_table($table);
echo "<br><a href='viewScore.php?a=$scorm->id'>".format_string(get_string('viewscore','scorm'))."</a>"; echo "<br><a href='viewScore.php?a=$scorm->id'>".format_string(get_string('viewscore','scorm'))."</a>";
if (empty($noheader)) { if (empty($noheader)) {
print_footer($course); print_footer($course);
} }

View file

@ -29,60 +29,60 @@
#-- I'm sorry for that, but all the @ annoy me #-- I'm sorry for that, but all the @ annoy me
error_reporting(0x0000377 & error_reporting()); error_reporting(0x0000377 & error_reporting());
# error_reporting(E_ALL^E_NOTICE); # error_reporting(E_ALL^E_NOTICE);
#-- the position of your ewiki-wrapper script #-- the position of your ewiki-wrapper script
define("EWIKI_SCRIPT", "?id="); # relative/absolute to docroot define("EWIKI_SCRIPT", "?id="); # relative/absolute to docroot
# define("EWIKI_SCRIPT_URL", "http://...?id="); # absolute URL # define("EWIKI_SCRIPT_URL", "http://...?id="); # absolute URL
#-- change to your needs (site lang) #-- change to your needs (site lang)
define("EWIKI_NAME", "ErfurtWiki"); define("EWIKI_NAME", "ErfurtWiki");
define("EWIKI_PAGE_INDEX", "ErfurtWiki"); define("EWIKI_PAGE_INDEX", "ErfurtWiki");
define("EWIKI_PAGE_NEWEST", "NewestPages"); define("EWIKI_PAGE_NEWEST", "NewestPages");
define("EWIKI_PAGE_SEARCH", "SearchPages"); define("EWIKI_PAGE_SEARCH", "SearchPages");
define("EWIKI_PAGE_HITS", "MostVisitedPages"); define("EWIKI_PAGE_HITS", "MostVisitedPages");
define("EWIKI_PAGE_VERSIONS", "MostOftenChangedPages"); define("EWIKI_PAGE_VERSIONS", "MostOftenChangedPages");
define("EWIKI_PAGE_UPDATES", "UpdatedPages"); define("EWIKI_PAGE_UPDATES", "UpdatedPages");
#-- default settings are good settings - most often ;) #-- default settings are good settings - most often ;)
#- look & feel #- look & feel
define("EWIKI_PRINT_TITLE", 1); # <h2>WikiPageName</h2> on top define("EWIKI_PRINT_TITLE", 1); # <h2>WikiPageName</h2> on top
define("EWIKI_SPLIT_TITLE", 0); # <h2>Wiki Page Name</h2> define("EWIKI_SPLIT_TITLE", 0); # <h2>Wiki Page Name</h2>
define("EWIKI_CONTROL_LINE", 1); # EditThisPage-link at bottom define("EWIKI_CONTROL_LINE", 1); # EditThisPage-link at bottom
define("EWIKI_LIST_LIMIT", 20); # listing limit define("EWIKI_LIST_LIMIT", 20); # listing limit
#- behaviour #- behaviour
define("EWIKI_AUTO_EDIT", 1); # edit box for non-existent pages define("EWIKI_AUTO_EDIT", 1); # edit box for non-existent pages
define("EWIKI_EDIT_REDIRECT", 1); # redirect after edit save define("EWIKI_EDIT_REDIRECT", 1); # redirect after edit save
define("EWIKI_DEFAULT_ACTION", "view"); # (keep!) define("EWIKI_DEFAULT_ACTION", "view"); # (keep!)
define("EWIKI_CASE_INSENSITIVE", 1); # wikilink case sensitivity define("EWIKI_CASE_INSENSITIVE", 1); # wikilink case sensitivity
define("EWIKI_HIT_COUNTING", 1); define("EWIKI_HIT_COUNTING", 1);
define("UNIX_MILLENNIUM", 1000000000); define("UNIX_MILLENNIUM", 1000000000);
#- rendering #- rendering
define("EWIKI_ALLOW_HTML", 0); # often a very bad idea define("EWIKI_ALLOW_HTML", 0); # often a very bad idea
define("EWIKI_HTML_CHARS", 1); # allows for &#200; define("EWIKI_HTML_CHARS", 1); # allows for &#200;
define("EWIKI_ESCAPE_AT", 1); # "@" -> "&#x40;" define("EWIKI_ESCAPE_AT", 1); # "@" -> "&#x40;"
#- http/urls #- http/urls
define("EWIKI_HTTP_HEADERS", 1); # most often a good thing define("EWIKI_HTTP_HEADERS", 1); # most often a good thing
define("EWIKI_NO_CACHE", 1); # browser+proxy shall not cache define("EWIKI_NO_CACHE", 1); # browser+proxy shall not cache
define("EWIKI_URLENCODE", 1); # disable when _USE_PATH_INFO define("EWIKI_URLENCODE", 1); # disable when _USE_PATH_INFO
define("EWIKI_URLDECODE", 1); define("EWIKI_URLDECODE", 1);
define("EWIKI_USE_PATH_INFO", 1 &&!strstr($_SERVER["SERVER_SOFTWARE"],"Apache")); define("EWIKI_USE_PATH_INFO", 1 &&!strstr($_SERVER["SERVER_SOFTWARE"],"Apache"));
define("EWIKI_USE_ACTION_PARAM", 1); define("EWIKI_USE_ACTION_PARAM", 1);
define("EWIKI_ACTION_SEP_CHAR", "/"); define("EWIKI_ACTION_SEP_CHAR", "/");
define("EWIKI_UP_PAGENUM", "n"); # _UP_ means "url parameter" define("EWIKI_UP_PAGENUM", "n"); # _UP_ means "url parameter"
define("EWIKI_UP_PAGEEND", "e"); define("EWIKI_UP_PAGEEND", "e");
define("EWIKI_UP_BINARY", "binary"); define("EWIKI_UP_BINARY", "binary");
define("EWIKI_UP_UPLOAD", "upload"); define("EWIKI_UP_UPLOAD", "upload");
#- other stuff #- other stuff
define("EWIKI_DEFAULT_LANG", "en"); define("EWIKI_DEFAULT_LANG", "en");
define("EWIKI_CHARSET", current_charset()); define("EWIKI_CHARSET", current_charset());
#- user permissions #- user permissions
define("EWIKI_PROTECTED_MODE", 0); # disable funcs + require auth define("EWIKI_PROTECTED_MODE", 0); # disable funcs + require auth
define("EWIKI_PROTECTED_MODE_HIDING", 0); # hides disallowed actions define("EWIKI_PROTECTED_MODE_HIDING", 0); # hides disallowed actions
define("EWIKI_AUTH_DEFAULT_RING", 3); # 0=root 1=priv 2=user 3=view define("EWIKI_AUTH_DEFAULT_RING", 3); # 0=root 1=priv 2=user 3=view
define("EWIKI_AUTO_LOGIN", 1); # [auth_query] on startup define("EWIKI_AUTO_LOGIN", 1); # [auth_query] on startup
#-- allowed WikiPageNameCharacters #-- allowed WikiPageNameCharacters
#### BEGIN MOODLE CHANGES - to remove auto-camelcase linking. #### BEGIN MOODLE CHANGES - to remove auto-camelcase linking.
global $moodle_disable_camel_case; global $moodle_disable_camel_case;
@ -93,72 +93,72 @@
else { else {
#### END MOODLE CHANGES #### END MOODLE CHANGES
define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377"); define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377");
define("EWIKI_CHARS_U", "A-Z0-9\300-\336"); define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
#### BEGIN MOODLE CHANGES #### BEGIN MOODLE CHANGES
} }
#### END MOODLE CHANGES #### END MOODLE CHANGES
define("EWIKI_CHARS", EWIKI_CHARS_L.EWIKI_CHARS_U); define("EWIKI_CHARS", EWIKI_CHARS_L.EWIKI_CHARS_U);
#-- database #-- database
define("EWIKI_DB_TABLE_NAME", "ewiki"); # MySQL / ADOdb define("EWIKI_DB_TABLE_NAME", "ewiki"); # MySQL / ADOdb
define("EWIKI_DBFILES_DIRECTORY", "/tmp"); # see "db_flat_files.php" define("EWIKI_DBFILES_DIRECTORY", "/tmp"); # see "db_flat_files.php"
define("EWIKI_DBA", "/tmp/ewiki.dba"); # see "db_dba.php" define("EWIKI_DBA", "/tmp/ewiki.dba"); # see "db_dba.php"
define("EWIKI_DBQUERY_BUFFER", 512*1024); # 512K define("EWIKI_DBQUERY_BUFFER", 512*1024); # 512K
define("EWIKI_INIT_PAGES", "./init-pages"); # for initialization define("EWIKI_INIT_PAGES", "./init-pages"); # for initialization
define("EWIKI_DB_F_TEXT", 1<<0); define("EWIKI_DB_F_TEXT", 1<<0);
define("EWIKI_DB_F_BINARY", 1<<1); define("EWIKI_DB_F_BINARY", 1<<1);
define("EWIKI_DB_F_DISABLED", 1<<2); define("EWIKI_DB_F_DISABLED", 1<<2);
define("EWIKI_DB_F_HTML", 1<<3); define("EWIKI_DB_F_HTML", 1<<3);
define("EWIKI_DB_F_READONLY", 1<<4); define("EWIKI_DB_F_READONLY", 1<<4);
define("EWIKI_DB_F_WRITEABLE", 1<<5); define("EWIKI_DB_F_WRITEABLE", 1<<5);
define("EWIKI_DB_F_APPENDONLY", 1<<6); #nyi define("EWIKI_DB_F_APPENDONLY", 1<<6); #nyi
define("EWIKI_DB_F_SYSTEM", 1<<7); define("EWIKI_DB_F_SYSTEM", 1<<7);
define("EWIKI_DB_F_PART", 1<<8); define("EWIKI_DB_F_PART", 1<<8);
define("EWIKI_DB_F_TYPE", EWIKI_DB_F_TEXT | EWIKI_DB_F_BINARY | EWIKI_DB_F_DISABLED | EWIKI_DB_F_SYSTEM | EWIKI_DB_F_PART); define("EWIKI_DB_F_TYPE", EWIKI_DB_F_TEXT | EWIKI_DB_F_BINARY | EWIKI_DB_F_DISABLED | EWIKI_DB_F_SYSTEM | EWIKI_DB_F_PART);
define("EWIKI_DB_F_ACCESS", EWIKI_DB_F_READONLY | EWIKI_DB_F_WRITEABLE | EWIKI_DB_F_APPENDONLY); define("EWIKI_DB_F_ACCESS", EWIKI_DB_F_READONLY | EWIKI_DB_F_WRITEABLE | EWIKI_DB_F_APPENDONLY);
define("EWIKI_DB_F_COPYMASK", EWIKI_DB_F_TYPE | EWIKI_DB_F_ACCESS); define("EWIKI_DB_F_COPYMASK", EWIKI_DB_F_TYPE | EWIKI_DB_F_ACCESS);
define("EWIKI_DBFILES_NLR", '\\n'); define("EWIKI_DBFILES_NLR", '\\n');
define("EWIKI_DBFILES_ENCODE", 0 || (DIRECTORY_SEPARATOR != "/")); define("EWIKI_DBFILES_ENCODE", 0 || (DIRECTORY_SEPARATOR != "/"));
define("EWIKI_DBFILES_GZLEVEL", "2"); define("EWIKI_DBFILES_GZLEVEL", "2");
#-- internal #-- internal
define("EWIKI_ADDPARAMDELIM", (strstr(EWIKI_SCRIPT,"?") ? "&" : "?")); define("EWIKI_ADDPARAMDELIM", (strstr(EWIKI_SCRIPT,"?") ? "&" : "?"));
#-- binary content (images) #-- binary content (images)
define("EWIKI_SCRIPT_BINARY", /*"/binary.php?binary="*/ ltrim(strtok(" ".EWIKI_SCRIPT,"?"))."?".EWIKI_UP_BINARY."=" ); define("EWIKI_SCRIPT_BINARY", /*"/binary.php?binary="*/ ltrim(strtok(" ".EWIKI_SCRIPT,"?"))."?".EWIKI_UP_BINARY."=" );
define("EWIKI_CACHE_IMAGES", 1 &&!headers_sent()); define("EWIKI_CACHE_IMAGES", 1 &&!headers_sent());
define("EWIKI_IMAGE_MAXSIZE", 64 *1024); define("EWIKI_IMAGE_MAXSIZE", 64 *1024);
define("EWIKI_IMAGE_MAXWIDTH", 3072); define("EWIKI_IMAGE_MAXWIDTH", 3072);
define("EWIKI_IMAGE_MAXHEIGHT", 2048); define("EWIKI_IMAGE_MAXHEIGHT", 2048);
define("EWIKI_IMAGE_MAXALLOC", 1<<19); define("EWIKI_IMAGE_MAXALLOC", 1<<19);
define("EWIKI_IMAGE_RESIZE", 1); define("EWIKI_IMAGE_RESIZE", 1);
define("EWIKI_IMAGE_ACCEPT", "image/jpeg,image/png,image/gif,application/x-shockwave-flash"); define("EWIKI_IMAGE_ACCEPT", "image/jpeg,image/png,image/gif,application/x-shockwave-flash");
define("EWIKI_IDF_INTERNAL", "internal://"); define("EWIKI_IDF_INTERNAL", "internal://");
define("EWIKI_ACCEPT_BINARY", 0); # for arbitrary binary data files define("EWIKI_ACCEPT_BINARY", 0); # for arbitrary binary data files
#-- misc #-- misc
define("EWIKI_TMP", $_SERVER["TEMP"] ? $_SERVER["TEMP"] : "/tmp"); define("EWIKI_TMP", $_SERVER["TEMP"] ? $_SERVER["TEMP"] : "/tmp");
define("EWIKI_LOGLEVEL", -1); # 0=error 1=warn 2=info 3=debug define("EWIKI_LOGLEVEL", -1); # 0=error 1=warn 2=info 3=debug
define("EWIKI_LOGFILE", "/tmp/ewiki.log"); define("EWIKI_LOGFILE", "/tmp/ewiki.log");
#-- plugins (tasks mapped to function names) #-- plugins (tasks mapped to function names)
$ewiki_plugins["database"][] = "ewiki_database_mysql"; $ewiki_plugins["database"][] = "ewiki_database_mysql";
$ewiki_plugins["edit_preview"][] = "ewiki_page_edit_preview"; $ewiki_plugins["edit_preview"][] = "ewiki_page_edit_preview";
$ewiki_plugins["render"][] = "ewiki_format"; $ewiki_plugins["render"][] = "ewiki_format";
$ewiki_plugins["init"][-5] = "ewiki_localization"; $ewiki_plugins["init"][-5] = "ewiki_localization";
$ewiki_plugins["init"][-1] = "ewiki_binary"; $ewiki_plugins["init"][-1] = "ewiki_binary";
$ewiki_plugins["handler"][-105] = "ewiki_eventually_initialize"; $ewiki_plugins["handler"][-105] = "ewiki_eventually_initialize";
$ewiki_plugins["handler"][] = "ewiki_intermap_walking"; $ewiki_plugins["handler"][] = "ewiki_intermap_walking";
$ewiki_plugins["view_append"][-1] = "ewiki_control_links"; $ewiki_plugins["view_append"][-1] = "ewiki_control_links";
$ewiki_plugins["view_final"][-1] = "ewiki_add_title"; $ewiki_plugins["view_final"][-1] = "ewiki_add_title";
$ewiki_plugins["page_final"][] = "ewiki_http_headers"; $ewiki_plugins["page_final"][] = "ewiki_http_headers";
$ewiki_plugins["page_final"][99115115] = "ewiki_page_css_container"; $ewiki_plugins["page_final"][99115115] = "ewiki_page_css_container";
$ewiki_plugins["edit_form_final"][] = "ewiki_page_edit_form_final_imgupload"; $ewiki_plugins["edit_form_final"][] = "ewiki_page_edit_form_final_imgupload";
$ewiki_plugins["format_block"]["pre"][] = "ewiki_format_pre"; $ewiki_plugins["format_block"]["pre"][] = "ewiki_format_pre";
$ewiki_plugins["format_block"]["code"][] = "ewiki_format_pre"; $ewiki_plugins["format_block"]["code"][] = "ewiki_format_pre";
$ewiki_plugins["format_block"]["htm"][] = "ewiki_format_html"; $ewiki_plugins["format_block"]["htm"][] = "ewiki_format_html";
@ -166,36 +166,36 @@
$ewiki_plugins["format_block"]["comment"][] = "ewiki_format_comment"; $ewiki_plugins["format_block"]["comment"][] = "ewiki_format_comment";
#-- internal pages #-- internal pages
$ewiki_plugins["page"][EWIKI_PAGE_NEWEST] = "ewiki_page_newest"; $ewiki_plugins["page"][EWIKI_PAGE_NEWEST] = "ewiki_page_newest";
$ewiki_plugins["page"][EWIKI_PAGE_SEARCH] = "ewiki_page_search"; $ewiki_plugins["page"][EWIKI_PAGE_SEARCH] = "ewiki_page_search";
if (EWIKI_HIT_COUNTING) $ewiki_plugins["page"][EWIKI_PAGE_HITS] = "ewiki_page_hits"; if (EWIKI_HIT_COUNTING) $ewiki_plugins["page"][EWIKI_PAGE_HITS] = "ewiki_page_hits";
$ewiki_plugins["page"][EWIKI_PAGE_VERSIONS] = "ewiki_page_versions"; $ewiki_plugins["page"][EWIKI_PAGE_VERSIONS] = "ewiki_page_versions";
$ewiki_plugins["page"][EWIKI_PAGE_UPDATES] = "ewiki_page_updates"; $ewiki_plugins["page"][EWIKI_PAGE_UPDATES] = "ewiki_page_updates";
#-- page actions #-- page actions
$ewiki_plugins["action"]["edit"] = "ewiki_page_edit"; $ewiki_plugins["action"]["edit"] = "ewiki_page_edit";
$ewiki_plugins["action_always"]["links"] = "ewiki_page_links"; $ewiki_plugins["action_always"]["links"] = "ewiki_page_links";
$ewiki_plugins["action"]["info"] = "ewiki_page_info"; $ewiki_plugins["action"]["info"] = "ewiki_page_info";
$ewiki_plugins["action"]["view"] = "ewiki_page_view"; $ewiki_plugins["action"]["view"] = "ewiki_page_view";
#-- helper vars --------------------------------------------------- #-- helper vars ---------------------------------------------------
$ewiki_config["idf"]["url"] = array("http://", "mailto:", "internal://", "ftp://", "https://", "irc://", "telnet://", "news://", "chrome://", "file://", "gopher://", "httpz://"); $ewiki_config["idf"]["url"] = array("http://", "mailto:", "internal://", "ftp://", "https://", "irc://", "telnet://", "news://", "chrome://", "file://", "gopher://", "httpz://");
$ewiki_config["idf"]["img"] = array(".jpeg", ".png", ".jpg", ".gif", ".j2k"); $ewiki_config["idf"]["img"] = array(".jpeg", ".png", ".jpg", ".gif", ".j2k");
$ewiki_config["idf"]["obj"] = array(".swf", ".svg"); $ewiki_config["idf"]["obj"] = array(".swf", ".svg");
#-- entitle actions #-- entitle actions
$ewiki_config["action_links"]["view"] = @array_merge(array( $ewiki_config["action_links"]["view"] = @array_merge(array(
"edit" => "EDITTHISPAGE", # ewiki_t() is called on these "edit" => "EDITTHISPAGE", # ewiki_t() is called on these
"links" => "BACKLINKS", "links" => "BACKLINKS",
"info" => "PAGEHISTORY", "info" => "PAGEHISTORY",
"like" => "LIKEPAGES", "like" => "LIKEPAGES",
), @$ewiki_config["action_links"]["view"] ), @$ewiki_config["action_links"]["view"]
); );
$ewiki_config["action_links"]["info"] = @array_merge(array( $ewiki_config["action_links"]["info"] = @array_merge(array(
"view" => "browse", "view" => "browse",
"edit" => "fetchback", "edit" => "fetchback",
), @$ewiki_config["action_links"]["info"] ), @$ewiki_config["action_links"]["info"]
); );
#-- variable configuration settings (go into '$ewiki_config') #-- variable configuration settings (go into '$ewiki_config')
@ -209,72 +209,72 @@
"script" => EWIKI_SCRIPT, "script" => EWIKI_SCRIPT,
"script_url" => (defined("EWIKI_SCRIPT_URL")?EWIKI_SCRIPT_URL:NULL), "script_url" => (defined("EWIKI_SCRIPT_URL")?EWIKI_SCRIPT_URL:NULL),
"script_binary" => EWIKI_SCRIPT_BINARY, "script_binary" => EWIKI_SCRIPT_BINARY,
#-- heart of the wiki -- don't try to read this! ;) #-- heart of the wiki -- don't try to read this! ;)
"wiki_pre_scan_regex" => '/ "wiki_pre_scan_regex" => '/
(?<![~!]) (?<![~!])
((?:(?:\w+:)*['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+){2,}[\w\d]*) ((?:(?:\w+:)*['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+){2,}[\w\d]*)
|\^([-'.EWIKI_CHARS_L.EWIKI_CHARS_U.']{3,}) |\^([-'.EWIKI_CHARS_L.EWIKI_CHARS_U.']{3,})
|\[ (?:"[^\]\"]+" | \s+ | [^:\]#]+\|)* ([^\|\"\[\]\#]+) (?:\s+ | "[^\]\"]+")* [\]\#] |\[ (?:"[^\]\"]+" | \s+ | [^:\]#]+\|)* ([^\|\"\[\]\#]+) (?:\s+ | "[^\]\"]+")* [\]\#]
|(\w{3,9}:\/\/[^?#\s\[\]\'\"\)\,<]+) /x', |(\w{3,9}:\/\/[^?#\s\[\]\'\"\)\,<]+) /x',
"wiki_link_regex" => "\007 [!~]?( "wiki_link_regex" => "\007 [!~]?(
\#?\[[^<>\[\]\n]+\] | \#?\[[^<>\[\]\n]+\] |
\^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} | \^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
\b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* | \b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
([a-z]{2,9}://|mailto:)[^\s\[\]\'\"\)\,<]+ | ([a-z]{2,9}://|mailto:)[^\s\[\]\'\"\)\,<]+ |
\w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x", \w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x",
#-- rendering ruleset #-- rendering ruleset
"wm_indent" => '<div style="margin-left:15px;" class="indent">', "wm_indent" => '<div style="margin-left:15px;" class="indent">',
"wm_table_defaults" => 'cellpadding="2" border="1" cellspacing="0"', "wm_table_defaults" => 'cellpadding="2" border="1" cellspacing="0"',
"wm_whole_line" => array(), "wm_whole_line" => array(),
"htmlentities" => array( "htmlentities" => array(
"&" => "&amp;", "&" => "&amp;",
">" => "&gt;", ">" => "&gt;",
"<" => "&lt;", "<" => "&lt;",
), ),
"wm_source" => array( "wm_source" => array(
"%%%" => "<br />", "%%%" => "<br />",
"\t" => " ", "\t" => " ",
"\n;:" => "\n ", # workaround, replaces the old ;: "\n;:" => "\n ", # workaround, replaces the old ;:
), ),
"wm_list" => array( "wm_list" => array(
"-" => array('ul type="square"', "", "li"), "-" => array('ul type="square"', "", "li"),
"*" => array('ul type="circle"', "", "li"), "*" => array('ul type="circle"', "", "li"),
"#" => array("ol", "", "li"), "#" => array("ol", "", "li"),
":" => array("dl", "dt", "dd"), ":" => array("dl", "dt", "dd"),
#<out># ";" => array("dl", "dt", "dd"), #<out># ";" => array("dl", "dt", "dd"),
), ),
"wm_style" => array( "wm_style" => array(
"'''''" => array("<b><i>", "</i></b>"), "'''''" => array("<b><i>", "</i></b>"),
"'''" => array("<b>", "</b>"), "'''" => array("<b>", "</b>"),
"___" => array("<i><b>", "</b></i>"), "___" => array("<i><b>", "</b></i>"),
"''" => array("<em>", "</em>"), "''" => array("<em>", "</em>"),
"__" => array("<strong>", "</strong>"), "__" => array("<strong>", "</strong>"),
"^^" => array("<sup>", "</sup>"), "^^" => array("<sup>", "</sup>"),
"==" => array("<tt>", "</tt>"), "==" => array("<tt>", "</tt>"),
#<off># "***" => array("<b><i>", "</i></b>"), #<off># "***" => array("<b><i>", "</i></b>"),
#<off># "###" => array("<big><b>", "</b></big>"), #<off># "###" => array("<big><b>", "</b></big>"),
"**" => array("<b>", "</b>"), "**" => array("<b>", "</b>"),
"##" => array("<big>", "</big>"), "##" => array("<big>", "</big>"),
"µµ" => array("<small>", "</small>"), "µµ" => array("<small>", "</small>"),
), ),
"wm_start_end" => array( "wm_start_end" => array(
), ),
#-- rendering plugins #-- rendering plugins
"format_block" => array( "format_block" => array(
"html" => array("&lt;html&gt;", "&lt;/html&gt;", "html", 0x0000), "html" => array("&lt;html&gt;", "&lt;/html&gt;", "html", 0x0000),
"htm" => array("&lt;htm&gt;", "&lt;/htm&gt;", "html", 0x0003), "htm" => array("&lt;htm&gt;", "&lt;/htm&gt;", "html", 0x0003),
"code" => array("&lt;code&gt;", "&lt;/code&gt;", false, 0x0000), "code" => array("&lt;code&gt;", "&lt;/code&gt;", false, 0x0000),
"pre" => array("&lt;pre&gt;", "&lt;/pre&gt;", false, 0x003F), "pre" => array("&lt;pre&gt;", "&lt;/pre&gt;", false, 0x003F),
"comment" => array("\n&lt;!--", "--&gt;", false, 0x0030), "comment" => array("\n&lt;!--", "--&gt;", false, 0x0030),
# "verbatim" => array("&lt;verbatim&gt;", "&lt;/verbatim&gt;", false, 0x0000), # "verbatim" => array("&lt;verbatim&gt;", "&lt;/verbatim&gt;", false, 0x0000),
), ),
"format_params" => array( "format_params" => array(
"scan_links" => 1, "scan_links" => 1,
"html" => EWIKI_ALLOW_HTML, "html" => EWIKI_ALLOW_HTML,
"mpi" => 1, "mpi" => 1,
), ),
); );
foreach ($ewiki_config_DEFAULTSTMP as $set => $val) { foreach ($ewiki_config_DEFAULTSTMP as $set => $val) {
@ -292,9 +292,9 @@
} }
$ewiki_config_DEFAULTSTMP = $valv = $vali = $val = NULL; $ewiki_config_DEFAULTSTMP = $valv = $vali = $val = NULL;
#-- init stuff, autostarted parts #-- init stuff, autostarted parts
ksort($ewiki_plugins["init"]); ksort($ewiki_plugins["init"]);
if ($pf_a = $ewiki_plugins["init"]) foreach ($pf_a as $pf) { if ($pf_a = $ewiki_plugins["init"]) foreach ($pf_a as $pf) {
// Binary Handling starts here // Binary Handling starts here
#### MOODLE CHANGE TO BE COMPATIBLE WITH PHP 4.1 #### MOODLE CHANGE TO BE COMPATIBLE WITH PHP 4.1
#if(headers_sent($file,$line)) { #if(headers_sent($file,$line)) {
@ -304,52 +304,52 @@
} }
$pf($GLOBALS); $pf($GLOBALS);
} }
unset($ewiki_plugins["init"]); unset($ewiki_plugins["init"]);
#-- text (never remove the "C" or "en" sections!) #-- text (never remove the "C" or "en" sections!)
# #
$ewiki_t["C"] = @array_merge(@$ewiki_t["C"], array( $ewiki_t["C"] = @array_merge(@$ewiki_t["C"], array(
"DATE" => "%a, %d %b %G %T %Z", "DATE" => "%a, %d %b %G %T %Z",
"EDIT_TEXTAREA_RESIZE_JS" => '<a href="javascript:ewiki_enlarge()" style="text-decoration:none">+</a><script type="text/javascript"><!--'."\n".'function ewiki_enlarge() {var ta=document.getElementById("ewiki_content");ta.style.width=((ta.cols*=1.1)*10).toString()+"px";ta.style.height=((ta.rows*=1.1)*30).toString()+"px";}'."\n".'//--></script>', "EDIT_TEXTAREA_RESIZE_JS" => '<a href="javascript:ewiki_enlarge()" style="text-decoration:none">+</a><script type="text/javascript"><!--'."\n".'function ewiki_enlarge() {var ta=document.getElementById("ewiki_content");ta.style.width=((ta.cols*=1.1)*10).toString()+"px";ta.style.height=((ta.rows*=1.1)*30).toString()+"px";}'."\n".'//--></script>',
)); ));
# #
$ewiki_t["en"] = @array_merge(@$ewiki_t["en"], array( $ewiki_t["en"] = @array_merge(@$ewiki_t["en"], array(
"EDITTHISPAGE" => "EditThisPage", "EDITTHISPAGE" => "EditThisPage",
"APPENDTOPAGE" => "Add to", "APPENDTOPAGE" => "Add to",
"BACKLINKS" => "BackLinks", "BACKLINKS" => "BackLinks",
"PAGESLINKINGTO" => "Pages linking to \$title", "PAGESLINKINGTO" => "Pages linking to \$title",
"PAGEHISTORY" => "PageInfo", "PAGEHISTORY" => "PageInfo",
"INFOABOUTPAGE" => "Information about page", "INFOABOUTPAGE" => "Information about page",
"LIKEPAGES" => "Pages like this", "LIKEPAGES" => "Pages like this",
"NEWESTPAGES" => "Newest Pages", "NEWESTPAGES" => "Newest Pages",
"LASTCHANGED" => "last changed on %c", "LASTCHANGED" => "last changed on %c",
"DOESNOTEXIST" => "This page does not yet exist, please click on EditThisPage if you'd like to create it.", "DOESNOTEXIST" => "This page does not yet exist, please click on EditThisPage if you'd like to create it.",
"DISABLEDPAGE" => "This page is currently not available.", "DISABLEDPAGE" => "This page is currently not available.",
"ERRVERSIONSAVE" => "Sorry, while you edited this page someone else "ERRVERSIONSAVE" => "Sorry, while you edited this page someone else
did already save a changed version. Please go back to the did already save a changed version. Please go back to the
previous screen and copy your changes to your computers previous screen and copy your changes to your computers
clipboard to insert it again after you reload the edit clipboard to insert it again after you reload the edit
screen.", screen.",
"ERRORSAVING" => "An error occoured while saving your changes. Please try again.", "ERRORSAVING" => "An error occoured while saving your changes. Please try again.",
"THANKSFORCONTRIBUTION" => "Thank you for your contribution!", "THANKSFORCONTRIBUTION" => "Thank you for your contribution!",
"CANNOTCHANGEPAGE" => "This page cannot be changed.", "CANNOTCHANGEPAGE" => "This page cannot be changed.",
"OLDVERCOMEBACK" => "Make this old version come back to replace the current one", "OLDVERCOMEBACK" => "Make this old version come back to replace the current one",
"PREVIEW" => "Preview", "PREVIEW" => "Preview",
"SAVE" => "Save", "SAVE" => "Save",
"CANCEL_EDIT" => "CancelEditing", "CANCEL_EDIT" => "CancelEditing",
"UPLOAD_PICTURE_BUTTON" => "upload picture &gt;&gt;&gt;", "UPLOAD_PICTURE_BUTTON" => "upload picture &gt;&gt;&gt;",
"EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GoodStyle\">GoodStyle</a> is to "EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GoodStyle\">GoodStyle</a> is to
write what comes to your mind. Don't care about how it write what comes to your mind. Don't care about how it
looks too much now. You can add <a href=\"".EWIKI_SCRIPT."WikiMarkup\">WikiMarkup</a> looks too much now. You can add <a href=\"".EWIKI_SCRIPT."WikiMarkup\">WikiMarkup</a>
also later if you think it is necessary.<br />", also later if you think it is necessary.<br />",
"EDIT_FORM_2" => "<br />Please do not write things, which may make other "EDIT_FORM_2" => "<br />Please do not write things, which may make other
people angry. And please keep in mind that you are not all that people angry. And please keep in mind that you are not all that
anonymous in the internet (find out more about your computers anonymous in the internet (find out more about your computers
'<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' at Google).", '<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' at Google).",
"BIN_IMGTOOLARGE" => "Image file is too large!", "BIN_IMGTOOLARGE" => "Image file is too large!",
"BIN_NOIMG" => "This is no image file (inacceptable file format)!", "BIN_NOIMG" => "This is no image file (inacceptable file format)!",
"FORBIDDEN" => "You are not authorized to access this page.", "FORBIDDEN" => "You are not authorized to access this page.",
)); ));
# #
$ewiki_t["es"] = @array_merge(@$ewiki_t["es"], array( $ewiki_t["es"] = @array_merge(@$ewiki_t["es"], array(
"EDITTHISPAGE" => "EditarEstaPágina", "EDITTHISPAGE" => "EditarEstaPágina",
@ -363,10 +363,10 @@
"DOESNOTEXIST" => "Esta página aún no existe, por favor eliga EditarEstaPágina si desea crearla.", "DOESNOTEXIST" => "Esta página aún no existe, por favor eliga EditarEstaPágina si desea crearla.",
"DISABLEDPAGE" => "Esta página no está disponible en este momento.", "DISABLEDPAGE" => "Esta página no está disponible en este momento.",
"ERRVERSIONSAVE" => "Disculpe, mientras editaba esta página alguién más "ERRVERSIONSAVE" => "Disculpe, mientras editaba esta página alguién más
salvó una versión modificada. Por favor regrese a salvó una versión modificada. Por favor regrese a
a la pantalla anterior y copie sus cambios a su computador a la pantalla anterior y copie sus cambios a su computador
para insertalos nuevamente después de que cargue para insertalos nuevamente después de que cargue
la pantalla de edición.", la pantalla de edición.",
"ERRORSAVING" => "Ocurrió un error mientras se salvavan sus cambios. Por favor intente de nuevo.", "ERRORSAVING" => "Ocurrió un error mientras se salvavan sus cambios. Por favor intente de nuevo.",
"THANKSFORCONTRIBUTION" => "Gracias por su contribución!", "THANKSFORCONTRIBUTION" => "Gracias por su contribución!",
"CANNOTCHANGEPAGE" => "Esta página no puede ser modificada.", "CANNOTCHANGEPAGE" => "Esta página no puede ser modificada.",
@ -376,88 +376,88 @@
"CANCEL_EDIT" => "CancelarEdición", "CANCEL_EDIT" => "CancelarEdición",
"UPLOAD_PICTURE_BUTTON" => "subir gráfica &gt;&gt;&gt;", "UPLOAD_PICTURE_BUTTON" => "subir gráfica &gt;&gt;&gt;",
"EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."BuenEstilo\">BuenEstilo</a> es "EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."BuenEstilo\">BuenEstilo</a> es
escribir lo que viene a su mente. No se preocupe mucho escribir lo que viene a su mente. No se preocupe mucho
por la apariencia. También puede agregar <a href=\"".EWIKI_SCRIPT."ReglasDeMarcadoWiki\">ReglasDeMarcadoWiki</a> por la apariencia. También puede agregar <a href=\"".EWIKI_SCRIPT."ReglasDeMarcadoWiki\">ReglasDeMarcadoWiki</a>
más adelante si piensa que es necesario.<br />", más adelante si piensa que es necesario.<br />",
"EDIT_FORM_2" => "<br />Por favor no escriba cosas, que puedan "EDIT_FORM_2" => "<br />Por favor no escriba cosas, que puedan
enfadar a otras personas. Y por favor tenga en mente que enfadar a otras personas. Y por favor tenga en mente que
usted no es del todo anónimo en Internet usted no es del todo anónimo en Internet
(encuentre más sobre (encuentre más sobre
'<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' de su computador con Google).", '<a href=\"http://google.com/search?q=my+computers+IP+address\">IP address</a>' de su computador con Google).",
"BIN_IMGTOOLARGE" => "¡La gráfica es demasiado grande!", "BIN_IMGTOOLARGE" => "¡La gráfica es demasiado grande!",
"BIN_NOIMG" => "¡No es un archivo con una gráfica (formato de archivo inaceptable)!", "BIN_NOIMG" => "¡No es un archivo con una gráfica (formato de archivo inaceptable)!",
"FORBIDDEN" => "No está autorizado para acceder a esta página.", "FORBIDDEN" => "No está autorizado para acceder a esta página.",
)); ));
# #
$ewiki_t["de"] = @array_merge(@$ewiki_t["de"], array( $ewiki_t["de"] = @array_merge(@$ewiki_t["de"], array(
"EDITTHISPAGE" => "DieseSeiteÄndern", "EDITTHISPAGE" => "DieseSeiteÄndern",
"APPENDTOPAGE" => "Ergänze", "APPENDTOPAGE" => "Ergänze",
"BACKLINKS" => "ZurückLinks", "BACKLINKS" => "ZurückLinks",
"PAGESLINKINGTO" => "Verweise zur Seite \$title", "PAGESLINKINGTO" => "Verweise zur Seite \$title",
"PAGEHISTORY" => "SeitenInfo", "PAGEHISTORY" => "SeitenInfo",
"INFOABOUTPAGE" => "Informationen über Seite", "INFOABOUTPAGE" => "Informationen über Seite",
"LIKEPAGES" => "Ähnliche Seiten", "LIKEPAGES" => "Ähnliche Seiten",
"NEWESTPAGES" => "Neueste Seiten", "NEWESTPAGES" => "Neueste Seiten",
"LASTCHANGED" => "zuletzt geändert am %d.%m.%Y um %H:%M", "LASTCHANGED" => "zuletzt geändert am %d.%m.%Y um %H:%M",
"DISABLEDPAGE" => "Diese Seite kann momentan nicht angezeigt werden.", "DISABLEDPAGE" => "Diese Seite kann momentan nicht angezeigt werden.",
"ERRVERSIONSAVE" => "Entschuldige, aber während Du an der Seite "ERRVERSIONSAVE" => "Entschuldige, aber während Du an der Seite
gearbeitet hast, hat bereits jemand anders eine geänderte gearbeitet hast, hat bereits jemand anders eine geänderte
Fassung gespeichert. Damit nichts verloren geht, browse bitte Fassung gespeichert. Damit nichts verloren geht, browse bitte
zurück und speichere Deine Änderungen in der Zwischenablage zurück und speichere Deine Änderungen in der Zwischenablage
(Bearbeiten->Kopieren) um sie dann wieder an der richtigen (Bearbeiten->Kopieren) um sie dann wieder an der richtigen
Stelle einzufügen, nachdem du die EditBoxSeite nocheinmal Stelle einzufügen, nachdem du die EditBoxSeite nocheinmal
geladen hast.<br /> geladen hast.<br />
Vielen Dank für Deine Mühe.", Vielen Dank für Deine Mühe.",
"ERRORSAVING" => "Beim Abspeichern ist ein Fehler aufgetreten. Bitte versuche es erneut.", "ERRORSAVING" => "Beim Abspeichern ist ein Fehler aufgetreten. Bitte versuche es erneut.",
"THANKSFORCONTRIBUTION" => "Vielen Dank für Deinen Beitrag!", "THANKSFORCONTRIBUTION" => "Vielen Dank für Deinen Beitrag!",
"CANNOTCHANGEPAGE" => "Diese Seite kann nicht geändert werden.", "CANNOTCHANGEPAGE" => "Diese Seite kann nicht geändert werden.",
"OLDVERCOMEBACK" => "Diese alte Version der Seite wieder zur Aktuellen machen", "OLDVERCOMEBACK" => "Diese alte Version der Seite wieder zur Aktuellen machen",
"PREVIEW" => "Vorschau", "PREVIEW" => "Vorschau",
"SAVE" => "Speichern", "SAVE" => "Speichern",
"CANCEL_EDIT" => "ÄnderungenVerwerfen", "CANCEL_EDIT" => "ÄnderungenVerwerfen",
"UPLOAD_PICTURE_BUTTON" => "Bild hochladen &gt;&gt;&gt;", "UPLOAD_PICTURE_BUTTON" => "Bild hochladen &gt;&gt;&gt;",
"EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GuterStil\">GuterStil</a> ist es, "EDIT_FORM_1" => "<a href=\"".EWIKI_SCRIPT."GuterStil\">GuterStil</a> ist es,
ganz einfach das zu schreiben, was einem gerade in den ganz einfach das zu schreiben, was einem gerade in den
Sinn kommt. Du solltest dich jetzt noch nicht so sehr Sinn kommt. Du solltest dich jetzt noch nicht so sehr
darum kümmern, wie die Seite aussieht. Du kannst später darum kümmern, wie die Seite aussieht. Du kannst später
immernoch zurückkommen und den Text mit <a href=\"".EWIKI_SCRIPT."FormatierungsRegeln\">WikiTextFormatierungsRegeln</a> immernoch zurückkommen und den Text mit <a href=\"".EWIKI_SCRIPT."FormatierungsRegeln\">WikiTextFormatierungsRegeln</a>
aufputschen.<br />", aufputschen.<br />",
"EDIT_FORM_2" => "<br />Bitte schreib keine Dinge, die andere Leute "EDIT_FORM_2" => "<br />Bitte schreib keine Dinge, die andere Leute
verärgern könnten. Und bedenke auch, daß es schnell auf verärgern könnten. Und bedenke auch, daß es schnell auf
dich zurückfallen kann wenn du verschiedene andere Dinge sagst (mehr Informationen zur dich zurückfallen kann wenn du verschiedene andere Dinge sagst (mehr Informationen zur
'<a href=\"http://google.de/search?q=computer+IP+adresse\">IP Adresse</a>' '<a href=\"http://google.de/search?q=computer+IP+adresse\">IP Adresse</a>'
deines Computers findest du bei Google).", deines Computers findest du bei Google).",
)); ));
#-- InterWiki:Links #-- InterWiki:Links
$ewiki_config["interwiki"] = @array_merge( $ewiki_config["interwiki"] = @array_merge(
@$ewiki_config["interwiki"], @$ewiki_config["interwiki"],
array( array(
"javascript" => "", # this actually protects from javascript: links "javascript" => "", # this actually protects from javascript: links
"url" => "", "url" => "",
# "self" => "this", # "self" => "this",
"this" => EWIKI_SCRIPT, # better was absolute _URL to ewiki wrapper "this" => EWIKI_SCRIPT, # better was absolute _URL to ewiki wrapper
"jump" => "", "jump" => "",
"ErfurtWiki" => "http://erfurtwiki.sourceforge.net/?id=", "ErfurtWiki" => "http://erfurtwiki.sourceforge.net/?id=",
"InterWiki" => "InterWikiSearch", "InterWiki" => "InterWikiSearch",
"InterWikiSearch" => "http://sunir.org/apps/meta.pl?", "InterWikiSearch" => "http://sunir.org/apps/meta.pl?",
"Wiki" => "WardsWiki", "Wiki" => "WardsWiki",
"WardsWiki" => "http://www.c2.com/cgi/wiki?", "WardsWiki" => "http://www.c2.com/cgi/wiki?",
"WikiFind" => "http://c2.com/cgi/wiki?FindPage&amp;value=", "WikiFind" => "http://c2.com/cgi/wiki?FindPage&amp;value=",
"WikiPedia" => "http://www.wikipedia.com/wiki.cgi?", "WikiPedia" => "http://www.wikipedia.com/wiki.cgi?",
"MeatBall" => "MeatballWiki", "MeatBall" => "MeatballWiki",
"MeatballWiki" => "http://www.usemod.com/cgi-bin/mb.pl?", "MeatballWiki" => "http://www.usemod.com/cgi-bin/mb.pl?",
"UseMod" => "http://www.usemod.com/cgi-bin/wiki.pl?", "UseMod" => "http://www.usemod.com/cgi-bin/wiki.pl?",
"PhpWiki" => "http://phpwiki.sourceforge.net/phpwiki/index.php3?", "PhpWiki" => "http://phpwiki.sourceforge.net/phpwiki/index.php3?",
"LinuxWiki" => "http://linuxwiki.de/", "LinuxWiki" => "http://linuxwiki.de/",
"OpenWiki" => "http://openwiki.com/?", "OpenWiki" => "http://openwiki.com/?",
"Tavi" => "http://andstuff.org/tavi/", "Tavi" => "http://andstuff.org/tavi/",
"TWiki" => "http://twiki.sourceforge.net/cgi-bin/view/", "TWiki" => "http://twiki.sourceforge.net/cgi-bin/view/",
"MoinMoin" => "http://www.purl.net/wiki/moin/", "MoinMoin" => "http://www.purl.net/wiki/moin/",
"Google" => "http://google.com/search?q=", "Google" => "http://google.com/search?q=",
"ISBN" => "http://www.amazon.com/exec/obidos/ISBN=", "ISBN" => "http://www.amazon.com/exec/obidos/ISBN=",
"icq" => "http://www.icq.com/", "icq" => "http://www.icq.com/",
)); ));
@ -2091,7 +2091,7 @@ function ewiki_format (
global $ewiki_use_editor, $ewiki_editor_content; global $ewiki_use_editor, $ewiki_editor_content;
if(!($ewiki_use_editor && $ewiki_editor_content)) { if(!($ewiki_use_editor && $ewiki_editor_content)) {
##### END MOODLE ADDITION ##### ##### END MOODLE ADDITION #####
ewiki_render_wiki_links($ooo[$in][0]); ewiki_render_wiki_links($ooo[$in][0]);
##### BEGIN MOODLE ADDITION ##### ##### BEGIN MOODLE ADDITION #####
} }
##### END MOODLE ADDITION ##### ##### END MOODLE ADDITION #####
@ -2422,7 +2422,7 @@ function ewiki_link_regex_callback($uu, $force_noimg=0) {
$str = ($obj ? '<embed width="70%"' : '<img') . ' src="' . $href . '"' . $str = ($obj ? '<embed width="70%"' : '<img') . ' src="' . $href . '"' .
' alt="' . ($title) . '"' . ' alt="' . ($title) . '"' .
(@$states["titled"] ? ' title="' . ($title) . '"' : ''). (@$states["titled"] ? ' title="' . ($title) . '"' : '').
($x && $y ? " width=\"$x\" height=\"$y\"" : "") . ($x && $y ? " width=\"$x\" height=\"$y\"" : "") .
$align . " />" . ($obj ? "</embed>" : ""); $align . " />" . ($obj ? "</embed>" : "");
# htmlentities($title) # htmlentities($title)
} }
@ -2977,8 +2977,8 @@ function ewiki_array($array, $key=false, $am=1, $ci=EWIKI_CASE_INSENSITIVE) {
$r[$i] = $v; $r[$i] = $v;
} }
else { else {
$r[$i] .= $v; //RET: doubling for images`meta won't happen $r[$i] .= $v; //RET: doubling for images`meta won't happen
} // but should be "+" here for integers } // but should be "+" here for integers
} }
$array = &$r; $array = &$r;
} }
@ -3008,7 +3008,7 @@ function ewiki_author($defstr="") {
(empty($author)) && ( (empty($author)) && (
($author = $defstr) || ($author = $defstr) ||
($author = $_SERVER["HTTP_FROM"]) || // RFC2068 sect 14.22 ($author = $_SERVER["HTTP_FROM"]) || // RFC2068 sect 14.22
($author = $_SERVER["PHP_AUTH_USER"]) ($author = $_SERVER["PHP_AUTH_USER"])
); );
@ -3418,7 +3418,7 @@ function ewiki_database_mysql($action, &$args, $sw1, $sw2) {
existing entries (using WRITE); returns 0 on failure and 1 if existing entries (using WRITE); returns 0 on failure and 1 if
saved correctly. saved correctly.
*/ */
case "OVERWRITE": // fall-through case "OVERWRITE": // fall-through
$COMMAND = "REPLACE"; $COMMAND = "REPLACE";
case "WRITE": case "WRITE":

View file

@ -348,13 +348,13 @@
/// Insert a link to force page refresh if new content isn't showing. /// Insert a link to force page refresh if new content isn't showing.
// build new URL + query string // build new URL + query string
$queries = preg_split('/[?&]/', me()); $queries = preg_split('/[?&]/', me());
$nqueries = count($queries); $nqueries = count($queries);
$me = $queries[0] . '?'; $me = $queries[0] . '?';
for($i=1; $i < $nqueries; $i++) for($i=1; $i < $nqueries; $i++)
{ {
if( !strstr($queries[$i], 'allowcache') ) if( !strstr($queries[$i], 'allowcache') )
$me .= $queries[$i] . '&'; $me .= $queries[$i] . '&';
} }
$me .= 'allowcache=0'; $me .= 'allowcache=0';