Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response for AJAX check so completion check only needs to happen so long as the activity is not completed #163

Closed
caperneoignis opened this issue Nov 2, 2018 · 5 comments

Comments

@caperneoignis
Copy link
Contributor

Currently AJAX continues to check for completion as long as the person is taking the content. However, this does not handle if the user is retaking a completed activity, or has completed it and is still in the activity.

This is a good addition to avoid the LRS having unnecessary traffic for activities that are already completed.

We can pass a variable to the completion check.php file to echo "completed" for the ajax call and the ajax call only, so the ajax call only needs to happen once.

we also need to add a small condition to the completion check if the activity is marked 'user must view activity to complete it' currently this activity completion is not validated, only the event statement is being validated. If we add the small if condition. in function tincanlaunch_get_completion_state($course, $cm, $userid, $type)

// I know the irony of getting completion check within a get completion state function.
    $current = $DB->get_record('course_modules_completion', array('coursemoduleid' => $cm->id, 'userid' => $userid));
    // Check viewed. If user only needs to view activity then skip LRS check. Because completion is achieved.
    if ($cm->completionview == COMPLETION_VIEW_REQUIRED &&
        $current->viewed == COMPLETION_VIEWED) {
        return true;
    }

I can add this to it's own issue, but it's simple enough we can add it to this one. Up to you.

@caperneoignis
Copy link
Contributor Author

I have also made an addition to the header.php, to use caching instead of DB lookups to help reduce DB look-ups since the DB lookups are happening for records that don't really change, unless the activity is updated, deleted, or course is deleted. This way the activity can be cached and reduce the lookups to one per activity, till the cache is renewed. Since the AJAX function calls completion check which has 3 DB lookups per include. This can get pretty heavy in a big environment with a huge number of users.

@garemoko
Copy link
Collaborator

garemoko commented Nov 2, 2018

Thanks for this. Completion checking is definately an area that needs attention but I'm deliberately not looking at it this release to avoid too much scope.

@davidpesce
Copy link
Owner

davidpesce commented Jul 8, 2020

@caperneoignis - I know it has been a while since you commented on this, but any chance you have a PR for this?

I'm resurrecting this repo and pushing for a v2.0 release with all current issues resolved.

@davidpesce
Copy link
Owner

A lot has changed since this issue was submitted. The completion based on view has been implemented along with the newer (moodle 3.11) custom_completion.php requirements.

The only item not implemented from this issue is the verbose execution of completion_check.php.

@davidpesce
Copy link
Owner

The completion_check.php now only checks for completion if the cached completionstate isn't completed: bb7db56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants