From: mark-nielsen Date: Wed, 13 Sep 2006 03:42:16 +0000 (+0000) Subject: Added some more stats to reports, added more actions to collapsed view and increased... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=260a56b1140e4ae3843f65277a405fcbd6ad63bb;p=moodle.git 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. --- diff --git a/mod/lesson/action/addcluster.php b/mod/lesson/action/addcluster.php index ae547b4826..e3148baea0 100644 --- a/mod/lesson/action/addcluster.php +++ b/mod/lesson/action/addcluster.php @@ -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"); ?> \ No newline at end of file diff --git a/mod/lesson/action/addendofbranch.php b/mod/lesson/action/addendofbranch.php index bf72e4a654..5341071a12 100644 --- a/mod/lesson/action/addendofbranch.php +++ b/mod/lesson/action/addendofbranch.php @@ -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"); ?> diff --git a/mod/lesson/action/addendofcluster.php b/mod/lesson/action/addendofcluster.php index dd379c3420..dc05fa7093 100644 --- a/mod/lesson/action/addendofcluster.php +++ b/mod/lesson/action/addendofcluster.php @@ -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')); \ No newline at end of file + lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess'); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); \ No newline at end of file diff --git a/mod/lesson/action/delete.php b/mod/lesson/action/delete.php index 18cd78f13a..3ac6702de9 100644 --- a/mod/lesson/action/delete.php +++ b/mod/lesson/action/delete.php @@ -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"); ?> diff --git a/mod/lesson/action/insertpage.php b/mod/lesson/action/insertpage.php index 0fb374e6fc..b377c9bcce 100644 --- a/mod/lesson/action/insertpage.php +++ b/mod/lesson/action/insertpage.php @@ -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"); ?> diff --git a/mod/lesson/action/moveit.php b/mod/lesson/action/moveit.php index 32d9e73504..abc5258e57 100644 --- a/mod/lesson/action/moveit.php +++ b/mod/lesson/action/moveit.php @@ -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"); ?> diff --git a/mod/lesson/action/updatepage.php b/mod/lesson/action/updatepage.php index 732958c887..f1df47d6bb 100644 --- a/mod/lesson/action/updatepage.php +++ b/mod/lesson/action/updatepage.php @@ -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"); } ?> diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php index f3af00ba4d..e704f48ed3 100644 --- a/mod/lesson/edit.php +++ b/mod/lesson/edit.php @@ -86,7 +86,7 @@ $table->data[] = array("wwwroot/mod/lesson/edit.php?id=$cm->id&mode=single&pageid=".$page->id."\">".format_string($pages[$pageid]->title,true).'', lesson_get_qtype_name($page->qtype), implode("
\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 "\n"; echo "\n"; echo "
".format_string($page->title)."  \n"; - lesson_print_page_actions($cm->id, $page->id, $npages); + lesson_print_page_actions($cm->id, $page, $npages); echo "
\n"; $options = new stdClass; diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index 32209e4d9e..daf001dbe4 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -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').':
'; - $message .= format_text($pages[$attempt->pageid]->contents, FORMAT_MOODLE, $options); - $message .= '

'; - $message .= get_string('yourresponse', 'lesson').':
'; - $message .= format_text(stripslashes($essayinfo->answer)); - $message .= '

'; - $message .= get_string('commentswithname', 'lesson', $USER).':
'; - $message .= format_text(stripslashes($essayinfo->response), FORMAT_MOODLE, $options); - $message .= '

'; + 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 .= '

'; - $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; } diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index a5e1753a8d..eb6ae9875b 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -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[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&action=move&pageid=$pageid\"> + $actions[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&action=move&pageid=$page->id\"> pixpath/t/move.gif\" height=\"11\" width=\"11\" alt=\"".get_string('move')."\" border=\"0\" />\n"; } - $actions[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&action=editpage&pageid=$pageid\"> + $actions[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&action=editpage&pageid=$page->id\"> pixpath/t/edit.gif\" height=\"11\" width=\"11\" alt=\"".get_string('update')."\" border=\"0\" />\n"; - $actions[] = "wwwroot/mod/lesson/view.php?id=$cmid&pageid=$pageid\"> + $actions[] = "wwwroot/mod/lesson/view.php?id=$cmid&pageid=$page->id\"> pixpath/t/preview.gif\" height=\"11\" width=\"11\" alt=\"".get_string('preview')."\" border=\"0\" />\n"; - $actions[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=confirmdelete&pageid=$pageid\"> + $actions[] = "wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=confirmdelete&pageid=$page->id\"> pixpath/t/delete.gif\" height=\"11\" width=\"11\" alt=\"".get_string('delete')."\" border=\"0\" />\n"; + if ($printaddpage) { + // Add page drop-down + $options = array(); + $options['addcluster&sesskey='.sesskey()] = get_string('clustertitle', 'lesson'); + $options['addendofcluster&sesskey='.sesskey()] = get_string('endofclustertitle', 'lesson'); + $options['addbranchtable'] = get_string('branchtable', 'lesson'); + $options['addendofbranch&sesskey='.sesskey()] = get_string('endofbranch', 'lesson'); + $options['addpage'] = get_string('question', 'lesson'); + // Base url + $common = "$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&pageid=$page->id&action="; + + $actions[] = popup_form($common, $options, "addpage_$page->id", '', get_string('addpage', 'lesson').'...', '', '', true); + } } $actions = implode(' ', $actions); diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 814ef87424..d9588f8ac4 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -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 "
"; } diff --git a/mod/lesson/styles.php b/mod/lesson/styles.php index 7d0ed743d5..3f2db20664 100644 --- a/mod/lesson/styles.php +++ b/mod/lesson/styles.php @@ -10,6 +10,11 @@ font-size: .8em; } +.mod-lesson .userinfotable .cell, +.mod-lesson .userinfotable .userpicture { + vertical-align: middle; +} + /*** *** Style for view.php ***/