]> git.mjollnir.org Git - moodle.git/commitdiff
Added some more stats to reports, added more actions to collapsed view and increased...
authormark-nielsen <mark-nielsen>
Wed, 13 Sep 2006 03:42:16 +0000 (03:42 +0000)
committermark-nielsen <mark-nielsen>
Wed, 13 Sep 2006 03:42:16 +0000 (03:42 +0000)
12 files changed:
mod/lesson/action/addcluster.php
mod/lesson/action/addendofbranch.php
mod/lesson/action/addendofcluster.php
mod/lesson/action/delete.php
mod/lesson/action/insertpage.php
mod/lesson/action/moveit.php
mod/lesson/action/updatepage.php
mod/lesson/edit.php
mod/lesson/essay.php
mod/lesson/locallib.php
mod/lesson/report.php
mod/lesson/styles.php

index ae547b4826e1e54bc6b6828d61e01f582a000569..e3148baea04c79baf34f460b6250622ab343b39e 100644 (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");
 ?>
\ No newline at end of file
index bf72e4a6549f2f7e2a40e6471b70ef2f25500a63..5341071a12a09d014f783964c682786a9b63c2cf 100644 (file)
         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");
 ?>
index dd379c3420c28e1e1b904778736c9764aa468813..dc05fa70930952d02371ff8953237f82ae375859 100644 (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'));
\ 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
index 18cd78f13a20a3c697fe45f1ecc71dff0390bdc7..3ac6702de9fe7f36d02a0cfc94ec813fbfe40fa9 100644 (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");
 ?>
index 0fb374e6fc59080dc75fad648ecaf28e69b49850..b377c9bcce47c197216c026a1d77511c09448c70 100644 (file)
             }
         }
     }
-
-    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");
 ?>
index 32d9e73504d54f993342605f8059ae09d3751a7f..abc5258e57207fe0be0071bae22fd86cd5934fe0 100644 (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");
 ?>
index 732958c887e78b7a89e44add28bed975f3678680..f1df47d6bba352dcd5576a2b15e3009e91a19c54 100644 (file)
 
     if ($form->redisplay) {
         redirect("$CFG->wwwroot/mod/lesson/lesson.php?id=$cm->id&amp;action=editpage&amp;pageid=$page->id&amp;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&amp;pageid=$page->id", get_string('updatedpage', 'lesson'));
+        redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&amp;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");
     }
 ?>
index f3af00ba4d9654f451d8be4c24fcecac787b07c1..e704f48ed37c4c4fbd8e4da1ca3a115664468c84 100644 (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;
                 }
 
                     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;
index 32209e4d9e9b3053e96a5a237d9d9646ad854b23..daf001dbe420760399581c53edbd452c5f81fa93 100644 (file)
                     // 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');
             }
             
             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));
                     }
                 }
             }
-            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;
     }
     
index a5e1753a8d244f193935a0885e3205659e2dc9a4..eb6ae9875bd2d56ffa629dc96cbc001df143297e 100644 (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);
index 814ef874247b312b83b4af54ad912e04bafa34e6..d9588f8ac4f0f6707fe82652433d791968e2d1cc 100644 (file)
         $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);
 }
             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();
 
         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;
 
             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 />";
         }
 
index 7d0ed743d5310e07ae98a2488d911fb97fd831af..3f2db206643dd159b242bc805f1178f1fc3dd0ce 100644 (file)
     font-size: .8em;
 }
 
+.mod-lesson .userinfotable .cell,
+.mod-lesson .userinfotable .userpicture {
+    vertical-align: middle;
+}
+
 /***
  *** Style for view.php
  ***/