Student activity completion

From MoodleDocs
Improving the student activity completion experience
Project state In progress
Tracker issue MDL-70469 (epic)
Discussion Student activity completion in Moodle 3.11
Assignee Team International Legends

Moodle 3.11

Introduction

For Moodle 3.11 the MUA voted for a project aligned with Moodle's planned UX/UI improvements. Most of the improvements will be released with Moodle 4.0, which is scheduled for November 2021. In collaboration with the MUA, it was agreed there is an opportunity to deliver some UX/UI improvements already for Moodle 3.11.

As a result, the MUA project for Moodle 3.11 will focus on improving the student course experience. In particular, we will focus on making it more obvious to the student what the requirements are to complete each activity, and in doing so making it more obvious what the requirements are to complete the course.

Prototype / mock-ups

The course page

The course page will be enhanced to enable the display of important activity dates and activity completion requirements. The dates will be displayed immediately underneath the activity title. For manual completion, there will be a button as a call to action for the student and for automatic completion the requirements will be displayed in pills.

Course page with example of manual activity completion Course page with example of automatic activity completion

The activity page

The important activity dates and completion requirements will also be displayed when you are inside an activity.

Activity page with an example of activity dates and automatic completion requirements

Course appearance settings

Whether or not the activity dates and completion requirements are displayed within a course and within the activities can be enabled and disabled for each course.

Course appearance settings to enable or disable the display of activity dates and completion requirements

Admin settings

Additionally, there will be a global administrator setting to set the default value for the course settings for displaying activity dates and completion requirements.

Demo site

You are welcome to try things out as a teacher or student on the Student activity completion demo site and share your feedback in the discussion Student activity completion in Moodle 3.11 or in MDL-70469.

User stories

These are the user stories that this project aims to address.

For the student

Student user stories Acceptance criteria / confirmation
As a student

I want to be able to quickly see on the course page which activities I need to complete so that I know where to focus my attention next

When I am on the course page I should be able to see the requirements for completing an activity with automatic completion.

When I am on the course page I should be able to manually complete an activity with manual completion.

As a student

I want to be able to complete an activity from inside the activity so that I don’t need to navigate back to the course page to do so

When I am on the activity with manual completion’s landing page (e.g. view.php), I should be able to mark the activity as completed in its landing page.
As a student

I want to be able to clearly see the requirements for an activity with automatic activity completion so that I understand what I need to do to complete it

When I am on the activity with automatic completion’s landing page (e.g. view.php), I should be able to see the requirements for completing the activity.
As a student

I want to be able to clearly see the activity dates that are relevant to me so that I can easily plan my schedule in advance

When I am on the course page, I should be able to see the activity dates that are relevant to me

When I am on the landing page (e.g. view.php) of an activity with dates (e.g. due dates, etc.), I should be able to see these activity dates that are relevant to me.

Note: Activity dates relevant to the user cover the following scenarios:

  • If there are no overrides applicable to the student, then activity's dates (e.g. assignment submission-open date, due date, etc.) should be displayed normally.
  • If there are group overrides applied to the activity dates, then a student belonging to a group with group overrides should see the overridden date(s) for the student's applicable group.
  • If there is a user override for a student has been applied to the activity dates, then the student should see the overridden dates.
  • User override dates take precedence over group override dates. A student belonging to a group with group overrides for the activity dates and user overrides should see the user overrides instead.

Bottom line is that the activity dates that the students see on their course homepage/activity view page should be consistent with the relevant activity dates that they see on their calendar/timeline.

For the course creator / teacher

Course creator / teacher user stories Acceptance criteria / confirmation
As a course creator/editing teacher

I want to be able to configure the course to show completion requirements so that I can decide if I want the completion requirements to be shown

  1. When I am at a course’s settings page, then I should see a setting that I can use to specify if I want the completion requirements to be shown in the course or not.
  2. Given completion requirements are set to be shown, when I go to a course's homepage, then I should see the completion requirements for the activities with automatic completion requirements.
  3. Given completion requirements are not set to be shown, when I go to a course's homepage, then I should not see the completion requirements for the activities with automatic completion requirements.
  4. Given completion requirements are set to be shown, when I view an activity with automatic completion requirements, then I should see the activity's completion requirements.
  5. Given completion requirements are not set to be shown, when I view an activity with automatic completion requirements, then I should not see the activity's completion requirements.
As a course creator/editing teacher

I want to be able to configure the course to show activity dates so that I can decide if I want the activity dates to be shown

  1. When I am at a course’s settings page, then I should see a setting that I can use to specify if I want the activity dates to be shown in the course or not.
  2. Given activity dates are set to be shown, when I go to a course's homepage, then I should see the dates for the activities in the course.
  3. Given activity dates are not set to be shown, when I go to a course's homepage, then I should not see the dates for the activities in the course.
  4. Given activity dates are set to be shown, when I view an activity with dates set, then those dates should be displayed on the activity's view page.
  5. Given activity dates are not set to be shown, when I view an activity with dates set, then those dates should not be displayed on the activity's view page.

