Added some more stats to reports, added more actions to collapsed view and increased speed of lesson by using lesson_set_message() and redirects with 0 second delays.

This commit is contained in:
mark-nielsen 2006-09-13 03:42:16 +00:00
parent 1975d8bd3e
commit 260a56b114
12 changed files with 99 additions and 58 deletions

View File

@ -59,5 +59,6 @@
if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
error("Add cluster: answer record not inserted");
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('addedcluster', 'lesson'));
lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
?>

View File

@ -55,8 +55,11 @@
if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
error("Add end of branch: answer record not inserted");
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('addedanendofbranch', 'lesson'));
lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess');
} else {
notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id");
lesson_set_message(get_string('nobranchtablefound', 'lesson'));
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
?>

View File

@ -46,4 +46,5 @@
if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
error("Add end of cluster: answer record not inserted");
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('addedendofcluster', 'lesson'));
lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");

View File

@ -47,5 +47,6 @@
error("Delete: unable to set prev link");
}
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('deletedpage', 'lesson'));
lesson_set_message(get_string('deletedpage', 'lesson').': '.format_string($thispage->title, true), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
?>

View File

@ -181,6 +181,7 @@
}
}
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('insertedpage', 'lesson'));
lesson_set_message(get_string('insertedpage', 'lesson').': '.format_string($newpage->title, true), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
?>

View File

@ -92,5 +92,6 @@
if (!set_field("lesson_pages", "nextpageid", 0, "id", $newlastpageid)) {
error("Moveit: unable to update link");
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('movedpage', 'lesson'));
lesson_set_message(get_string('movedpage', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
?>

View File

@ -170,10 +170,13 @@
if ($form->redisplay) {
redirect("$CFG->wwwroot/mod/lesson/lesson.php?id=$cm->id&action=editpage&pageid=$page->id&redirect=$redirect");
} else if ($redirect == 'navigation') {
}
lesson_set_message(get_string('updatedpage', 'lesson').': '.format_string($page->title, true), 'notifysuccess');
if ($redirect == 'navigation') {
// takes us back to viewing the page
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$page->id", get_string('updatedpage', 'lesson'));
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$page->id");
} else {
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('updatedpage', 'lesson'));
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
}
?>

View File

@ -86,7 +86,7 @@
$table->data[] = array("<a href=\"$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&amp;mode=single&amp;pageid=".$page->id."\">".format_string($pages[$pageid]->title,true).'</a>',
lesson_get_qtype_name($page->qtype),
implode("<br />\n", $jumps),
lesson_print_page_actions($cm->id, $page->id, $npages, true)
lesson_print_page_actions($cm->id, $page, $npages, true, true)
);
$pageid = $page->nextpageid;
}
@ -115,7 +115,7 @@
echo "<tr><td>\n";
echo "<table width=\"100%\" border=\"1\" class=\"generalbox\"><tr><th colspan=\"2\">".format_string($page->title)."&nbsp;&nbsp;\n";
lesson_print_page_actions($cm->id, $page->id, $npages);
lesson_print_page_actions($cm->id, $page, $npages);
echo "</th></tr>\n";
echo "<tr><td colspan=\"2\">\n";
$options = new stdClass;

View File

@ -110,10 +110,11 @@
// Log it
add_to_log($course->id, 'lesson', 'update grade', "essay.php?id=$cm->id", $lesson->name, $cm->id);
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('updatesuccess', 'lesson'));
lesson_set_message(get_string('changessaved'), 'notifysuccess');
} else {
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('updatefailed', 'lesson'));
lesson_set_message(get_string('updatefailed', 'lesson'));
}
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
} else {
error('Something is wrong with the form data');
}
@ -158,33 +159,38 @@
foreach ($attempts as $attempt) {
$essayinfo = unserialize($attempt->useranswer);
if ($essayinfo->graded and !$essayinfo->sent) {
$subject = get_string('essayemailsubject', 'lesson', format_string($pages[$attempt->pageid]->title,true));
$message = get_string('question', 'lesson').':<br>';
$message .= format_text($pages[$attempt->pageid]->contents, FORMAT_MOODLE, $options);
$message .= '<br><br>';
$message .= get_string('yourresponse', 'lesson').':<br>';
$message .= format_text(stripslashes($essayinfo->answer));
$message .= '<br><br>';
$message .= get_string('commentswithname', 'lesson', $USER).':<br>';
$message .= format_text(stripslashes($essayinfo->response), FORMAT_MOODLE, $options);
$message .= '<br><br>';
if ($essayinfo->graded and !$essayinfo->sent) {
// Holds values for the essayemailsubject string for the email message
$a = new stdClass;
// Set the grade
$grades = get_records_select('lesson_grades', "lessonid = $lesson->id and userid = $attempt->userid", 'completed', '*', $attempt->retry, 1);
$grade = current($grades);
$grade = current($grades);
$a->newgrade = $grade->grade;
// Set the points
if ($lesson->custom) {
$points->score = $essayinfo->score;
$points->outof = $answers[$attempt->pageid]->score;
$message .= get_string('youhavereceived', 'lesson', $points);
$a->earned = $essayinfo->score;
$a->outof = $answers[$attempt->pageid]->score;
} else {
$points->score = $essayinfo->score;
$points->outof = 1;
$message .= get_string('youhavereceived', 'lesson', $points);
$a->earned = $essayinfo->score;
$a->outof = 1;
}
$message .= '<br><br>';
$message .= get_string('yourgradeisnow', 'lesson', $grade->grade).'%.';
// Set rest of the message values
$a->question = format_text($pages[$attempt->pageid]->contents, FORMAT_MOODLE, $options);
$a->response = format_text(stripslashes($essayinfo->answer));
$a->teacher = $course->teacher;
$a->comment = format_text(stripslashes($essayinfo->response), FORMAT_MOODLE, $options);
// Fetch message HTML and plain text formats
$message = get_string('essayemailmessage', 'lesson', $a);
$plaintxt = format_text_email($message, FORMAT_HTML);
// Subject
$subject = get_string('essayemailsubject', 'lesson', format_string($pages[$attempt->pageid]->title,true));
if(email_to_user($users[$attempt->userid], $USER, $subject, $plaintxt, $message)) {
$essayinfo->sent = 1;
$attempt->useranswer = addslashes(serialize($essayinfo));
@ -196,7 +202,8 @@
}
}
}
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('emailsuccess', 'lesson'));
lesson_set_message(get_string('emailsuccess', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
break;
}

View File

@ -465,12 +465,13 @@ function lesson_print_time_remaining($starttime, $maxtime, $return = false) {
*
* @uses $CFG
* @param int $cmid Course Module ID
* @param int $pageid Page record ID for which the actions affect
* @param object $page Page record
* @param boolean $printmove Flag to print the move button or not
* @param boolean $printaddpage Flag to print the add page drop-down or not
* @param boolean $return Return flag
* @return mixed boolean/string
**/
function lesson_print_page_actions($cmid, $pageid, $printmove, $return = false) {
function lesson_print_page_actions($cmid, $page, $printmove, $printaddpage = false, $return = false) {
global $CFG;
$context = get_context_instance(CONTEXT_MODULE, $cmid);
@ -478,18 +479,31 @@ function lesson_print_page_actions($cmid, $pageid, $printmove, $return = false)
if (has_capability('mod/lesson:edit', $context)) {
if ($printmove) {
$actions[] = "<a title=\"".get_string('move')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=move&pageid=$pageid\">
$actions[] = "<a title=\"".get_string('move')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=move&pageid=$page->id\">
<img src=\"$CFG->pixpath/t/move.gif\" height=\"11\" width=\"11\" alt=\"".get_string('move')."\" border=\"0\" /></a>\n";
}
$actions[] = "<a title=\"".get_string('update')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&amp;action=editpage&amp;pageid=$pageid\">
$actions[] = "<a title=\"".get_string('update')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&amp;action=editpage&amp;pageid=$page->id\">
<img src=\"$CFG->pixpath/t/edit.gif\" height=\"11\" width=\"11\" alt=\"".get_string('update')."\" border=\"0\" /></a>\n";
$actions[] = "<a title=\"".get_string('preview')."\" href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&amp;pageid=$pageid\">
$actions[] = "<a title=\"".get_string('preview')."\" href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&amp;pageid=$page->id\">
<img src=\"$CFG->pixpath/t/preview.gif\" height=\"11\" width=\"11\" alt=\"".get_string('preview')."\" border=\"0\" /></a>\n";
$actions[] = "<a title=\"".get_string('delete')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&amp;sesskey=".sesskey()."&amp;action=confirmdelete&amp;pageid=$pageid\">
$actions[] = "<a title=\"".get_string('delete')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&amp;sesskey=".sesskey()."&amp;action=confirmdelete&amp;pageid=$page->id\">
<img src=\"$CFG->pixpath/t/delete.gif\" height=\"11\" width=\"11\" alt=\"".get_string('delete')."\" border=\"0\" /></a>\n";
if ($printaddpage) {
// Add page drop-down
$options = array();
$options['addcluster&amp;sesskey='.sesskey()] = get_string('clustertitle', 'lesson');
$options['addendofcluster&amp;sesskey='.sesskey()] = get_string('endofclustertitle', 'lesson');
$options['addbranchtable'] = get_string('branchtable', 'lesson');
$options['addendofbranch&amp;sesskey='.sesskey()] = get_string('endofbranch', 'lesson');
$options['addpage'] = get_string('question', 'lesson');
// Base url
$common = "$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&amp;pageid=$page->id&amp;action=";
$actions[] = popup_form($common, $options, "addpage_$page->id", '', get_string('addpage', 'lesson').'...', '', '', true);
}
}
$actions = implode(' ', $actions);

View File

@ -296,8 +296,7 @@
$stattable->align = array("center", "center", "center", "center", "center", "center");
$stattable->wrap = array("nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap");
$stattable->width = "90%";
$stattable->size = array("*", "*", "*", "*", "*", "*");
$stattable->data[] = array($avescore, $avetime, $highscore, $lowscore, $hightime, $lowtime);
$stattable->data[] = array($avescore.'%', $avetime, $highscore.'%', $lowscore.'%', $hightime, $lowtime);
print_table($stattable);
}
@ -328,14 +327,6 @@
error("Could not find first page");
}
if (!empty($userid)) {
// print out users name
$headingobject->lastname = $students[$userid]->lastname;
$headingobject->firstname = $students[$userid]->firstname;
$headingobject->attempt = $try + 1;
print_heading(get_string("studentattemptlesson", "lesson", $headingobject));
}
// now gather the stats into an object
$firstpageid = $pageid;
$pagestats = array();
@ -846,9 +837,17 @@
if (!empty($userid)) {
// if looking at a students try, print out some basic stats at the top
// print out users name
//$headingobject->lastname = $students[$userid]->lastname;
//$headingobject->firstname = $students[$userid]->firstname;
//$headingobject->attempt = $try + 1;
//print_heading(get_string("studentattemptlesson", "lesson", $headingobject));
print_heading(get_string('attempt', 'lesson', $try+1));
$table->head = array();
$table->align = array("right", "left");
$table->size = array("*", "*");
$table->class = 'generaltable userinfotable';
if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $userid", "completed", "*", $try, 1)) {
$grade = -1;
@ -867,18 +866,23 @@
if ($timetotake == -1 || $completed == -1 || $grade == -1) {
$table->align = array("center");
$table->size = array("*");
$table->data[] = array(get_string("notcompleted", "lesson"));
} else {
$table->align = array("right", "left");
$table->size = array("*", "*");
$user = $students[$userid];
$gradeinfo = lesson_grade($lesson, $try, $user->id);
$table->data[] = array($course->student.':', print_user_picture($user->id, $course->id, $user->picture, 0, true).fullname($user, true));
$table->data[] = array(get_string("timetaken", "lesson").":", format_time($timetotake));
$table->data[] = array(get_string("completed", "lesson").":", userdate($completed));
$table->data[] = array(get_string('rawgrade', 'lesson').':', $gradeinfo->earned.'/'.$gradeinfo->total);
$table->data[] = array(get_string("grade", "lesson").":", $grade."%");
}
print_table($table);
// Don't want this class for later tables
unset($table->class);
echo "<br />";
}

View File

@ -10,6 +10,11 @@
font-size: .8em;
}
.mod-lesson .userinfotable .cell,
.mod-lesson .userinfotable .userpicture {
vertical-align: middle;
}
/***
*** Style for view.php
***/