diff --git a/lang/en_utf8/help/lesson/showattempts.html b/lang/en_utf8/help/lesson/showattempts.html new file mode 100644 index 0000000..f63db37 --- /dev/null +++ b/lang/en_utf8/help/lesson/showattempts.html @@ -0,0 +1,3 @@ +
Enabling this option allows students to view their previous attempts and grades in a given lesson. The instructor can enable this on a lesson by lesson basis. If enabled, the student can view their reports by clicking "Lessons" in the Activities block on the course home page. The Activities block should be enabled.
diff --git a/lang/en_utf8/lesson.php b/lang/en_utf8/lesson.php index fae21fb..970410b 100644 --- a/lang/en_utf8/lesson.php +++ b/lang/en_utf8/lesson.php @@ -250,8 +250,10 @@ $string['savepage'] = 'Save page'; $string['score'] = 'Score'; $string['scores'] = 'Scores'; $string['secondpluswrong'] = 'Not quite. Would you like to try again?'; +$string['seereports'] = "See reports"; $string['showanunansweredpage'] = 'Show an unanswered Page'; $string['showanunseenpage'] = 'Show an Unseen Page'; +$string['showattempts'] = 'Allow Students to see their own reports'; $string['singleanswer'] = 'Single Answer'; $string['skip'] = 'Skip navigation'; $string['slideshow'] = 'Slide Show'; diff --git a/local/db/upgrade.php b/local/db/upgrade.php new file mode 100644 index 0000000..96ead58 --- /dev/null +++ b/local/db/upgrade.php @@ -0,0 +1,22 @@ +setAttributes(XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timemodified'); + if (! field_exists($table, $field)) { + $result = $result && add_field($table, $field); + } + } + + return $result; +} + + +?> diff --git a/local/version.php b/local/version.php new file mode 100644 index 0000000..7d3a8e6 --- /dev/null +++ b/local/version.php @@ -0,0 +1,6 @@ + diff --git a/mod/lesson/index.php b/mod/lesson/index.php index ea33f44..a56996b 100644 --- a/mod/lesson/index.php +++ b/mod/lesson/index.php @@ -27,6 +27,9 @@ $strlessons = get_string("modulenameplural", "lesson"); $strlesson = get_string("modulename", "lesson"); + // RT #49973 20090709 Ray. See if the user has the ability to manage the page; + $context = get_context_instance(CONTEXT_COURSE, $id); + $manages = has_capability('mod/lesson:manage', $context); /// Print the header $navlinks = array(); @@ -49,6 +52,9 @@ $strname = get_string("name"); $strgrade = get_string("grade"); $strdeadline = get_string("deadline", "lesson"); + // RT # 49973 20090709 Ray. Get the strings to display if it is a student + $strattempts = get_string("attempts", "lesson"); + $strview = get_string("seereports", "lesson"); $strweek = get_string("week"); $strtopic = get_string("topic"); $strnodeadline = get_string("nodeadline", "lesson"); @@ -64,7 +70,12 @@ $table->head = array ($strname, $strgrade, $strdeadline); $table->align = array ("left", "center", "center"); } - + // RT #49973 20090709 Ray. If it is a student, add an extra column for view link + if (! $manages) { + $table->head[] = $strattempts; + $table->align[] = "center"; + } + foreach ($lessons as $lesson) { if (!$lesson->visible) { //Show dimmed if the mod is hidden @@ -75,7 +86,15 @@ } $cm = get_coursemodule_from_instance('lesson', $lesson->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); - + // RT #49973 20090709 Ray. if it is a student, create a link to the lesson + if (! $manages) { + if ($lesson->showattempts) { + $overview_url = "$CFG->wwwroot/mod/lesson/report.php?id=$lesson->coursemodule&action=reportoverview&userid=$USER->id"; + $overview = "".format_string($strview, true).""; + } else { + $overview = "-"; + } + } if ($lesson->deadline == 0) { $due = $strnodeadline; } else if ($lesson->deadline > $timenow) { @@ -94,9 +113,18 @@ $grade_value = $return[$USER->id]->rawgrade; } } - $table->data[] = array ($lesson->section, $link, $grade_value, $due); + // RT #49973 20090709 Ray. if it is a student, display a link to the lesson overview + if ($manages) { + $table->data[] = array ($lesson->section, $link, $grade_value, $due); + } else { + $table->data[] = array ($lesson->section, $link, $grade_value, $due, $overview); + } } else { - $table->data[] = array ($link, $lesson->grade, $due); + if ($manages) { + $table->data[] = array ($link, $lesson->grade, $due); + } else { + $table->data[] = array ($link, $lesson->grade, $due, $overview); + } } } diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 76b51d4..94d556c 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -226,12 +226,16 @@ if (!defined("LESSON_RESPONSE_EDITOR")) { function lesson_print_header($cm, $course, $lesson, $currenttab = '') { global $CFG, $USER; + $userid = optional_param('userid', NULL, PARAM_INT); + $strlesson = get_string('modulename', 'lesson'); $strname = format_string($lesson->name, true, $course->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); - if (has_capability('mod/lesson:edit', $context)) { + $isuser = ($userid && $userid == $USER->id); + + if (has_capability('mod/lesson:edit', $context) || $isuser) { $button = update_module_button($cm->id, $course->id, $strlesson); } else { $button = ''; @@ -246,7 +250,6 @@ function lesson_print_header($cm, $course, $lesson, $currenttab = '') { if (has_capability('mod/lesson:manage', $context)) { print_heading_with_help($strname, "overview", "lesson"); - if (!empty($currenttab)) { include($CFG->dirroot.'/mod/lesson/tabs.php'); } diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index a5c65b8..dc38a82 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -89,6 +89,11 @@ class mod_lesson_mod_form extends moodleform_mod { $mform->setHelpButton('ongoing', array('ongoing', get_string('ongoing', 'lesson'), 'lesson')); $mform->setDefault('ongoing', 0); + # RT 49973 20090713 Ray - Add preference to allow students to see their attempts + $mform->addElement('selectyesno', 'showattempts', get_string('showattempts', 'lesson')); + $mform->setDefault('showattempts', 0); + $mform->setHelpButton('showattempts', array('showattempts', get_string('showattempts', 'lesson'), 'lesson')); + //------------------------------------------------------------------------------- $mform->addElement('header', '', get_string('flowcontrol', 'lesson')); diff --git a/mod/lesson/report.php b/mod/lesson/report.php index a0f0803..5078655 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -11,9 +11,12 @@ require_once('lib.php'); require_once('locallib.php'); + global $USER; + $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID $action = optional_param('action', 'reportoverview', PARAM_ALPHA); // action to take + $userid = optional_param('userid', NULL, PARAM_INT); // RT #49973 $nothingtodisplay = false; list($cm, $course, $lesson) = lesson_get_basics($id); @@ -34,16 +37,22 @@ u.id = a.userid ORDER BY u.lastname"; } - + if (! $students = get_records_sql($sql)) { $nothingtodisplay = true; } - + // make sure people are where they should be require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); - require_capability('mod/lesson:manage', $context); - + + // RT #49973 20090706 Ray + if (($USER->id == $userid) && ($action == 'reportoverview' || $action == 'reportdetail') && ($lesson->showattempts)) { + $manages = has_capability('mod/lesson:manage', $context); + } else { + require_capability('mod/lesson:manage', $context); + $manages = true; + } /// Process any form data before fetching attempts, grades and times if (has_capability('mod/lesson:edit', $context) and $form = data_submitted($CFG->wwwroot.'/mod/lesson/report.php') and @@ -196,7 +205,9 @@ // going through each student that has attempted the lesson, so, each student should have something to be displayed foreach ($students as $student) { // check to see if the student has attempts to print out - if (array_key_exists($student->id, $studentdata)) { + //if (array_key_exists($student->id, $studentdata)) { + // RT #49973 20090706 Ray - Show the student's report OR show all students reports + if (array_key_exists($student->id, $studentdata) && ($manages || $student->id == $USER->id)) { // set/reset some variables $attempts = array(); // gather the data for each user attempt @@ -309,19 +320,22 @@ $lowscore = get_string("notcompleted", "lesson"); } - // output the stats - print_heading(get_string('lessonstats', 'lesson')); - $stattable = new stdClass; - $stattable->head = array(get_string('averagescore', 'lesson'), get_string('averagetime', 'lesson'), + if ($manages) { + + // output the stats + print_heading(get_string('lessonstats', 'lesson')); + $stattable = new stdClass; + $stattable->head = array(get_string('averagescore', 'lesson'), get_string('averagetime', 'lesson'), get_string('highscore', 'lesson'), get_string('lowscore', 'lesson'), get_string('hightime', 'lesson'), get_string('lowtime', 'lesson')); - $stattable->align = array("center", "center", "center", "center", "center", "center"); - $stattable->wrap = array("nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap"); - $stattable->width = "90%"; - $stattable->data[] = array($avescore.'%', $avetime, $highscore.'%', $lowscore.'%', $hightime, $lowtime); + $stattable->align = array("center", "center", "center", "center", "center", "center"); + $stattable->wrap = array("nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap"); + $stattable->width = "90%"; + $stattable->data[] = array($avescore.'%', $avetime, $highscore.'%', $lowscore.'%', $hightime, $lowtime); - print_table($stattable); -} + print_table($stattable); + } + } /************************************************************************** this action is for a student detailed view and for the general detailed view @@ -343,6 +357,10 @@ $userid = optional_param('userid', NULL, PARAM_INT); // if empty, then will display the general detailed view $try = optional_param('try', NULL, PARAM_INT); + if ($userid != $USER->id) { + require_capability('mod/lesson:manage', $context); + } + if (! $lessonpages = get_records("lesson_pages", "lessonid", $lesson->id)) { error("Could not find Lesson Pages"); } @@ -890,22 +908,39 @@ $fontend2 = ""; } - $table->head = array($fontstart2.$page->qtype.": ".format_string($page->title).$fontend2, $fontstart2.get_string("classstats", "lesson").$fontend2); - $table->data[] = array($fontstart.get_string("question", "lesson").":