From fbf85b8d767ad5efb5ee30f5cabcc681866ee2b1 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Thu, 31 Dec 2015 11:46:50 -0500 Subject: [PATCH 1/2] MDL-50915 Lesson: Fix information on outline report --- mod/lesson/lib.php | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index bc87c9eb4b9..4c6d84cdf1e 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -302,25 +302,48 @@ function lesson_delete_course($course, $feedback=true) { * @return object */ function lesson_user_outline($course, $user, $mod, $lesson) { - global $CFG; + global $CFG, $DB; require_once("$CFG->libdir/gradelib.php"); $grades = grade_get_grades($course->id, 'mod', 'lesson', $lesson->id, $user->id); - $return = new stdClass(); + if (empty($grades->items[0]->grades)) { - $return->info = get_string("no")." ".get_string("attempts", "lesson"); + $return->info = get_string("nolessonattempts", "lesson"); } else { $grade = reset($grades->items[0]->grades); - $return->info = get_string("grade") . ': ' . $grade->str_long_grade; + if (empty($grade->grade)) { - //datesubmitted == time created. dategraded == time modified or time overridden - //if grade was last modified by the user themselves use date graded. Otherwise use date submitted - //TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704 - if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) { - $return->time = $grade->dategraded; + // Check to see if it an ungraded / incomplete attempt. + $sql = "SELECT * + FROM {lesson_timer} + WHERE lessonid = :lessonid + AND userid = :userid + ORDER BY starttime DESC"; + $params = array('lessonid' => $lesson->id, 'userid' => $user->id); + + if ($attempts = $DB->get_records_sql($sql, $params, 0, 1)) { + $attempt = reset($attempts); + if ($attempt->completed) { + $return->info = get_string("completed", "lesson"); + } else { + $return->info = get_string("notyetcompleted", "lesson"); + } + $return->time = $attempt->lessontime; + } else { + $return->info = get_string("nolessonattempts", "lesson"); + } } else { - $return->time = $grade->datesubmitted; + $return->info = get_string("grade") . ': ' . $grade->str_long_grade; + + // Datesubmitted == time created. dategraded == time modified or time overridden. + // If grade was last modified by the user themselves use date graded. Otherwise use date submitted. + // TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704. + if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) { + $return->time = $grade->dategraded; + } else { + $return->time = $grade->datesubmitted; + } } } return $return; From afd5408eda75873c31512b38d58d1465ba8812b8 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Mon, 4 Jan 2016 12:05:17 -0500 Subject: [PATCH 2/2] MDL-50915 Lesson: Behat test for overview report --- .../tests/behat/lesson_outline_report.feature | 187 ++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 mod/lesson/tests/behat/lesson_outline_report.feature diff --git a/mod/lesson/tests/behat/lesson_outline_report.feature b/mod/lesson/tests/behat/lesson_outline_report.feature new file mode 100644 index 00000000000..3189fa19736 --- /dev/null +++ b/mod/lesson/tests/behat/lesson_outline_report.feature @@ -0,0 +1,187 @@ +@mod @mod_lesson +Feature: Teachers can review student progress on all lessons in a course by viewing the overview report + As a Teacher + I need to view the overview report for one of my students. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | student1 | Student | 1 | student1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "Lesson" to section "1" + And I set the following fields to these values: + | Name | Test lesson name | + | Description | Test lesson description | + | Re-takes allowed | Yes | + And I press "Save and return to course" + And I follow "Test lesson name" + + @javascript + Scenario: View student progress for lesson that was never attempted + Given I follow "Add a content page" + And I set the following fields to these values: + | Page title | First page name | + | Page contents | First page contents | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 1 | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + When I follow "Course 1" + And I follow "Participants" + And I follow "Student 1" + And I follow "Outline report" + Then I should see "No attempts have been made on this lesson" + + @javascript + Scenario: View student progress for an incomplete lesson containing both content and question pages + Given I follow "Add a content page" + And I set the following fields to these values: + | Page title | First page name | + | Page contents | First page contents | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 1 | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Second page name | + | Page contents | Second page contents | + | id_answer_editor_0 | Previous page | + | id_jumpto_0 | Previous page | + | id_answer_editor_1 | Next page | + | id_jumpto_1 | Next page | + And I press "Save page" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "First page contents" + And I press "Next page" + And I log out + Then I log in as "teacher1" + And I follow "Course 1" + And I follow "Participants" + And I follow "Student 1" + And I follow "Outline report" + And I should see "Lesson has been started, but not yet completed" + + @javascript + Scenario: View student progress for a lesson containing both content and question pages + Given I follow "Add a content page" + And I set the following fields to these values: + | Page title | First page name | + | Page contents | First page contents | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 1 | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Second page name | + | Page contents | Second page contents | + | id_answer_editor_0 | Previous page | + | id_jumpto_0 | Previous page | + | id_answer_editor_1 | Next page | + | id_jumpto_1 | Next page | + And I press "Save page" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "First page contents" + And I press "Next page" + And I should see "Second page contents" + And I press "Next page" + And I should see "Paper is made from trees." + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Congratulations - end of lesson reached" + And I log out + Then I log in as "teacher1" + And I follow "Course 1" + And I follow "Participants" + And I follow "Student 1" + And I follow "Outline report" + And I should see "Grade: 100.00 / 100.00" + + @javascript + Scenario: View student attempts in a lesson containing only content pages + Given I follow "Add a content page" + And I set the following fields to these values: + | Page title | First page name | + | Page contents | First page contents | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Second page name | + | Page contents | Second page contents | + | id_answer_editor_0 | Previous page | + | id_jumpto_0 | Previous page | + | id_answer_editor_1 | End of lesson | + | id_jumpto_1 | End of lesson | + And I press "Save page" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "First page contents" + And I press "Next page" + And I should see "Second page contents" + And I press "End of lesson" + And I log out + Then I log in as "teacher1" + And I follow "Course 1" + And I follow "Participants" + And I follow "Student 1" + And I follow "Outline report" + And I should see "Completed"