See the Animations on this implementation. A Demo server to play with will be available shortly.
This work requires two things:
- A LAMS Tool Adapter that wraps the Moodle tool
- Minimal modifications in the Moodle tool
The LAMS Tool Adapter is basically a LAMS Tool but with almost no "business logic" within it. It provides a set of hooks for the Moodle tools to behave as if it would be a LAMS Tool following the LAMS Tool Contract.
To talk to this LAMS Tool Adapter, the Moodle tool has to have a few minimal modifications to be incorporated in the context of LAMS.
LAMS Tool Adapter
See the LAMS Tool Adapter page for further information on its implementation.
Modifications to Moodle and Moodle Tool to work in LAMS
In this page we will focus on the necessary extensions we do in the Moodle Forum Tool to add it as a native LAMS tool. There are significant benefits on extending a Moodle tool to work on the context of LAMS.
The main challenge we faced with Moodle Tools is the same as we face with other LMSs: Moodle tools instances are heavily tied to a course. Therefore you can't quite create Moodle tool instances that are not within a context of a course.
LAMS (and learning design for that matter) has a design stage (authoring), where the teacher sets up the sequence of activities, and a runtime or enactment stage, which is when given the design that the teacher has created, the students go thru this design completing and doing the activities.
Moodle and other LMSs and their tools don't really have this concept. If they would, a teacher should be able to create a Forum outside the course and then instantiate one or more instances of this forum in one (or more) of her courses. Currently, LMS' tools allow teacher to create activities/tools in a course. So teacher goes into the course page, selects a tool to add, completes its content and bang! Now this tool is in the course page.
Trying to do a work around this can be difficult as it requires to "hack" the LMS tool, meaning that not only you need a tool adapter to "bring" this tool into LAMS, but also modify the code (though slightly) in the LMS tool to overcome this limitation.
Here's the list of changes and tasks we have identified that are needed to get a Moodle tool to work in LAMS. We'll go thru each of this individually:
Important Integration Principle
The main principle we follow is to avoid any modification to existing code whenever possible and extend the current method or functions instead.
Modifications to Moodle
- moodle/course/modedit-lams.php (+463 lines) new
This file is copy of modedit.php where we add only a few lines (this is an actual diff):
We add a new parameter called lamsupdateurl which after saving the content of the mod, this is the URL where we are going to return to in LAMS.
We won't need Moodle groups within this tool, therefore we remove it.
As you can see, we also extend the mod_forum.php file (we'll show this later) by creating a customized copy mod_forum_lams.php
Here is where we add the action parameter to the <form> as well as add the lamsupdateurl element to it.
We have added a column (is_lams) to the mdl_course_modules table as well as the mdl_forum table to identify which instances of forum and/or course modules are to be used for LAMS only.
After the saving, we return to LAMS using the lamsupdateurl appending the coursemodule id.
As mentioned before, in the authoring stage, the content we create for an activity/tool are independent of the course you create it on. Therefore we get rid of all the navigation breadcrumb.
No need for course footer, so we remove this too.
- moodle/lib/datalib.php (+1 -1 lines)
As we have added a new column to the course_modules, when a Moodle Course page is displayed, we don't want to show instances of Moodle that we have created for LAMS (as these instances might be used at authoring stage). Therefore, we add a new constraint to the function get_course_mods($courseid) function to show only course modules that aren't used in LAMS.
See the ND cm.is_lams=0 at the end of the query statement.
Modifications to Moodle Forum Tool
- moodle/mod/forum/index.php (+1 lines)
We replaced the get_records function for a get_records_select instead and add the is_lams=0 so it only shows forums that weren't created for LAMS.
- moodle/mod/forum/mod_form_lams.php (+178 lines) new
This file is also a copy of the original moodle/forum/mod_form.php which we remove a lot of features that http://lamscvs.melcoe.mq.edu.au/fisheye/browse/lams/temp_moodle_dev/moodle/mod/forum/mod_form_lams.php?r=1.1]. The only additions/modifications are:
We use standard_hidden_coursemodule_elements rather than standard_coursemodule_elements
Instead of showing the standard Save options, we only show one Save button.
- moodle/mod/forum/view.php (+6 lines)
In order to make the Moodle Forum Tool "workflow aware", we need to introduce a "Next Activity" button so after the students have posted their messages they can continue to other activities in the sequence. However, we only show this button if this is a Moodle Forum instance used in LAMS (is_lams = 1).
As part of adding a new Moodle Tool into LAMS, we need to add a few functions to the Moodle Forum tool so they can be use from LAMS. These functions are based on existing Moodle Forum functions.
This function is called from LAMS when it needs to create a new instance of a Moodle Forum based on the content of another instance. For instance when the teacher in LAMS creates a sequence that includes a Moodle Forum activity, then she creates a new LAMS lesson, LAMS needs to create a separate new instance of the Moodle Forum tool that the teacher created (because we don't want to modify the original design so the teacher can reuse this sequence elsewhere). Same if the teacher creates a second or third LAMS lesson based on the same sequence. For each new LAMS lesson, new instances of Moodle Forum Tools will be created. The LAMS tool adapter calls the forum_clone_instance when it needs to create new copies.