$jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
- if (!isset($_GET['firstpage'])) {
- $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
+ $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
+ if (!optional_param('firstpage', 0, PARAM_INT)) {
if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
error("Add page: first page not found");
}
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
+ $qtype = optional_param('qtype', LESSON_MULTICHOICE, PARAM_INT);
// set of jump array
$jump = array();
$jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
+ $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if(lesson_display_branch_jumps($lesson->id, $pageid)) {
$jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson");
$jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson");
if(lesson_display_cluster_jump($lesson->id, $pageid)) {
$jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
}
- if (!isset($_GET['firstpage'])) {
+ if (!optional_param('firstpage', 0, PARAM_INT)) {
$linkadd = "";
- $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
error("Add page: first page not found");
}
<?php
echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>";
- if (isset($_GET['qtype'])) {
- $qtype = clean_param($_GET['qtype'], PARAM_INT);
- lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
- "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
- // NoticeFix rearraged
- if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer
- echo '<p>';
- if ($qtype == LESSON_SHORTANSWER) {
- echo "<b>".get_string("casesensitive", "lesson").":</b> \n";
- } else {
- echo "<b>".get_string("multianswer", "lesson").":</b> \n";
- }
- echo " <label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>";
- helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
- echo '</p>';
+ lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
+ "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
+
+ if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer
+ echo '<p>';
+ if ($qtype == LESSON_SHORTANSWER) {
+ echo "<b>".get_string("casesensitive", "lesson").":</b> \n";
+ } else {
+ echo "<b>".get_string("multianswer", "lesson").":</b> \n";
}
- } else {
- lesson_qtype_menu($LESSON_QUESTION_TYPE, LESSON_MULTICHOICE,
- "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
- echo "<br><br><b>".get_string("multianswer", "lesson").":</b> \n";
echo " <label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>";
helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
+ echo '</p>';
}
?>
<table cellpadding="5" class="generalbox" border="1">
print_textarea($usehtmleditor, 25,70, 630, 400, "contents");
use_html_editor("contents");
echo "</td></tr>\n";
- if (isset($_GET['qtype'])) {
- switch ($_GET['qtype']) {
- case LESSON_TRUEFALSE :
- for ($i = 0; $i < 2; $i++) {
- $iplus1 = $i + 1;
- echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "answer[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "response[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
+ switch ($qtype) {
+ case LESSON_TRUEFALSE :
+ for ($i = 0; $i < 2; $i++) {
+ $iplus1 = $i + 1;
+ echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
+ print_textarea(false, 6, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
+ print_textarea(false, 6, 70, 630, 300, "response[$i]");
+ echo "</td></tr>\n";
+ echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
+ if ($i) {
+ // answers 2, 3, 4... jumpto this page
+ lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
+ } else {
+ // answer 1 jumpto next page
+ lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
+ }
+ helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
+ if($lesson->custom) {
if ($i) {
- // answers 2, 3, 4... jumpto this page
- lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
+ echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
} else {
- // answer 1 jumpto next page
- lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
+ echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
}
- helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
- if($lesson->custom) {
- if ($i) {
- echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
- } else {
- echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
- }
- }
- echo "</td></tr>\n";
}
- break;
- case LESSON_ESSAY :
- echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n";
- lesson_choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE, "");
- helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
- if ($lesson->custom) {
- echo get_string("score", "lesson").": <input type=\"text\" name=\"score[0]\" value=\"1\" size=\"5\">";
- }
- echo "</td></tr>\n";
- break;
- case LESSON_MATCHING :
- for ($i = 0; $i < $lesson->maxanswers+2; $i++) {
- $icorrected = $i - 1;
- if ($i == 0) {
- echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "answer[$i]");
- echo "</td></tr>\n";
- } elseif ($i == 1) {
- echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "answer[$i]");
- echo "</td></tr>\n";
- } else {
- echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "answer[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "response[$i]");
- echo "</td></tr>\n";
- }
- if ($i == 2) {
- echo "<tr><td><B>".get_string("correctanswerjump", "lesson").":</b> \n";
- lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
- helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
- if($lesson->custom) {
- echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
- }
- echo "</td></tr>\n";
- } elseif ($i == 3) {
- echo "<tr><td><B>".get_string("wronganswerjump", "lesson").":</b> \n";
- lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
- helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
- if($lesson->custom) {
- echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
- }
- echo "</td></tr>\n";
- }
+ echo "</td></tr>\n";
+ }
+ break;
+ case LESSON_ESSAY :
+ echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n";
+ lesson_choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE, "");
+ helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
+ if ($lesson->custom) {
+ echo get_string("score", "lesson").": <input type=\"text\" name=\"score[0]\" value=\"1\" size=\"5\">";
}
- break;
- case LESSON_SHORTANSWER :
- case LESSON_NUMERICAL :
- case LESSON_MULTICHOICE :
- // default code
- for ($i = 0; $i < $lesson->maxanswers; $i++) {
- $iplus1 = $i + 1;
- echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
+ echo "</td></tr>\n";
+ break;
+ case LESSON_MATCHING :
+ for ($i = 0; $i < $lesson->maxanswers+2; $i++) {
+ $icorrected = $i - 1;
+ if ($i == 0) {
+ echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b><br />\n";
+ print_textarea(false, 6, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ } elseif ($i == 1) {
+ echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n";
+ print_textarea(false, 6, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ } else {
+ echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
- echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
+ echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n";
- echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
- if ($i) {
- // answers 2, 3, 4... jumpto this page
- lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
- } else {
- // answer 1 jumpto next page
- lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
+ }
+ if ($i == 2) {
+ echo "<tr><td><B>".get_string("correctanswerjump", "lesson").":</b> \n";
+ lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
+ helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
+ if($lesson->custom) {
+ echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
}
+ echo "</td></tr>\n";
+ } elseif ($i == 3) {
+ echo "<tr><td><B>".get_string("wronganswerjump", "lesson").":</b> \n";
+ lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) {
- if ($i) {
- echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
- } else {
- echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
- }
+ echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
}
echo "</td></tr>\n";
}
- break;
- }
- } else {
- for ($i = 0; $i < $lesson->maxanswers; $i++) {
- $iplus1 = $i + 1;
- echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "answer[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
- print_textarea(false, 6, 70, 630, 300, "response[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
- if ($i) {
- // answers 2, 3, 4... jumpto this page
- lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
- } else {
- // answer 1 jumpto next page
- lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
}
- helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
- if($lesson->custom) {
+ break;
+ case LESSON_SHORTANSWER :
+ case LESSON_NUMERICAL :
+ case LESSON_MULTICHOICE :
+ // default code
+ for ($i = 0; $i < $lesson->maxanswers; $i++) {
+ $iplus1 = $i + 1;
+ echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
+ print_textarea(false, 6, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
+ print_textarea(false, 6, 70, 630, 300, "response[$i]");
+ echo "</td></tr>\n";
+ echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) {
- echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
+ // answers 2, 3, 4... jumpto this page
+ lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
} else {
- echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
+ // answer 1 jumpto next page
+ lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
}
+ helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
+ if($lesson->custom) {
+ if ($i) {
+ echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
+ } else {
+ echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
+ }
+ }
+ echo "</td></tr>\n";
}
- echo "</td></tr>\n";
- }
+ break;
}
// close table and form
?>
}
// record answer (if necessary) and show response (if none say if answer is correct or not)
- if (empty($_POST['pageid'])) {
- error("Continue: pageid missing");
- }
$pageid = required_param('pageid', PARAM_INT);
if (!$page = get_record("lesson_pages", "id", $pageid)) {
error("Continue: Page record not found");
confirm_sesskey();
- if (empty($_GET['pageid'])) {
- error("Delete: pageid missing");
- }
$pageid = required_param('pageid', PARAM_INT);
if (!$thispage = get_record("lesson_pages", "id", $pageid)) {
error("Delete: page record not found");
error("Edit page: page record not found");
}
- if (isset($_GET['qtype'])) {
- $page->qtype = required_param('qtype', PARAM_INT);
- }
+ $page->qtype = optional_param('qtype', $page->qtype, PARAM_INT);
// set of jump array
$jump = array();
fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed));
fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime));
fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake));
- fwrite ($bf,full_tag("TREE",4,false,$lesson->tree));
fwrite ($bf,full_tag("MEDIAFILE",4,false,$lesson->mediafile));
fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow));
fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width));
fwrite ($bf,full_tag("TIMED",5,false,$default->timed));
fwrite ($bf,full_tag("MAXTIME",5,false,$default->maxtime));
fwrite ($bf,full_tag("RETAKE",5,false,$default->retake));
- fwrite ($bf,full_tag("TREE",5,false,$default->tree));
fwrite ($bf,full_tag("SLIDESHOW",5,false,$default->slideshow));
fwrite ($bf,full_tag("WIDTH",5,false,$default->width));
fwrite ($bf,full_tag("HEIGHT",5,false,$default->height));
if ($oldversion < 2005110200) {
table_column('lesson', '', 'activitylink', 'int', '10', 'unsigned', '0', 'not null', 'tree');
}
+
+ if ($oldversion < 2006031900) {
+ execute_sql('ALTER TABLE '. $CFG->prefix . 'lesson DROP COLUMN tree');
+ execute_sql('ALTER TABLE '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
+ }
return true;
}
`timed` TINYINT(3) UNSIGNED NOT NULL default '0',
`maxtime` INT(10) UNSIGNED NOT NULL default '0',
`retake` int(3) unsigned NOT NULL default '1',
- `tree` TINYINT(3) UNSIGNED NOT NULL default '0',
`activitylink` INT(10) UNSIGNED NOT NULL default '0',
`mediafile` varchar(255) NOT NULL default '',
`mediaheight` INT(10) UNSIGNED NOT NULL DEFAULT '100',
`timed` int(3) unsigned NOT NULL default '0',
`maxtime` int(10) unsigned NOT NULL default '0',
`retake` int(3) unsigned NOT NULL default '1',
- `tree` int(3) unsigned NOT NULL default '0',
`slideshow` int(3) unsigned NOT NULL default '0',
`width` int(10) unsigned NOT NULL default '640',
`height` int(10) unsigned NOT NULL default '480',
if ($oldversion < 2005110200) {
table_column('lesson', '', 'activitylink', 'INT', '10', 'unsigned', '0', 'not null', 'tree');
}
+
+ if ($oldversion < 2006031900) {
+ execute_sql('ALTER TABLE '. $CFG->prefix . 'lesson DROP COLUMN tree');
+ execute_sql('ALTER TABLE '. $CFG->prefix . 'lesson_default DROP COLUMN tree');
+ }
return true;
}
timed INT NOT NULL DEFAULT '0',
maxtime INT8 NOT NULL DEFAULT '0',
retake INT NOT NULL default '1',
- tree INT NOT NULL DEFAULT '0',
activitylink INT8 NOT NULL default '0',
mediafile varchar(255) NOT NULL default '',
mediaheight INT NOT NULL DEFAULT '100',
timed INT NOT NULL default '0',
maxtime INT8 NOT NULL default '0',
retake INT NOT NULL default '1',
- tree INT NOT NULL default '0',
slideshow INT NOT NULL default '0',
width INT8 NOT NULL default '640',
height INT8 NOT NULL default '480',
/// Print upload form
$fileformats = get_list_of_plugins("mod/quiz/format");
- $fileformatname = array();
+ $fileformatnames = array();
foreach ($fileformats as $key => $fileformat) {
$formatname = get_string($fileformat, 'lesson');
if ($formatname == "[[$fileformat]]") {
"$navigation <a href=index.php?id=$course->id>$strlessons</a> ->
<a href=\"view.php?id=$cm->id\">".format_string($lesson->name,true)."</a>", "", "", true);
+ if ($action == 'continue' and isteacher($course->id)) {
+ $currenttab = 'navigation';
+ include('tabs.php');
+ }
+
// include the appropriate action (check to make sure the file is there first)
if (file_exists($CFG->dirroot.'/mod/lesson/action/'.$action.'.php')) {
include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
$output = "";
$class = ' class="leftmenu_not_selected_link" ';
- if (isset($_REQUEST['pageid'])) {
- if($page->id == $_REQUEST['pageid']) {
- $class = ' class="leftmenu_selected_link" ';
- }
- }
+ if($page->id == optional_param('pageid', 0, PARAM_INT)) {
+ $class = ' class="leftmenu_selected_link" ';
+ }
$output .= '<li>';
* @param string $pixpath Path to the pictures.
* @todo $pageid does not need to be passed. Can be found in the function. $pixpath is just
* $CFG->pixpath. So $CFG should be declaired globally and be used instead of passed.
+ * This function is only called once. It should be removed and the code inside it moved to view.php
*/
function lesson_print_tree($pageid, $lessonid, $cmid, $pixpath) {
global $USER;
if (!isset($form->maxtime)) {
$form->maxtime = 20;
}
- if (!isset($form->tree)) {
- $form->tree = 0;
- }
if (!isset($form->slideshow)) {
$form->slideshow = 0;
}
</td><td></td>
</tr>
-<tr>
- <td align="right"><b><?php print_string("treeview", "lesson"); ?>:</b></td>
- <td>
- <?PHP
- $options = array();
- $options[0] = get_string("no"); $options[1] = get_string("yes");
- choose_from_menu($options, "tree", $form->tree, "");
- helpbutton("tree", get_string("treeview", "lesson"), "lesson");
- ?>
- </td>
-</tr>
-
<tr>
<td align="right"><b><?php print_string("activitylink", "lesson"); ?>:</b></td>
<td>
$id = required_param('id', PARAM_INT); // Course Module ID
$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
- $action = optional_param('action'); // action to take
+ $action = optional_param('action', 'view', PARAM_ALPHA); // action to take
+ $nothingtodisplay = false;
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (! $attempts = get_records('lesson_attempts', 'lessonid', $lesson->id, 'timeseen')) {
- error('Could not find any attempts for this lesson');
+ $nothingtodisplay = true;
}
if (! $students = get_records_sql("SELECT DISTINCT u.*
WHERE a.lessonid = '$lesson->id' and
u.id = a.userid
ORDER BY u.lastname")) {
- error("Error: could not find users");
+ $nothingtodisplay = true;
}
// make sure people are where they should be
require_login($course->id, false);
- if (!isteacheredit($course->id)) {
+ if (!isteacher($course->id)) {
error("Must be teacher to view Reports");
}
'<input type="hidden" name="return" value="true" />'.
'<input type="submit" value="'. get_string('editlessonsettings', 'lesson') .'" /></form>';
+ if ($action == 'view') {
+ $navigationend = get_string("reports", "lesson");
+ } else if ($action == 'detail' and !optional_param('userid', 0, PARAM_INT)) {
+ $navigationend = "<a href=\"report.php?id=$cm->id\">".get_string("reports", "lesson").'</a> -> '.get_string('detailedstats', 'lesson');
+ } else {
+ $navigationend = "<a href=\"report.php?id=$cm->id\">".get_string("reports", "lesson").'</a> -> '.get_string('review', 'lesson');
+ }
+
print_header($course->shortname .': '. format_string($lesson->name), $course->fullname,
"$navigation <A HREF=index.php?id=$course->id>$strlessons</A> -> <a href=\"view.php?id=$cm->id\">".format_string($lesson->name,true)."</a>
- -> <a href=\"report.php?id=$cm->id\">".get_string("report", "lesson")."</a>",
- '', '', true, $button,
- navmenu($course, $cm));
-
- print_heading(get_string("lesson", "lesson", format_string($lesson->name)), "center", 5);
-
- // navigational links
- $detaillink = "<a href=\"report.php?id=$cm->id&action=detail\">".get_string("detailedstats", "lesson")."</a>";
- $overviewlink = "<a href=\"report.php?id=$cm->id\">".get_string("overview", "lesson")."</a>";
- print_heading($overviewlink." ".$detaillink);
+ -> $navigationend", '', '', true, $button, navmenu($course, $cm));
+
+ if (!optional_param('userid', 0, PARAM_INT)) {
+ $currenttab = 'reports';
+ $mode = $action;
+ }
+ include('tabs.php');
+
+ print_heading_with_help(format_string($lesson->name,true), "overview", "lesson");
+
+ if ($nothingtodisplay) {
+ notify(get_string('nolessonattempts', 'lesson'));
+ print_footer($course);
+ exit();
+ }
/**************************************************************************
this action is for default view and overview view
**************************************************************************/
- if (empty($action) || $action == 'view') {
+ if ($action == 'view') {
$studentdata = array();
// build an array for output
$lesson->timed = backup_todb($info['MOD']['#']['TIMED']['0']['#']);
$lesson->maxtime = backup_todb($info['MOD']['#']['MAXTIME']['0']['#']);
$lesson->retake = backup_todb($info['MOD']['#']['RETAKE']['0']['#']);
- $lesson->tree = backup_todb($info['MOD']['#']['TREE']['0']['#']);
$lesson->mediafile = backup_todb($info['MOD']['#']['MEDIAFILE']['0']['#']);
$lesson->slideshow = backup_todb($info['MOD']['#']['SLIDESHOW']['0']['#']);
$lesson->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']);
$default->timed = backup_todb($default_info['#']['TIMED']['0']['#']);
$default->maxtime = backup_todb($default_info['#']['MAXTIME']['0']['#']);
$default->retake = backup_todb($default_info['#']['RETAKE']['0']['#']);
- $default->tree = backup_todb($default_info['#']['TREE']['0']['#']);
$default->slideshow = backup_todb($default_info['#']['SLIDESHOW']['0']['#']);
$default->width = backup_todb($default_info['#']['WIDTH']['0']['#']);
$default->height = backup_todb($default_info['#']['HEIGHT']['0']['#']);
--- /dev/null
+<?php // $Id$
+/**
+* Sets up the tabs used by the lesson pages for teachers.
+*
+* This file was adapted from the mod/quiz/tabs.php
+*
+* @version $Id$
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+* @package lesson
+*/
+
+/// This file to be included so we can assume config.php has already been included.
+
+ if (empty($lesson)) {
+ error('You cannot call this script in that way');
+ }
+ if (!isset($currenttab)) {
+ $currenttab = '';
+ }
+ if (!isset($cm)) {
+ $cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ }
+ if (!isset($course)) {
+ $course = get_record('course', 'id', $lesson->course);
+ }
+
+ $tabs = array();
+ $row = array();
+ $inactive = array();
+
+
+/// user attempt count for reports link hover (completed attempts - much faster)
+ $counts = new stdClass;
+ $counts->attempts = count_records('lesson_grades', 'lessonid', $lesson->id);
+ $counts->student = $course->student;
+
+ $row[] = new tabobject('teacherview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('edit'), get_string('editlesson', 'lesson', format_string($lesson->name)));
+ $row[] = new tabobject('navigation', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=navigation", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name)));
+ $row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports', 'lesson', $counts));
+ if (isteacheredit($course->id)) {
+ $row[] = new tabobject('essayview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=essayview", get_string('manualgrading', 'lesson'));
+ }
+ if ($lesson->highscores) {
+ $row[] = new tabobject('highscores', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=highscores", get_string('highscores', 'lesson'));
+ }
+
+ $tabs[] = $row;
+
+/// sub tabs for reports (overview and detail)
+ if ($currenttab == 'reports' and isset($mode)) {
+ $inactive[] = 'reports';
+ $currenttab = $mode;
+
+ $row = array();
+ $row[] = new tabobject('view', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&action=view", get_string('overview', 'lesson'));
+ $row[] = new tabobject('detail', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&action=detail", get_string('detailedstats', 'lesson'));
+ $tabs[] = $row;
+ }
+
+/// sub tabs for teacher view (collapsed and expanded aka full)
+ if ($currenttab == 'teacherview') {
+ // use user preferences to remember which edit mode the user has selected
+ if (empty($mode)) {
+ $mode = get_user_preferences('lesson_view', 'collapsed');
+ } else {
+ set_user_preference('lesson_view', $mode);
+ }
+
+ $inactive[] = 'teacherview';
+ $currenttab = $mode;
+
+ $row = array();
+ $row[] = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=teacherview&mode=collapsed", get_string('collapsed', 'lesson'));
+ $row[] = new tabobject('full', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&=teacherview&mode=full", get_string('full', 'lesson'));
+ $tabs[] = $row;
+ }
+
+ print_tabs($tabs, $currenttab, $inactive);
+
+?>
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2005110200; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2006031900; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2005021600; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
$id = required_param('id', PARAM_INT); // Course Module ID
$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
+ $display = optional_param('display', 0, PARAM_INT); // for teacherview action
+ $mode = optional_param('mode', '', PARAM_ALPHA); // for eacherview action todo use user pref
+
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
if ($action == 'navigation' && $pageid != LESSON_EOL) {
$currentpageid = $pageid; // very important not to alter $pageid.
if (empty($currentpageid)) {
- if (!$currentpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
- error('Navigation: first page not found');
- }
+ $currentpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0);
+ }
+ if (!empty($currentpageid)) { // if still empty, then something is wrong
+ $button .= '</td><td>'.
+ '<form target="'. $CFG->framename .'" method="get" action="'. $CFG->wwwroot .'/mod/lesson/lesson.php">'.
+ '<input type="hidden" name="id" value="'. $cm->id .'" />'.
+ '<input type="hidden" name="action" value="editpage" />'.
+ '<input type="hidden" name="redirect" value="navigation" />'.
+ '<input type="hidden" name="pageid" value="'. $currentpageid .'" />'.
+ '<input type="submit" value="'. get_string('editpagecontent', 'lesson') .'" /></form>';
}
- $button .= '</td><td>'.
- '<form target="'. $CFG->framename .'" method="get" action="'. $CFG->wwwroot .'/mod/lesson/lesson.php">'.
- '<input type="hidden" name="id" value="'. $cm->id .'" />'.
- '<input type="hidden" name="action" value="editpage" />'.
- '<input type="hidden" name="redirect" value="navigation" />'.
- '<input type="hidden" name="pageid" value="'. $currentpageid .'" />'.
- '<input type="submit" value="'. get_string('editpagecontent', 'lesson') .'" /></form>';
}
$button .= '</td></tr></table>';
} else {
$button, // took out update_module_button($cm->id, $course->id, $strlesson) and replaced it with $button
navmenu($course, $cm));
+ if (isteacher($course->id)) {
+
+ if ($action == 'teacherview' and $display) {
+ // teacherview tab not selected when displaying a single page/question
+ $currenttab = '';
+ } else {
+ $currenttab = $action;
+ }
+ include('tabs.php');
+ }
+
// set up some general variables
$usehtmleditor = can_use_html_editor();
$path = $CFG->wwwroot .'/course';
// password protected lesson code
if ($lesson->usepassword && !isteacher($course->id)) {
$correctpass = false;
- if (isset($_POST['userpassword'])) {
- if ($lesson->password == md5(trim(clean_param($_POST['userpassword'], PARAM_CLEAN)))) {
+ if ($password = optional_param('userpassword', '', PARAM_CLEAN)) {
+ if ($lesson->password == md5(trim($password))) {
$USER->lessonloggedin[$lesson->id] = true;
$correctpass = true;
}
echo '<form name="password" method="post" action="view.php">' . "\n";
echo '<input type="hidden" name="id" value="'. $cm->id .'" />' . "\n";
echo '<input type="hidden" name="action" value="navigation" />' . "\n";
- echo '<table cellpadding="7px">';
- if (isset($_POST['userpassword'])) {
- echo "<tr align=\"center\" style='color:#DF041E;'><td>".get_string('loginfail', 'lesson') .'</td></tr>';
+ if (optional_param('userpassword', 0, PARAM_CLEAN)) {
+ notify(get_string('loginfail', 'lesson'));
}
- echo '<tr align="center"><td>'. get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name)) .'</td></tr>';
- echo '<tr align="center"><td>'. get_string('enterpassword', 'lesson').' <input type="password" name="userpassword" /></td></tr>';
-
- echo '<tr align="center"><td>';
- echo '<span class="lessonbutton standardbutton"><a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. get_string('cancel', 'lesson') .'</a></span> ';
- echo ' <span class="lessonbutton standardbutton"><a href="javascript:document.password.submit();">'. get_string('continue', 'lesson') .'</a></span>';
- echo '</td></tr></table>';
+ echo "<div align=\"center\">\n".
+ get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name))."<br /><br />\n".
+ get_string('enterpassword', 'lesson')." <input type=\"password\" name=\"userpassword\" /><br /><br />\n";
+
+ echo '<span class="lessonbutton standardbutton"><a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. get_string('cancel', 'lesson') .'</a></span> '.
+ ' <span class="lessonbutton standardbutton"><a href="javascript:document.password.submit();">'. get_string('continue', 'lesson') .'</a></span>'.
+ "</div>\n";
print_simple_box_end();
exit();
}
$timedflag = false;
$attemptflag = false;
if (empty($pageid)) {
- // check for dependencies first
+ // make sure there are pages to view
+ if (!get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
+ if (isstudent($course->id)) {
+ notify(get_string('lessonnotready', 'lesson', $course->teacher)); // a nice message to the student
+ } else {
+ if (!count_records('lesson_pages', 'lessonid', $lesson->id)) {
+ redirect('view.php?id='.$cm->id); // no pages - redirect to add pages
+ } else {
+ notify(get_string('lessonpagelinkingbroken', 'lesson')); // ok, bad mojo
+ }
+ }
+ print_footer($course);
+ exit();
+ }
+
+ // check for dependencies
if ($lesson->dependency and !isteacher($course->id)) {
if ($dependentlesson = get_record('lesson', 'id', $lesson->dependency)) {
// lesson exists, so we can proceed
}
}
- if (isset($_POST['startlastseen'])) {
- if ($_POST['startlastseen'] == 'yes') { // continue a previous test, need to update the clock (think this option is disabled atm)
- $timer->starttime = time() - ($timer->lessontime - $timer->starttime);
- $timer->lessontime = time();
- } elseif ($_POST['startlastseen'] == 'no') { // starting over
- // starting over, so reset the clock
- $timer->starttime = time();
- $timer->lessontime = time();
- }
+ $startlastseen = optional_param('startlastseen', '', PARAM_ALPHA);
+ if ($startlastseen == 'yes') { // continue a previous test, need to update the clock (think this option is disabled atm)
+ $timer->starttime = time() - ($timer->lessontime - $timer->starttime);
+ $timer->lessontime = time();
+ } else if ($startlastseen == 'no') { // starting over
+ // starting over, so reset the clock
+ $timer->starttime = time();
+ $timer->lessontime = time();
}
// for timed lessons, display clock
echo '</div><!--end slideshow div-->';
echo '<div class="branchslidebottom">' . $fullbuttonhtml . '</div>';
} else {
- print_simple_box_start('center');
- echo $fullbuttonhtml;
- print_simple_box_end();
+ echo '<tr><td>';
+ print_simple_box($fullbuttonhtml, 'center');
+ echo '</td></tr></table>'; // ends the answers table
}
echo '<input type="hidden" name="jumpto" />';
echo "</table>\n";
} else {
// end of lesson reached work out grade
+
+ // check to see if the student ran out of time
+ $outoftime = optional_param('outoftime', '', PARAM_ALPHA);
if ($lesson->timed && !isteacher($course->id)) {
- if (isset($_GET["outoftime"])) {
- if ($_GET["outoftime"] == "normal") {
- print_simple_box(get_string("eolstudentoutoftime", "lesson"), "center");
- }
+ if ($outoftime == 'normal') {
+ print_simple_box(get_string("eolstudentoutoftime", "lesson"), "center");
}
}
}
} else {
if ($lesson->timed) {
- if (isset($_GET["outoftime"])) {
- if ($_GET["outoftime"] == "normal") {
- $grade = new stdClass;
- $grade->lessonid = $lesson->id;
- $grade->userid = $USER->id;
- $grade->grade = 0;
- $grade->completed = time();
- if (!$lesson->practice) {
- if (!$newgradeid = insert_record("lesson_grades", $grade)) {
- error("Navigation: grade not inserted");
- }
+ if ($outoftime == 'normal') {
+ $grade = new stdClass;
+ $grade->lessonid = $lesson->id;
+ $grade->userid = $USER->id;
+ $grade->grade = 0;
+ $grade->completed = time();
+ if (!$lesson->practice) {
+ if (!$newgradeid = insert_record("lesson_grades", $grade)) {
+ error("Navigation: grade not inserted");
}
- echo get_string("eolstudentoutoftimenoanswers", "lesson");
}
+ echo get_string("eolstudentoutoftimenoanswers", "lesson");
}
} else {
echo get_string("welldone", "lesson");
/*******************teacher view **************************************/
elseif ($action == 'teacherview') {
- // link to grade essay questions and to report
- if ($userattempts = get_records("lesson_attempts", "lessonid", $lesson->id)) { // just check to see if anyone has answered any questions.
- $usercount = array();
- foreach ($userattempts as $userattempts) {
- $usercount[$userattempts->userid] = 0;
- }
- $a = new stdClass;
- $a->users = count($usercount);
- $a->usersname = $course->students;
- echo "<div align=\"right\"><a href=\"report.php?id=$cm->id\">".get_string("viewlessonstats", "lesson", $a)."</a></div>";
- }
- if ($essaypages = get_records_select("lesson_pages", "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) { // get pages that are essay
- // get only the attempts that are in response to essay questions
- $essaypageids = implode(",", array_keys($essaypages)); // all the pageids in comma seperated list
- if ($essayattempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND pageid IN($essaypageids)")) {
- $studentessays = array();
- // makes an array that organizes essayattempts by grouping userid, then pageid, then try count
- foreach ($essayattempts as $essayattempt) {
- $studentessays[$essayattempt->userid][$essayattempt->pageid][$essayattempt->retry][] = $essayattempt;
- }
- $a = new stdClass;
- $a->notgradedcount = 0;
- $a->notsentcount = 0;
- foreach ($studentessays as $studentid => $pages) { // students
- $attempts = count_records('lesson_grades', 'userid', $studentid, 'lessonid', $lesson->id);
- $count = 0;
- foreach ($pages as $tries) { // pages
- // go through each essay per page
- foreach($tries as $try) { // actual attempts
- if ($attempts == $count) {
- break; // dont count unfinnished attempts
- }
- $count++;
-
- // make sure they didn't answer it more than the max number of attmepts
- if (count($try) > $lesson->maxattempts) {
- $essay = $try[$lesson->maxattempts-1];
- } else {
- $essay = end($try);
- }
- $essayinfo = unserialize($essay->useranswer);
- if ($essayinfo->graded == 0) {
- $a->notgradedcount++;
- }
- if ($essayinfo->sent == 0) {
- $a->notsentcount++;
- }
- }
- }
- }
- echo "<div align=\"right\"><a href=\"view.php?id=$cm->id&action=essayview\">".get_string("gradeessay", "lesson", $a)."</a></div><br />";
- }
+ // set collapsed flag
+ if ($mode == 'collapsed') {
+ $collapsed = true;
+ } else {
+ $collapsed = false;
}
print_heading_with_help(format_string($lesson->name,true), "overview", "lesson");
// get number of pages
- if ($page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) {
- $npages = 1;
- while (true) {
- if ($page->nextpageid) {
- if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) {
- error("Teacher view: Next page not found!");
- }
- } else {
- // last page reached
- break;
- }
- $npages++;
- }
- }
+ $npages = count_records('lesson_pages', 'lessonid', $lesson->id);
if (!$page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) {
// if there are no pages give teacher the option to create a new page or a new branch table
}
echo '</div>';
} else {
- print_heading("<a href=\"view.php?id=$cm->id&action=navigation\">".get_string("checknavigation",
- "lesson")."</a>\n");
// print the pages
echo "<form name=\"lessonpages\" method=\"post\" action=\"view.php\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
echo "<input type=\"hidden\" name=\"pageid\" />\n";
$branch = false;
$singlePage = false;
- if($lesson->tree && !isset($_GET['display']) && !isset($_GET['viewAll'])) {
- echo "<div align=\"center\">";
- echo get_string("treeview", "lesson")."<br /><br />";
- echo "<a href=\"view.php?id=$id&viewAll=1\">".get_string("viewallpages", "lesson")."</a><br /><br />\n";
- echo "<table><tr><td>";
+ if($collapsed and !$display) {
+ echo "<div align=\"center\">\n";
+ echo "<table><tr><td>\n";
lesson_print_tree($page->id, $lesson->id, $cm->id, $CFG->pixpath);
- echo "</td></tr></table>";
- echo "<br /><a href=\"view.php?id=$id&viewAll=1\">".get_string("viewallpages", "lesson")."</a>\n";
- echo "</div>";
+ echo "</td></tr></table>\n";
+ echo "</div>\n";
} else {
- if(isset($_GET['display']) && !isset($_GET['viewAll'])) {
- $display = clean_param($_GET['display'], PARAM_INT);
+ if($display) {
while(true)
{
if($page->id == $display && $page->qtype == LESSON_BRANCHTABLE) {
break;
}
}
- echo "<center><a href=\"view.php?id=$id&viewAll=1\">".get_string("viewallpages", "lesson")."</a><br />\n";
- echo "<a href=\"view.php?id=$id\">".get_string("backtreeview", "lesson")."</a><br />\n";
- echo "<table cellpadding=\"5\" border=\"0\" width=\"80%\">\n";
+ echo "<table align=\"center\" cellpadding=\"5\" border=\"0\" width=\"80%\">\n";
if (isteacheredit($course->id)) {
echo "<tr><td align=\"left\"><small><a href=\"import.php?id=$cm->id&pageid=$page->prevpageid\">".
get_string("importquestions", "lesson")."</a> | ".
get_string("addaquestionpage", "lesson")." ".get_string("here","lesson").
"</a></small></td></tr>\n";
}
- } else {
- if($lesson->tree) {
- echo "<center><a href=\"view.php?id=$id\">".get_string("backtreeview", "lesson")."</a><br /></center>\n";
- }
+ } else {
echo "<table align=\"center\" cellpadding=\"5\" border=\"0\" width=\"80%\">\n";
if (isteacheredit($course->id)) {
echo "<tr><td align=\"left\"><small><a href=\"import.php?id=$cm->id&pageid=0\">".
"</a></small></td></tr>\n";
}
}
- /// end tree code (note, there is an "}" below for an else above)
+ /// end collapsed code (note, there is an "}" below for an else above)
while (true) {
echo "<tr><td>\n";
echo "<table width=\"100%\" border=\"1\" class=\"generalbox\"><tr><th colspan=\"2\">".format_string($page->title)." \n";
break;
}
}
- } // end of else from above tree code!!!
+ } // end of else from above collapsed code!!!
echo "</table></form>\n";
- if(isset($_GET['display']) && !isset($_GET['viewAll'])) {
- echo "<center><a href=\"view.php?id=$id&viewAll=1\">".get_string("viewallpages", "lesson")."</a><br />\n";
- }
- if($lesson->tree && (isset($_GET['display']) || isset($_GET['viewAll']))) {
- echo "<center><a href=\"view.php?id=$id\">".get_string("backtreeview", "lesson")."</a><br /></center>\n";
- }
- print_heading("<a href=\"view.php?id=$cm->id&action=navigation\">".get_string("checknavigation",
- "lesson")."</a>\n");
}
}
// get lesson pages that are essay
if (!$pages = get_records_select("lesson_pages", "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) {
- error("Error: could not find lesson pages");
+ notify(get_string('noessayquestionsfound', 'lesson'));
+ print_footer($course);
+ exit();
+ }
+
+ // get only the attempts that are in response to essay questions
+ $pageids = implode(",", array_keys($pages)); // all the pageids in comma seperated list
+ if (!$essayattempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND pageid IN($pageids)")) {
+ notify(get_string('noonehasanswered', 'lesson'));//error ("No one has answered essay questions yet...");
+ print_footer($course);
+ exit();
}
// get all the users who have taken this lesson, order by their last name
error("Error: could not find users");
}
- // get only the attempts that are in response to essay questions
- $pageids = implode(",", array_keys($pages)); // all the pageids in comma seperated list
- if (!$essayattempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND pageid IN($pageids)")) {
- error ("No one has answered essay questions yet...");
- }
-
// group all the essays by userid
$studentessays = array();
foreach ($essayattempts as $essay) {
$studentessays[$essay->userid][$essay->pageid][$essay->retry][] = $essay;
}
- print_heading("<a href=\"view.php?id=$cm->id\">".get_string("gobacktolesson", "lesson")."</a>");
$table = new stdClass;
$table->head = array($course->students, get_string("essays", "lesson"), get_string("email", "lesson"));
$table->align = array("left", "left", "left");
// cycle through all the ids
foreach ($studentids as $id) {
- $studentname = $users[$id]->lastname.", ".$users[$id]->firstname;
+ $studentname = fullname($users[$id], true);
$essaylinks = array();
// number of attempts on the lesson
$table->align = array("left");
$table->wrap = array();
$table->width = "70%";
- $table->size = array("100%");
+ $table->size = array("100%");
$table->head = array(get_string("question", "lesson"));
confirm_sesskey();
- if (isset($_GET['userid'])) {
- $userid = clean_param($_GET['userid'], PARAM_INT);
+ if ($userid = optional_param('userid', 0, PARAM_INT)) {
$queryadd = " AND userid = ".$userid;
if (! $users = get_records("user", "id", $userid)) {
error("Error: could not find users");
if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id", "completed")) {
$grades = array();
}
-
- echo "<div align=\"center\">";
- $titleinfo->maxhighscores = $lesson->maxhighscores;
- $titleinfo->name = format_string($lesson->name);
- echo get_string("topscorestitle", "lesson", $titleinfo)."<br><br>";
+
+ print_heading(get_string("topscorestitle", "lesson", $lesson->maxhighscores), 'center', 4);
if (!$highscores = get_records_select("lesson_high_scores", "lessonid = $lesson->id")) {
echo get_string("nohighscores", "lesson")."<br>";
$topscores[$grade][] = $highscore->nickname;
}
krsort($topscores);
+
+ $table = new stdClass;
+ $table->align = array('center', 'left', 'right');
+ $table->wrap = array();
+ $table->width = "30%";
+ $table->cellspacing = '10px';
+ $table->size = array('*', '*', '*');
+
+ $table->head = array(get_string("rank", "lesson"), $course->students, get_string("scores", "lesson"));
- echo "<table cellspacing=\"10px\">";
- echo "<tr align=\"center\"><td>".get_string("rank", "lesson")."</td><td>$course->students</td><td>".get_string("scores", "lesson")."</td></tr>";
$printed = 0;
while (true) {
$temp = current($topscores);
$rank = $printed + 1;
sort($temp);
foreach ($temp as $student) {
- echo "<tr><td align=\"right\">$rank</td><td>$student</td><td align=\"right\">$score</td></tr>";
-
+ $table->data[] = array($rank, $student, $score);
}
$printed++;
if (!next($topscores) || !($printed < $lesson->maxhighscores)) {
break;
}
}
- echo "</table>";
+ print_table($table);
}
- if (isset($_GET['link'])) {
- echo "<br /><div class=\"lessonbutton standardbutton\"><a href=\"../../course/view.php?id=$course->id\">".get_string("returntocourse", "lesson")."</a></div>";
- } else {
- echo "<br /><span class=\"lessonbutton standardbutton\"><a href=\"../../course/view.php?id=$course->id\">".get_string("cancel", "lesson").'</a></span> '.
- " <span class=\"lessonbutton standardbutton\"><a href=\"view.php?id=$cm->id&action=navigation\">".get_string("startlesson", "lesson").'</a></span>';
+
+ if (!isteacher($course->id)) { // teachers don't need the links
+ echo '<div align="center">';
+ if (optional_param('link', 0, PARAM_INT)) {
+ echo "<br /><div class=\"lessonbutton standardbutton\"><a href=\"../../course/view.php?id=$course->id\">".get_string("returntocourse", "lesson")."</a></div>";
+ } else {
+ echo "<br /><span class=\"lessonbutton standardbutton\"><a href=\"../../course/view.php?id=$course->id\">".get_string("cancel", "lesson").'</a></span> '.
+ " <span class=\"lessonbutton standardbutton\"><a href=\"view.php?id=$cm->id&action=navigation\">".get_string("startlesson", "lesson").'</a></span>';
+ }
+ echo "</div>";
}
- echo "</div>";
-
}
/*******************update high scores **************************************/
elseif ($action == 'updatehighscores') {
$newhighscore->lessonid = $lesson->id;
$newhighscore->userid = $USER->id;
$newhighscore->gradeid = $newgrade->id;
- if (isset($_GET['name'])) {
- $newhighscore->nickname = clean_param($_GET['name'], PARAM_CLEAN);
- }
+ $newhighscore->nickname = optional_param('name', '', PARAM_CLEAN);
+
if (!insert_record("lesson_high_scores", $newhighscore)) {
error("Insert of new high score Failed!");
}
elseif ($action == 'nameforhighscores') {
print_heading_with_help(format_string($lesson->name,true), "overview", "lesson");
echo "<div align=\"center\">";
- if (isset($_POST['name'])) {
- $name = trim(clean_param($_POST['name'], PARAM_CLEAN));
+ if ($name = trim(optional_param('name', '', PARAM_CLEAN))) {
if (lesson_check_nickname($name)) {
redirect("view.php?id=$cm->id&action=updatehighscores&name=$name&sesskey=".$USER->sesskey, get_string("nameapproved", "lesson"));
} else {
- echo get_string("namereject", "lesson")."<br><br>";
+ echo get_string("namereject", "lesson")."<br /><br />";
}
}