Assignments

The Assignments addon exposes actions and filters that let you plug custom logic into key moments of the assignment lifecycle. Use these hooks to send notifications, change pagination, or integrate with external systems.

Actions

  1. stm_lms_assignment_before_drafting

Type: action

When it runs: right before a learner starts an assignment for the first time

Parameters:

  • $assignment_id (int)

Example:

add_action( 'stm_lms_assignment_before_drafting', 'mslms_assignment_before_drafting', 10, 1 );

function mslms_assignment_before_drafting( $assignment_id ) {
    $response = wp_remote_post(
        'https://demo-website.com/',
        array( 'body' => 'Assignment with ID ' . $assignment_id . ' has been started.' )
    );

    if ( is_wp_error( $response ) ) {
        error_log( 'Request error while sending assignment start notice for ID ' . $assignment_id );
        return;
    }
}
  1. stm_lms_assignment_{status}

Type: action Concrete hooks: stm_lms_assignment_passed, stm_lms_assignment_not_passed

When it runs: whenever an assignment status changes

Signature used by MasterStudy:

Statuses:

  • passed

  • not_passed

Parameters:

  • $status (string)

  • $student_id (int)

  • $assignment_id (int)

Important note: the dynamic action passes two arguments. Set accepted args to 2 in add_action. Do not expect a status argument in the callback for the concrete hooks.

Example notify on not passed:

Filters

  1. stm_lms_single_assignment_per_page

Type: filter

What it does: controls how many assignment items appear per page for learners

Parameters:

  • $per_page (int)

Return: int updated per page count

Example:


  1. stm_lms_instructor_assignments

Type: filter

What it does: controls how many submissions appear on the instructor assignment review screen

Parameters:

  • $per_page (int)

Return: int updated per page count

Example:

Last updated

Was this helpful?