At Discover eLearning, we work with clients based all around the world to help them fit the robust LearnDash LMS platform into their workflows.
We recently had the pleasure of working with a US based client who were looking to develop a platform for both the delivery of course content and the facilitation of formal examinations at the end of each course.
Because of the vast array of features that are built into LearnDash’s Quizzing options, we were able to create the exact environment that the client were looking to build at the time, but due to the strict rules regarding exam facilitation (for home-based learners), it was necessary for a third-party proctoring organisation to be involved during the month that exams were scheduled to run…
It was decided that the best way to protect the exam was to password protect access so that it could only be started as soon as the online proctor had performed their initial checks and were satisfied that the learner was ready to start. As a side note, the timed release feature of Lesson/Topic pages was also considered, but because each learner may be taking the exam on a different date and time it seemed best to give the power to commence the examination completely to the Proctor.
At first this didn’t seem to be a big issue, as there is already a Password Protected option when it comes to publishing a post/page in WordPress. What we discovered in the case of our client’s theme however, and also our own demo site theme which I have used to take the screenshots below, was that the LearnDash generated elements such as the link to access the quiz on the lesson page was being rendered separately from the page content, and by default it appeared that the password protect option is designed to only protect everything governed by ‘the_content()’ WordPress function. Things like LearnDash link boxes, assignment upload boxes and Mark Complete buttons do not always fall under this function:
In order to fix this problem we need to go into the PHP files of the LearnDash LMS plugin in order to make some changes, but first we would make a copy of the LearnDash plugin Template folder into the root folder of our theme, so that if we update LearnDash in the future we will not lose any of our changes. The file that we are working with in this case is the lesson.php file contained within the Templates folder (that we just copied over). This file contains the code block that renders the quiz link box onto the page if there is a quiz associated to that lesson:
As you can see, there is already an IF statement associated with this code block to say that the learndash_quizzes div tag should not be rendered if there is no quiz associated with the lesson. Thankfully WordPress already provides a function that we can use to check whether the Password Protected option has been set within the publishing options of the page, this is post_password_required(). So all we need to do is include this function as part of the IF statement! So if we now return to our page, this is what we see:
Job Done! The thing to remember is that if you also want to password protect the same element on Course and Topic pages then you would also need to open the course.php and topic.php files and look for the same code block.