diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php index eea7fac2a25..e5d4e8aa913 100644 --- a/mod/assign/renderer.php +++ b/mod/assign/renderer.php @@ -226,6 +226,8 @@ class mod_assign_renderer extends plugin_renderer_base { * @return string */ public function render_assign_header(assign_header $header) { + global $USER; + $o = ''; if ($header->subpage) { @@ -244,6 +246,14 @@ class mod_assign_renderer extends plugin_renderer_base { $o .= $this->output->header(); $o .= $this->output->heading($heading); + + // Show the activity information output component. + $modinfo = get_fast_modinfo($header->assign->course); + $cm = $modinfo->get_cm($header->coursemoduleid); + $cmcompletion = \core_completion\cm_completion_details::get_instance($cm, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); + $o .= $this->output->activity_information($cm, $cmcompletion, $activitydates); + if ($header->preface) { $o .= $header->preface; } diff --git a/mod/book/view.php b/mod/book/view.php index cf93731c2e3..fa0f762e900 100644 --- a/mod/book/view.php +++ b/mod/book/view.php @@ -208,6 +208,12 @@ book_view($book, $chapter, $islastchapter, $course, $cm, $context); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($book->name)); +// Render the activity information. +$cminfo = cm_info::create($cm); +$cmcompletion = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $cmcompletion, $activitydates); + // Info box. if ($book->intro) { echo $OUTPUT->box(format_module_intro('book', $book, $cm->id), 'generalbox', 'intro'); diff --git a/mod/chat/view.php b/mod/chat/view.php index 74ef55ce13e..6daf4d0b7ef 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -105,6 +105,12 @@ if ($currentgroup) { echo $OUTPUT->heading(format_string($chat->name), 2); +// Render the activity information. +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + if ($chat->intro) { echo $OUTPUT->box(format_module_intro('chat', $chat, $cm->id), 'generalbox', 'intro'); } diff --git a/mod/data/view.php b/mod/data/view.php index 9bce3e74cce..1e6aa3fe0be 100644 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -80,7 +80,7 @@ } $record = NULL; } - + $cm = cm_info::create($cm); require_course_login($course, true, $cm); require_once($CFG->dirroot . '/comment/lib.php'); @@ -268,6 +268,11 @@ echo $OUTPUT->heading(format_string($data->name), 2); + // Render the activity information. + $completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); + echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); + // Do we need to show a link to the RSS feed for the records? //this links has been Settings (database activity administration) block /*if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) { diff --git a/mod/feedback/view.php b/mod/feedback/view.php index fe2ef8b6dba..a8e10192c18 100644 --- a/mod/feedback/view.php +++ b/mod/feedback/view.php @@ -78,6 +78,11 @@ $preview = html_writer::link($previewlnk, $previewimg); echo $OUTPUT->heading(format_string($feedback->name) . $preview); +// Render the activity information. +$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); +echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); + // Print the tabs. require('tabs.php'); diff --git a/mod/folder/view.php b/mod/folder/view.php index afdbcfafc49..82335c45aa3 100644 --- a/mod/folder/view.php +++ b/mod/folder/view.php @@ -76,6 +76,12 @@ echo $output->header(); echo $output->heading(format_string($folder->name), 2); +// Render the activity information. +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $output->activity_information($cminfo, $completiondetails, $activitydates); + echo $output->display_folder($folder); echo $output->footer(); diff --git a/mod/forum/view.php b/mod/forum/view.php index d6828232130..e50a25a9161 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -156,6 +156,11 @@ if (!empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds) && $forum echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($forum->get_name()), 2); +// Render the activity information. +$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); +echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); + if (!$istypesingle && !empty($forum->get_intro())) { echo $OUTPUT->box(format_module_intro('forum', $forumrecord, $cm->id), 'generalbox', 'intro'); } diff --git a/mod/glossary/view.php b/mod/glossary/view.php index adadafe2c0a..c363643f8a4 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -46,6 +46,7 @@ if (!empty($id)) { } else { print_error('invalidid', 'glossary'); } +$cm = cm_info::create($cm); require_course_login($course->id, true, $cm); $context = context_module::instance($cm->id); @@ -298,6 +299,11 @@ if ($tab == GLOSSARY_APPROVAL_VIEW) { } echo $OUTPUT->heading(format_string($glossary->name), 2); +// Render the activity information. +$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); +echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); + /// All this depends if whe have $showcommonelements if ($showcommonelements) { /// To calculate available options diff --git a/mod/h5pactivity/view.php b/mod/h5pactivity/view.php index d79308b6d00..549d3f59351 100644 --- a/mod/h5pactivity/view.php +++ b/mod/h5pactivity/view.php @@ -70,6 +70,11 @@ $PAGE->set_context($context); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($moduleinstance->name)); +// Render the activity information. +$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); +echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); + $instance = $manager->get_instance(); if (!empty($instance->intro)) { echo $OUTPUT->box(format_module_intro('h5pactivity', $instance, $cm->id), 'generalbox', 'intro'); diff --git a/mod/imscp/view.php b/mod/imscp/view.php index 87aefe63adc..fbffca914ad 100644 --- a/mod/imscp/view.php +++ b/mod/imscp/view.php @@ -70,6 +70,13 @@ if (!$imscp->structure) { echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($imscp->name)); + +// Render the activity information. +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + // Info box. if ($imscp->intro) { echo $OUTPUT->box(format_module_intro('imscp', $imscp, $cm->id), 'generalbox', 'intro'); diff --git a/mod/lesson/renderer.php b/mod/lesson/renderer.php index 10066f9b8c4..90309a0943c 100644 --- a/mod/lesson/renderer.php +++ b/mod/lesson/renderer.php @@ -37,7 +37,7 @@ class mod_lesson_renderer extends plugin_renderer_base { * @return string */ public function header($lesson, $cm, $currenttab = '', $extraeditbuttons = false, $lessonpageid = null, $extrapagetitle = null) { - global $CFG; + global $CFG, $USER; $activityname = format_string($lesson->name, true, $lesson->course); if (empty($extrapagetitle)) { @@ -55,8 +55,13 @@ class mod_lesson_renderer extends plugin_renderer_base { lesson_add_header_buttons($cm, $context, $extraeditbuttons, $lessonpageid); $output = $this->output->header(); + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); if (has_capability('mod/lesson:manage', $context)) { $output .= $this->output->heading_with_help($activityname, 'overview', 'lesson'); + $output .= $this->output->activity_information($cminfo, $completiondetails, $activitydates); + // Info box. if ($lesson->intro) { $output .= $this->output->box(format_module_intro('lesson', $lesson, $cm->id), 'generalbox', 'intro'); @@ -69,6 +74,8 @@ class mod_lesson_renderer extends plugin_renderer_base { } } else { $output .= $this->output->heading($activityname); + $output .= $this->output->activity_information($cminfo, $completiondetails, $activitydates); + // Info box. if ($lesson->intro) { $output .= $this->output->box(format_module_intro('lesson', $lesson, $cm->id), 'generalbox', 'intro'); diff --git a/mod/lti/tests/behat/lti_activity_completion.feature b/mod/lti/tests/behat/lti_activity_completion.feature new file mode 100644 index 00000000000..c689be1524e --- /dev/null +++ b/mod/lti/tests/behat/lti_activity_completion.feature @@ -0,0 +1,81 @@ +@mod @mod_lti @core_completion +Feature: View activity completion information in the LTI activity + In order to have visibility of LTI completion requirements + As a student + I need to be able to view my LTI completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I turn editing mode on + And I add a "External tool" to section "1" and I fill the form with: + | Activity name | Music history | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | 1 | + And I log out + + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "Receive a grade" completion condition + And "Music history" should have the "View" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "View > Grader report" in the course gradebook + And I turn editing mode on + And I give the grade "90.00" to the user "Vinnie Student1" for the grade item "Music history" + And I press "Save changes" + And I log out + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "Receive a grade" completion condition of "Music history" is displayed as "done" + And the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view. + And I follow "Music history" + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" diff --git a/mod/lti/view.php b/mod/lti/view.php index 5775363c78f..adac5fe75f9 100644 --- a/mod/lti/view.php +++ b/mod/lti/view.php @@ -114,6 +114,12 @@ if ($lti->showtitlelaunch) { echo $OUTPUT->heading(format_string($lti->name, true, array('context' => $context))); } +// Display any activity information (eg completion requirements / dates). +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + if ($lti->showdescriptionlaunch && $lti->intro) { echo $OUTPUT->box(format_module_intro('lti', $lti, $cm->id), 'generalbox description', 'intro'); } diff --git a/mod/page/tests/behat/page_activity_completion.feature b/mod/page/tests/behat/page_activity_completion.feature new file mode 100644 index 00000000000..7fbc179d647 --- /dev/null +++ b/mod/page/tests/behat/page_activity_completion.feature @@ -0,0 +1,62 @@ +@mod @mod_page @core_completion +Feature: View activity completion information in the Page resource + In order to have visibility of page completion requirements + As a student + I need to be able to view my page completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + + Scenario: View automatic completion items + Given I am on "Course 1" course homepage with editing mode on + And I add a "Page" to section "1" and I fill the form with: + | Name | Music history | + | Page content | A lesson learned in life | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I am on "Course 1" course homepage with editing mode on + And I add a "Page" to section "1" and I fill the form with: + | Name | Music history | + | Page content | A lesson learned in life | + | Completion tracking | Students can manually mark the activity as completed | + # Teacher view. + And I follow "Music history" + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" diff --git a/mod/page/view.php b/mod/page/view.php index 4297a7fb7f0..1eefd2276e0 100644 --- a/mod/page/view.php +++ b/mod/page/view.php @@ -72,6 +72,12 @@ if (!isset($options['printheading']) || !empty($options['printheading'])) { echo $OUTPUT->heading(format_string($page->name), 2); } +// Display any activity information (eg completion requirements / dates). +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + if (!empty($options['printintro'])) { if (trim(strip_tags($page->intro))) { echo $OUTPUT->box_start('mod_introbox', 'pageintro'); diff --git a/mod/quiz/renderer.php b/mod/quiz/renderer.php index ac87ca207ab..a7ec9b4c683 100644 --- a/mod/quiz/renderer.php +++ b/mod/quiz/renderer.php @@ -936,12 +936,20 @@ class mod_quiz_renderer extends plugin_renderer_base { * @return string HTML to output. */ public function view_information($quiz, $cm, $context, $messages) { - global $CFG; + global $USER; $output = ''; - // Print quiz name and description. + // Print quiz name. $output .= $this->heading(format_string($quiz->name)); + + // Print any activity information (eg completion requirements / dates). + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + $output .= $this->output->activity_information($cminfo, $completiondetails, $activitydates); + + // Print quiz description. $output .= $this->quiz_intro($quiz, $cm); // Output any access messages. diff --git a/mod/resource/locallib.php b/mod/resource/locallib.php index 40ab0ce93d9..7765917e576 100644 --- a/mod/resource/locallib.php +++ b/mod/resource/locallib.php @@ -61,7 +61,7 @@ function resource_redirect_if_migrated($oldid, $cmid) { * @return does not return */ function resource_display_embed($resource, $cm, $course, $file) { - global $CFG, $PAGE, $OUTPUT; + global $PAGE, $OUTPUT, $USER; $clicktoopen = resource_get_clicktoopen($file, $resource->revision); @@ -102,6 +102,12 @@ function resource_display_embed($resource, $cm, $course, $file) { resource_print_header($resource, $cm, $course); resource_print_heading($resource, $cm, $course); + // Display any activity information (eg completion requirements / dates). + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $code; resource_print_intro($resource, $cm, $course); @@ -202,10 +208,16 @@ function resource_get_clicktodownload($file, $revision) { * @return does not return */ function resource_print_workaround($resource, $cm, $course, $file) { - global $CFG, $OUTPUT; - + global $CFG, $OUTPUT, $USER; resource_print_header($resource, $cm, $course); resource_print_heading($resource, $cm, $course, true); + + // Display any activity information (eg completion requirements / dates). + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + resource_print_intro($resource, $cm, $course, true); $resource->mainfile = $file->get_filename(); diff --git a/mod/scorm/view.php b/mod/scorm/view.php index 9cdbf764165..b96893fa355 100644 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -139,6 +139,12 @@ $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($scorm->name)); +// Display any activity information (eg completion requirements / dates). +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) { if ($action == 'delete') { $confirmurl = new moodle_url($PAGE->url, array('action' => 'deleteconfirm')); diff --git a/mod/survey/view.php b/mod/survey/view.php index 97a528357c6..837b1ea96f4 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -31,6 +31,8 @@ if (! $cm = get_coursemodule_from_id('survey', $id)) { print_error('invalidcoursemodule'); } +$cm = cm_info::create($cm); + if (! $course = $DB->get_record("course", array("id" => $cm->course))) { print_error('coursemisconf'); } @@ -71,6 +73,11 @@ $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($survey->name)); +// Render the activity information. +$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); +echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); + // Check to see if groups are being used in this survey. if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used. $currentgroup = groups_get_activity_group($cm); diff --git a/mod/url/locallib.php b/mod/url/locallib.php index eb467b91091..8ca4fd26c15 100644 --- a/mod/url/locallib.php +++ b/mod/url/locallib.php @@ -266,10 +266,17 @@ EOF; * @return does not return */ function url_print_workaround($url, $cm, $course) { - global $OUTPUT; + global $OUTPUT, $USER; url_print_header($url, $cm, $course); url_print_heading($url, $cm, $course, true); + + // Display any activity information (eg completion requirements / dates). + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + url_print_intro($url, $cm, $course, true); $fullurl = url_get_full_url($url, $cm, $course); @@ -306,7 +313,7 @@ function url_print_workaround($url, $cm, $course) { * @return does not return */ function url_display_embed($url, $cm, $course) { - global $CFG, $PAGE, $OUTPUT; + global $PAGE, $OUTPUT, $USER; $mimetype = resourcelib_guess_url_mimetype($url->externalurl); $fullurl = url_get_full_url($url, $cm, $course); @@ -339,6 +346,12 @@ function url_display_embed($url, $cm, $course) { url_print_header($url, $cm, $course); url_print_heading($url, $cm, $course); + // Display any activity information (eg completion requirements / dates). + $cminfo = cm_info::create($cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates); + echo $code; url_print_intro($url, $cm, $course); diff --git a/mod/url/tests/behat/url_activity_completion.feature b/mod/url/tests/behat/url_activity_completion.feature new file mode 100644 index 00000000000..79a33ae64fc --- /dev/null +++ b/mod/url/tests/behat/url_activity_completion.feature @@ -0,0 +1,118 @@ +@mod @mod_url @core_completion +Feature: View activity completion information in the URL resource + In order to have visibility of URL completion requirements + As a student + I need to be able to view my URL completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + + Scenario: View automatic completion items in automatic display mode + Given I am on "Course 1" course homepage with editing mode on + And I add a "URL" to section "1" and I fill the form with: + | Name | Music history | + | External URL | https://moodle.org/ | + | Display | Automatic | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + Scenario: View automatic completion items in embed display mode + Given I am on "Course 1" course homepage with editing mode on + And I add a "URL" to section "1" and I fill the form with: + | Name | Music history | + | External URL | https://moodle.org/ | + | Display | Embed | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + Scenario: View automatic completion items in open display mode + Given I am on "Course 1" course homepage with editing mode on + And I add a "URL" to section "1" and I fill the form with: + | Name | Music history | + | External URL | https://moodle.org/ | + | Display | Open | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + Scenario: View automatic completion items in pop-up display mode + Given I am on "Course 1" course homepage with editing mode on + And I add a "URL" to section "1" and I fill the form with: + | Name | Music history | + | External URL | https://moodle.org/ | + | Display | In pop-up | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + # Teacher view. + And I follow "Music history" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I am on "Course 1" course homepage with editing mode on + And I add a "URL" to section "1" and I fill the form with: + | Name | Music history | + | External URL | https://moodle.org/ | + | Display | Automatic | + | Completion tracking | Students can manually mark the activity as completed | + # Teacher view. + And I follow "Music history" + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" diff --git a/mod/wiki/renderer.php b/mod/wiki/renderer.php index 42d6c5179dd..3f40fe7745d 100644 --- a/mod/wiki/renderer.php +++ b/mod/wiki/renderer.php @@ -235,8 +235,19 @@ class mod_wiki_renderer extends plugin_renderer_base { return $output; } public function wiki_info() { - return $this->output->box(format_module_intro('wiki', + global $USER; + + // Display any activity information (eg completion requirements / dates). + $cminfo = cm_info::create($this->page->cm); + $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); + $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); + $info = $this->output->activity_information($cminfo, $completiondetails, $activitydates); + + // Add the rest of the wiki info. + $info .= $this->output->box(format_module_intro('wiki', $this->page->activityrecord, $this->page->cm->id), 'generalbox', 'intro'); + + return $info; } public function tabs($page, $tabitems, $options) { diff --git a/mod/wiki/tests/behat/wiki_activity_completion.feature b/mod/wiki/tests/behat/wiki_activity_completion.feature new file mode 100644 index 00000000000..43176b05e6c --- /dev/null +++ b/mod/wiki/tests/behat/wiki_activity_completion.feature @@ -0,0 +1,64 @@ +@mod @mod_url @core_completion +Feature: View activity completion information in the Wiki activity + In order to have visibility of URL completion requirements + As a student + I need to be able to view my URL completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + + Scenario: View automatic completion items + Given I am on "Course 1" course homepage with editing mode on + And I add a "Wiki" to section "1" and I fill the form with: + | Wiki name | Music history | + | First page name | Respect | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + # Teacher view. + And I follow "Music history" + And I click on "Create page" "button" + And "Music history" should have the "View" completion condition + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I am on "Course 1" course homepage with editing mode on + And I add a "Wiki" to section "1" and I fill the form with: + | Wiki name | Music history | + | First page name | Respect | + | Completion tracking | Students can manually mark the activity as completed | + # Teacher view. + And I follow "Music history" + And I click on "Create page" "button" + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" diff --git a/mod/workshop/tests/behat/workshop_activity_completion.feature b/mod/workshop/tests/behat/workshop_activity_completion.feature new file mode 100644 index 00000000000..8ed6e7a5f62 --- /dev/null +++ b/mod/workshop/tests/behat/workshop_activity_completion.feature @@ -0,0 +1,107 @@ +@mod @mod_workshop @core_completion +Feature: View activity completion information in the Workshop activity + In order to have visibility of lesson completion requirements + As a student + I need to be able to view my lesson completion progress + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | student2 | Rex | Student2 | student2@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student2 | C1 | student | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the following fields to these values: + | Enable completion tracking | Yes | + | Show completion conditions | Yes | + And I press "Save and display" + And I turn editing mode on + And I add a "Workshop" to section "1" and I fill the form with: + | Workshop name | Music history | + | Completion tracking | Show activity as complete when conditions are met | + | Require view | 1 | + | Require grade | Submission | + And I edit assessment form in workshop "Music history" as:" + | id_description__idx_0_editor | Aspect1 | + And I change phase in workshop "Music history" to "Submission phase" + And I log out + + Scenario: View automatic completion items as a teacher + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I follow "Music history" + Then "Music history" should have the "Receive a grade" completion condition + And "Music history" should have the "View" completion condition + + Scenario: View automatic completion items as a student + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + And the "View" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "todo" + # Add a submission. + And I press "Add submission" + And I set the field "Title" to "Pinch harmonics" + And I set the field "Submission content" to "Satisfying to play" + And I press "Save changes" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I change phase in workshop "Music history" to "Assessment phase" + And I allocate submissions in workshop "Music history" as:" + | Participant | Reviewer | + | Vinnie Student1 | Rex Student2 | + And I log out + # Assess the submission. + And I log in as "student2" + And I am on "Course 1" course homepage + And I follow "Music history" + And I assess submission "Pinch harmonics" in workshop "Music history" as:" + | grade__idx_0 | 9 / 10 | + | peercomment__idx_0 | Well done | + And I log out + # Evaluate and close the workshop so a grade is recorded for the student. + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I change phase in workshop "Music history" to "Grading evaluation phase" + And I follow "Music history" + And I click on "Re-calculate grades" "button" + And I change phase in workshop "Music history" to "Closed" + And I log out + # Confirm completion condition is updated. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the "View" completion condition of "Music history" is displayed as "done" + And the "Receive a grade" completion condition of "Music history" is displayed as "done" + + @javascript + Scenario: Use manual completion + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Music history" + And I navigate to "Edit settings" in current page administration + And I expand all fieldsets + And I set the field "Completion tracking" to "Students can manually mark the activity as completed" + And I press "Save and display" + # Teacher view + And the manual completion button for "Music history" should be disabled + And I log out + # Student view. + When I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Music history" + Then the manual completion button of "Music history" is displayed as "Mark as done" + And I toggle the manual completion state of "Music history" + And the manual completion button of "Music history" is displayed as "Done" diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 78b464dadfe..8cfb1150206 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -103,6 +103,13 @@ $output = $PAGE->get_renderer('mod_workshop'); echo $output->header(); echo $output->heading_with_help(format_string($workshop->name), 'userplan', 'workshop'); + +// Display any activity information (eg completion requirements / dates). +$cminfo = cm_info::create($cm); +$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); +$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); +echo $output->activity_information($cminfo, $completiondetails, $activitydates); + echo $output->heading(format_string($currentphasetitle), 3, null, 'mod_workshop-userplanheading'); echo $output->render($userplan);