For the administrator

Administrator user stories Acceptance criteria / confirmation
As a site administrator

I want to be able to set the default value for displaying activity completion requirements in the course settings form

So that course creators or editing teachers won't have to set its value in each course on course creation

  1. When I am at the course default settings page, I should see a setting that I can use to set the default value for displaying the automatic completion requirements in the course settings form
  2. This admin setting should be set to "Yes" by default
  3. When I am creating a course with automatic completion, then the default value for the "Show completion conditions" course setting field should match the selected site default.
As a site administrator

I want to be able to set the default value for displaying activity dates in the course settings form

So that course creators or editing teachers won't have to set its value in each course on course creation

  1. When I am at the course default settings page, I should see a setting that I can use to set the default value for displaying activity dates in the course settings form
  2. This admin setting should be set to "Yes" by default.
  3. When I am creating a course with automatic completion, then the default value for the "Show activity dates" course setting field should match the selected site default.

Plugin implementation

Custom activity completion

We have developed a base class for activities that define custom completion rules: \core_completion\activity_custom_completion.

Activity plugins that define custom completion rules must implement a

mod_[modname]\completion\custom_completion

subclass and the following methods:

get_defined_custom_rules()

This is where the plugin's custom completion rules are defined. It basically returns an array of the activity module's custom completion rules.

/**
 * Fetch the list of custom completion rules that this module defines.
 *
 * @return array
 */
public static function get_defined_custom_rules(): array {
    return [
        'completionsubmit'
    ];
}

get_state()

This provides the completion state for a given custom completion condition.

/**
 * Fetches the completion state for a given completion rule.
 *
 * @param string $rule The completion rule.
 * @return int The completion state.
 */
public function get_state(string $rule): int {
    global $DB;
    // Make sure to validate the custom completion rule first.
    $this->validate_rule($rule);

    // Fetch the completion status of the custom completion rule.
    $status = COMPLETION_INCOMPLETE;
    if ($rule === 'completionsubmit') {
        $hassubmission = $DB->record_exists('choice_answers', ['choiceid' => $this->cm->instance, 'userid' => $this->userid]);            
        $status = $hassubmission ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
    }

    return $status;
}


If your plugin defines custom completion rules, then most likely your plugin implements the

*_get_completion_state()

callback. These callbacks will be deprecated soon in MDL-71144. It will still work in the meantime, but your plugin will not be able to display the individual completion state of your custom completion rules.

get_custom_rule_descriptions()

Returns an associative array with values containing the user-facing textual description of the custom completion rules (which serve as the keys to these values).

/**
 * Returns an associative array of the descriptions of custom completion rules.
 *
 * @return array
 */
public function get_custom_rule_descriptions(): array {
    return [
        'completionsubmit' => get_string('completiondetail:submit', 'choice')
    ];
}

get_sort_order()

Returns an array with values containing all of the completion rules applicable to the activity, in the order they should be presented to the user. This must include any custom conditions, as well as any core conditions (eg completionview and/or completionusegrade) that apply to the activity.

/**
 * Returns an array of all completion rules, in the order they should be displayed to users.
 *
 * @return array
 */
public function get_sort_order(): array {
    return [
        'completionview',
        'completionminattempts',
        'completionusegrade',
        'completionpassorattemptsexhausted',
    ];
}

Activity dates

Each activity can have milestones, due dates, important dates. We have developed a base class for this: \core\activity_dates.

Activity plugins that define dates must implement a

mod_[modname]\dates

subclass and the following method:

get_dates

This method returns an array of important dates in the following format:

[
    [
        'label' => <the label>
        'timestamp' => <the timestamp>
    ]
]

This is an example implementation:

/**
 * Returns a list of important dates in mod_choice
 *
 * @return array
 */
protected function get_dates(): array {
    $timeopen = $this->cm->customdata['timeopen'] ?? null;
    $timeclose = $this->cm->customdata['timeclose'] ?? null;
    $now = time();
    $dates = [];

    if ($timeopen) {
        $openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
        $dates[] = [
            'label' => get_string($openlabelid, 'course'),
            'timestamp' => (int) $timeopen,
        ];
    }

    if ($timeclose) {
        $closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
        $dates[] = [
            'label' => get_string($closelabelid, 'course'),
            'timestamp' => (int) $timeclose,
        ];
    }

    return $dates;
}

The activity information output component

A new output component has been created to display the plugin's custom completion conditions and relevant activity dates to the plugin's view page and the course homepage.

To display the custom completion conditions on your plugin's view.php page, call

$OUTPUT->activity_information()

after the heading of your activity plugin's view.php. For example in mod_choice:

echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($choice->name), 2, null);

// Just add this after the heading in view.php. Make sure that $cminfo is a cm_info object. (e.g. by calling cm_info::create())
$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); // Fetch completion information. 
$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); // Fetch activity dates.
echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates);