From 33ce9e581a34d56e6217e511a906cd91b314734f Mon Sep 17 00:00:00 2001 From: Atanas Atanasov Date: Wed, 17 Dec 2014 12:21:03 +0000 Subject: [PATCH 1/3] MDL-20304 lesson: do not send practice lesson grades to gradebook --- mod/lesson/lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index 7bab80f8d5c..d5055ccf7dd 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -430,11 +430,11 @@ function lesson_grade_item_update($lesson, $grades=null) { $params = array('itemname'=>$lesson->name); } - if ($lesson->grade > 0) { + if (!$lesson->practice and $lesson->grade > 0) { $params['gradetype'] = GRADE_TYPE_VALUE; $params['grademax'] = $lesson->grade; $params['grademin'] = 0; - } else if ($lesson->grade < 0) { + } else if (!$lesson->practice and $lesson->grade < 0) { $params['gradetype'] = GRADE_TYPE_SCALE; $params['scaleid'] = -$lesson->grade; From 9bb712a047cc3ef8dffd654aa62731b92666ec73 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 17 Dec 2014 12:40:29 +0000 Subject: [PATCH 2/3] MDL-20304 lesson: do not display gradebook link when in practice mode Practice mode means the grades do not go to the gradebook, so do not display the gradebook link at the end of the lesson --- mod/lesson/view.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 4b6824a6f5c..626e1d7ef37 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -579,8 +579,11 @@ if ($pageid != LESSON_EOL) { $url = new moodle_url('/course/view.php', array('id'=>$course->id)); $lessoncontent .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)), array('class'=>'centerpadded lessonbutton standardbutton')); - $url = new moodle_url('/grade/index.php', array('id'=>$course->id)); - $lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton')); + if (!$lesson->practice) { + $url = new moodle_url('/grade/index.php', array('id' => $course->id)); + $lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'), + array('class' => 'centerpadded lessonbutton standardbutton')); + } lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer); echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid, get_string("congratulations", "lesson")); From 3f6d5ea6214ed1d9983e4073df3cc1a337753561 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 17 Dec 2014 13:34:47 +0000 Subject: [PATCH 3/3] MDL-20304 lesson: add behat test for practice lessons --- .../tests/behat/lesson_practice.feature | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 mod/lesson/tests/behat/lesson_practice.feature diff --git a/mod/lesson/tests/behat/lesson_practice.feature b/mod/lesson/tests/behat/lesson_practice.feature new file mode 100644 index 00000000000..9b077fb23fe --- /dev/null +++ b/mod/lesson/tests/behat/lesson_practice.feature @@ -0,0 +1,97 @@ +@mod @mod_lesson +Feature: Practice mode in a lesson activity + In order to improve my students understanding of a subject + As a teacher + I need to be able to set ungraded practice lesson activites + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + | student1 | Student | 1 | student1@asd.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 + # Setup a basic lesson, we'll adjust it in the scenarios later. + And I add a "Lesson" to section "1" and I fill the form with: + | Name | Test lesson name | + | Description | Lesson description | + And I follow "Test lesson name" + And I follow "Add a question page" + 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 or False | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_answer_editor_1 | False | + And I press "Save page" + + @javascript + Scenario: Non-practice lesson records grades in the gradebook + Given I follow "Test lesson name" + And I navigate to "Edit settings" node in "Lesson administration" + And I set the following fields to these values: + | Name | Non-practice lesson | + | Description | This lesson will affect your course grade | + | Practice lesson | No | + And I press "Save and display" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Non-practice lesson" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + Then I should see "View grades" + And I navigate to "Grades" node in "Course administration" + And I should see "Non-practice lesson" + + @javascript + Scenario: Practice lesson doesn't record grades in the gradebook + Given I follow "Test lesson name" + And I navigate to "Edit settings" node in "Lesson administration" + And I set the following fields to these values: + | Name | Practice lesson | + | Description | This lesson will NOT affect your course grade | + | Practice lesson | Yes | + And I press "Save and display" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Practice lesson" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + Then I should not see "View grades" + And I navigate to "Grades" node in "Course administration" + And I should not see "Practice lesson" + + # TODO: uncomment this when MDL-48631 is resolved. + #@javascript + #Scenario: Practice lesson with scale doesn't record grades in the gradebook + # Given I follow "Test lesson name" + # And I navigate to "Edit settings" node in "Lesson administration" + # And I set the following fields to these values: + # | Name | Practice lesson with scale | + # | Description | This lesson will NOT affect your course grade | + # | Practice lesson | Yes | + # | Type | Scale | + # And I press "Save and display" + # And I log out + # When I log in as "student1" + # And I follow "Course 1" + # And I follow "Practice lesson with scale" + # And I set the following fields to these values: + # | True | 1 | + # And I press "Submit" + # Then I should not see "View grades" + # And I navigate to "Grades" node in "Course administration" + # And I should not see "Practice lesson with scale"