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
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");
?>
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
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");
?>
}
}
}
-
- 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");
?>
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");
?>
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");
}
?>
$table->data[] = array("<a href=\"$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=single&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)." \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;
// 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;
}
*
* @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);
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&action=editpage&pageid=$pageid\">
+ $actions[] = "<a title=\"".get_string('update')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&action=editpage&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&pageid=$pageid\">
+ $actions[] = "<a title=\"".get_string('preview')."\" href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&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&sesskey=".sesskey()."&action=confirmdelete&pageid=$pageid\">
+ $actions[] = "<a title=\"".get_string('delete')."\" href=\"$CFG->wwwroot/mod/lesson/lesson.php?id=$cmid&sesskey=".sesskey()."&action=confirmdelete&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&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);
$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 />";
}
font-size: .8em;
}
+.mod-lesson .userinfotable .cell,
+.mod-lesson .userinfotable .userpicture {
+ vertical-align: middle;
+}
+
/***
*** Style for view.php
***/