Set LearnDash lessons to completed Storyline triggers

Hi,

In a recent project. I used LearnDash as LMS with the Uncanny plugin for reporting. There was no quiz in the tincan modules and the customer didn't want the user to use the 'mark as complete' button in LearnDash. 

I found this article online to set Captivate and iSpring courses to completed in LearnDash: https://medium.com/@hdecisions/learndash-completion-tracking-for-xapi-content-from-captivate-ispring-etc-a0848a32754d

I adjusted the code so that it also works with triggers in Articulate Storyline.

What i've done. I created an 'Execute Javascript' trigger on the last slide of the module when the timeline started. With the following piece of code:

function module_completed() {
// this is for learndash
let np = parent.document.getElementById("sfwd-mark-complete")
if (np != null) {
np.submit();
return;
}
}

module_completed();

What this piece of code does is it 'clicks' the LearnDash 'mark as complete' button so LearnDash sets the Lesson to completed.  

To prevent issues we have hidden the button with a piece of php code. That goes into the functions.php of the WordPress theme that you are using.

add_action('wp_head','hide_mark_complete_button');
function hide_mark_complete_button(){
global $post;
$tags = wp_get_post_tags( $post->ID );
$tag_found = false;
foreach ($tags as $tag) {
if ($tag->name == 'hide_complete') { $tag_found = true;};
}
if( $tag_found == true ) {
?>
<style>
#sfwd-mark-complete{
display:none;
}
#llms_mark_complete {
display:none;
}
</style>
<?php
};
};

This piece of code hides the 'mark as completed' buttons in LearnDash on al lesson pages with the WordPress tag 'hide_complete'. 

The 'mark as completed' button is hidden for users, but is still accessible from the Storyline Course.

I hope this can help other Storyline users that are working with LearnDash and Storyline.

Regards,
Mark

7 Replies