Assembling the heterogeneous elements for (digital) learning

Category: bam Page 1 of 3

Progressing the student interface for bim2

The last post ended up with the basics of the student controller and views functioning to produce some simple output. The aim here is to get the entire student interface up and actually reading data from the database. It won’t be completely finished. There will be some additional extra features to add. The aim here is to iron our the design of the whole model/view/controller set of classes.

Am going to release this post before it is finished and continue working on it. So it will change.

To do list

  • Help strings are not displaying consistently using either breakdown and also problems with identifiers of the help strings….Is this a problem with the version of Moodle 2 I have?
  • rationalise the filenames and object names for all of student. Feed into design approach for other users
  • Show questions
    • get_string not replace place holders with values.
    • add in support for due dates for questions.
    • include information about questions answered by the student, also details about whether its marked etc.
  • The show questions stuff can/probably should be re-used for staff, especially markers.
  • Need to read up more about the proper approach to using OUTPUT and PAGE in generating output, there’s a limit to how far simple copying can take you.
  • Setting the URL for the tables in show questions and posts, probably also activity details.
  • Show posts
    • Need to add user/blog/post summary/details at start
    • Need to test posts of various statuses.
    • Add in the option to allocate posts.
    • Is there a chance to add an internal navigation that allows jumping to individual posts
    • The “Allocated to:” value in details should be link, maybe a popup, to the question
  • Check that the views are setting the URL appropriately — e.g. does “tab” need to be included? is it?
  • Consider using html_table rather than flexible_table for some of the tables.
  • Need to look into table classes and setting styles on cells etc. to ensure table format okay

Student tabbed interface

Each of the user groups will be using a tab interface to access the different services, so have to get this up and going. After a bit of playing have this working by having the tabs declared in the controller and then having the view figure out how to display them…which is how the division of responsibilities should theoretically work.

Well, that’s working for the student views. Able to move between them all as a student with a registered blog. Need to work on the tabs for unregistered..where the other two tabs are inactivated. Actually, that works fine.

Models and object/relational mapping

The intent is that each individual page will have a model that is responsible for retrieving and manipulating all of the data required for page. That model is passed to the view which uses the data to display the necessary output. Some, if not all, of that data will be retrieved through classes that are essentially object/relational mapping objects.

I’m planning to implement the first of these with the student controller/views. Will start with the questions page as this is the most straight forward. It should simply display all of the questions that have been set for this activity.

Put in some data

I’m going to manually insert some test data into the database. The data will be taken from test data from bim.

Questions

The intent is to minimise the need for the main bim2 code to know a great deal about the tables and fields in the database. Hide all that behind a specific object, bimtwo_questions. Since Moodle already does much of this, this objects are likely to be fairly simple wrappers (and yes that does raise the question of why add the extra layer of abstraction…) One answer to that question is that some of the objects will have fairly high level methods that will perform important tasks on the data.

These o/r objects are going to sit in the lib directory for now.

The bimtwo_questions object is going to take the bimtwo identifier and retrieve all of the questions for that bim2 activity from the bimtwo_questions table.

At the moment, there will be little or no methods for the class. This is likely to change later when the idea of due dates for questions gets added. Methods to determine which questions has passed the deadline etc seem likely.

Data that will be required includes

  • questions – the list of questions for the activity;
  • answered questions – the list of questions the student has answered.

Okay, simple model up and going. Let’s get it displaying the content in a reasonably nice way. This means identifying how to produce pretty tables in Moodle 2.0.
Seems good old flexible_table remains. However, it’s gone to a oo based implementation.

Well, show questions is working, at least in a basic form. Will leave it there and move onto the other screens.

Your posts

Initially this can be a simple one and just display the list of posts the system knows about from the student. Eventually this should allow the student to manage the allocation for unallocated or unmarked questions.

First, put some approriate data into the database. bimtwo_marking needs to be filled in. Done.

Need an o/r mapping object to retrieve this data. Initially the class bimtwo_posts will be much the same as bimtwo_questions. Copy and paste and a search and replace.

Now I need to add in a model for the page and use the o/r object to get data and display it simply.

Okay, have the data, time to display it. The question is how. In bim the posts were separated into distinct tables based on state (i.e. allocated, marked, etc). For bim2, initial thinking is two tables unallocated posts and allocated posts. Allocated posts include those that have been marked, returned etc. and thus will have to include columns or some other indication of mark, dates, etc.

Actually, looks like a single table might be the way to go. Pity flexible_table doesn’t want to nest.

Need to update the test data to include posts that are

  • allocated
    Show the time allocated, Show the question that it’s been allocated to.
  • released
    Show time allocated, marked and released. Also the mark and also the comments.

Activity details

This page can take on a number of different forms, depending on whether a feed has been registered and whether or not the students are able to register a feed. The first one I’ll implement is the situation where the student has registered a feed and it has started to be mirrored.

In this situation, the page should display

  • Configuration details about the bim2 activity;
    This will be used to identify if registration is turned on, display the description of the activity and other config data around the activity.

    This data is already available as part of the bimtwo object within the factory, which is passed in.

  • feed details for the student;
    i.e. does the student have a registered feed and, if so, where is it, how many posts etc.

    This will likely need to be a new class.

  • user details.
    i.e. their name, userid etc. Used to display information, but also to get the feed details and other personal information.

    This looks like being a new class. Have made sure that factory stores the user id. This will be needed to get the user records.

Ending up with a single class that pulls all this information into the one place. However, it does rely on other classes that can be re-used elsewhere. Will document this at the end.

At the moment, I’m having to put in all the language strings and associated help files. I think I am liking the fact that help strings are now included in the help file, rather than in separate files in a separate directory.

Am having a problem getting parameters passed in correctly to help strings. Ahh, have to put curly braces around them. Interesting, I gather this from reading the code, not the Moodle documentation or discussion on moodle.org. Would be buggered without the ability to read the Moodle code.

Still having problems with getting the help strings to work properly. Going to have to put in place holders that aren’t working and leave this as a major todo. Downloaded latest version of Moodle and the problem continues. So, probably a problem with my code. Will have to look at this later.

Back to the start

The next step is to implement the activity details/student view from the start of the student interaction. i.e. before the student has registered their blog and in some cases, before the staff have turned registration on. The stages to be implemented are, when the student visits the activity and:

  • DONERegistration is not turned on and the student has not registered;
    Show the activity configuration section shown normally, but precede it with message about how the student has not registered and that registration is not on
  • DONERegistration is turned on and the student has not registered;
    Same as above, but show the registration form
  • Handle the registration of the student’s blog, which has two cases
    • Registration worked
      Show a success message and then show the normal interface.
    • It didn’t work
      Show an appropriate error message, some direction on how to fix it and show the registration form again

Use the three test students as a test case. Start with the registration not turned on.

Now to add the register form. Seems a straight copy across of the form from bim, a few substitutions for module name (bim to bimtwo) and we’re just about done. The processing of the form has to be modified to be more object oriented. i.e. a new class.

Perhaps time now to start a new blog post, this has been going on for weeks. The next one will handle the registration process.

Reducing the aggravation of student blogging: The story of BIM

In a couple of weeks I’m off to Canberra to talk PhD, potential ALTC grants and promote the use of BIM. As part of the latter task, I’m giving a quick talk at the University of Canberra as part of their Stuff the works lunches. The title of the talk is “Reducing the aggravation of student blogging: The story of BIM”.

I have to send of a short abstract for the talk today, so thought I’d share it here. I’ll use this post as the home for all the resources associated with the talk. The slides should be up sometime just before the talk and I hope some audio/video will follow not long after.

The basic aim of the talk is to share the why, what and how of using individual student blogs in teaching. The premise is that there is value in using individual blogs, but that it can require a bit of work and that BIM can help.

Abstract

There are many good reasons (reflection and meta-cognition, reducing transactional distance, increasing sense of ownership and community, ICT literacy etc) to encourage or require students to use individual blogs as part of their learning. However, the use of individual student blogs is not without its problems, which include: limited quality of LMS blogging tools, difficulties of managing externally hosted blogs, the question of how to mark and comment on student posts, the novelty of blogging for many students and staff, increased workload etc.

This session will tell the story of BIM (BAM into Moodle). A Moodle module designed to reduce the aggravations of supporting individual student blogging. Since 2006 BIM, and its predecessor BAM, have been used to support 2800+ students in 26+ course offerings creating 20,000+ blog posts. The session will show how BIM works and describe one approach to why and how it was used in one course. It will include discussion of the challenges and benefits of using BIM.

More information about BIM can be found here https://djon.es/blog/research/bam-blog-aggregation-management/

Slides

The slides that will probably be used in the talk are below. If things go well, I’ll have some audio/video of the talk up in the next day or so.

Getting back into BIM: Summary and way forward

The last couple of months have resulted in an absence from work on BIM (BAM into Moodle). This post is meant to be a summary of where I had gotten up to and a restatement of what I need to do. The latter part is somewhat uncertain due to limited communication within my local context. Somewhat disappointing.

On the plus side, contributing to my lack of work on BIM was the attendance at a couple of conferences, including ASCILITE’09. It was obvious from a number of ASCILITE presentations that BAM/BIM remains an important and innovative tool that is much needed.

If you’ve only started following this blog recently, this is they type of post acts as a log/diary of the work I have done on BIM. Probably not much of interest to a broader community.

Current status

Up until now most of the work has been familiarising myself with the “Moodle way”. I’d gotten to the stage where there was:

  • A BIM activity module in the Moodle source tree.
  • The module would create the BIM database tables.
  • The ability to add BIM as an activity to a course.
  • The resulting link inserted into the course would operate as the student details screen (screen dump) and show details about the students blog posts.
  • This screen would react to different data within the database.

The one remaining, fairly important task to be done was to figure out how to get Moodle to take data from the user and appropriately put it into the database. This is essentially the one remaining component of web application development.

Once familiar with this process, the implementation of BIM becomes a translation process from the previous system into Moodle.

How it will work

This is developed in other posts, but I’m going to re-create it here to refresh all those dormant memory patterns I have. Much of it is pretty similar to BAM. I’ve included links to screen dumps from BAM of most of the screens listed below. BIM screens will be based on these, but they will likely be different.

The intent is that BIM will work in the following way:

  • Creation.
    • Course coordinator will add BIM as an activity to their course.
    • In doing so, the coordinator will need to fill in the configuration screen with details of the use of BIM (assignment name, posts etc.)
    • At the end of this process, there will be a link in the Moodle course to the BIM activity. This is used by both staff and students.
  • Normal use.
    • All users of BIM will use the link to the BIM activity added in the creation stage (e.g. this screen dump). Depending on what role they perform, they will see different information:
      • Students: there are two different views for students
        • Register Blog screen – appears when the student has not registered their blog. Shows some explanatory text and a text box. The student has to paste in the URL for their blog and hit submit. If there is a valid feed, success.
        • Student details screen – appears once the student has registered their blog. It will show what BIM knows about the student blog (where it is, the student’s name, the number of posts) and also any marking information (marks and comments) that have been released (only staff within an appropriate role can release marks/comments).
      • Coordinator: will have access to three different screens (all which are also used elsewhere by other people – with some modification).
        • Configuration screen – the same as the screen they see when adding BIM as an activity. Allows them to view and change the configuration of BIM for the course. There will need to be some limitations on what can be changed, but this needs to be thought through.
        • Show details screen – shows an overview of the details for all students. “All” students can be chosen as for the course, for a particular marker etc. Details include student name, number, number of entries in blog, and link to live blog.
        • Show posts screen – shows for “all” students an indication of whether they have posted answers to a particular question; number of posts blogged and marked; summary of marks etc.
        • Mark post screen – this is where the students’ post is marked (if required – not all courses using BIM mark blog posts).
        • Re-allocate screen – BIM attempts to automatically allocate student posts to the question (set by the coordinator) that it matches. This automated match doesn’t always work. This screen shows all of the student’s posts and allows the coordinator to change the allocation of a post.
      • Other staff: Will have access to the Show details screen, Show posts screen, Re-allocate screen and Mark post screen as described for the coordinator. The main difference is that “other staff” can only see details for students that they have been allocated to mark.
    • Aggregation, mirroring and allocation of blog posts.
      At a regular time interval (set at the system level) BIM will check if there is a new post to each students’ blog. If there is, BIM will
      • Add a copy of the new post(s) to a local RSS file, one per student.
      • Examine the new post(s) to see if they match any of the required questions as specified by the coordinator. If there is a match, the database will be updated to indicate another question has been answered.
      • Update the database that some new posts have been made.

E-Learning 2.0 and reliability of external services

BAM is a little project of mine playing at the edges of post-industrial e-learning. Since 2006 it’s been relying on students creating and using blogs provided by external service provides – mostly WordPress.com.

This reliance on external service providers has been one of the “problems” raised by folk who don’t like the idea. They fear that because the university doesn’t own the technology or have a contract with the service provider there is no certainty about the quality of service. That the students and the staff will be left high and dry as the service is yanked in the middle of term.

Those fears are not unfounded. There have been stories of Web 2.0 services disappearing in the middle of a course. However, my argument has always been that if you pick the right service providers and design systems to allow safe failure you can achieve generally better outcomes (for a cheaper price) than the mandate and purchase approach traditionally taken by institutions.

This post shares a recent experience that supports this argument and ruminates on some alternate explanations for why this approach might be better.

The story

Yesterday I received an email from one of the teaching staff involved in a course that is using BAM. The course has 170+ students spread across 5+ campuses using BAM with their posts being tracked and marked by 10 staff. Three of the students for this teacher are reporting that they can’t access their blogs.

While BAM allows students to create and use a blog on any service provider we have found it useful to suggest providers whom we find reliable. Originally this was blogger and WordPress.com, in the last year or so we’ve recommended WordPress.com only. i.e. based on our experience, we found WordPress.com more usable and reliable. I should point out though, that the institution I work for does not have a formal agreement with WordPress.com. The students create free blogs on WordPress.com like any of the other of thousands of folks who do each week. I’ll pick up on this later.

After looking at the reported problem it was apparent that the blogs for the three students had been suspended because they apparently had contravened the WordPress.com terms of service (ToS). This mean that the students couldn’t post to their blog and no-one could see any of the content posted to their blog. While it seemed unlikely that the students would have done anything to deserve this, it’s amazing what can happen. So the question was what had they done?

A key part of BAM is that it is designed to enable safe failure. If, as in this case, the student’s blog has disappeared – for whatever reason – it doesn’t matter. BAM keeps a mirror of the blog’s RSS/Atom feed on a university server. So while I couldn’t see the blogs posts on WordPress.com, I could see the content on BAM. Nothing there looked like it would contravene the ToS.

So the only way forward was to ask WordPress.com why they did this. This is where the fear of failure arises. I’ve seen any number of examples of technical support being horrible. Including instances where the institution has paid companies significant amounts of money for support only to receive slow responses that do little more than avoid the question or report “it looks alright from here”. If you get this sort of “service” from supplier you pay, what sort of response am I going to get from WordPress.com.

Remember, these blogs are not my blogs. The blogs belong to students who attend the university I work for. A university WordPress.com is not likely to know anything about. A university they certainly don’t have any relationship with. In fact, it’s a university that appears to favour a competitor. Both IT division and our Vice-Chancellor have blogs hosted by blogger.

For these reasons, I was somewhat pessimistic about the response I would get. I was fearful that this experience would provide support for the nay sayers. How wrong I was.

12 hours after I contacted WordPress.com about this issue. I received an email response which basically said “Oops, sorry it looked like the profiles matched spammers. Our mistake. The blogs are back.”.

12 hours might seem like a long time if you’re picky. But I’m more than happy with that. It’s streets ahead of the response times I’ve seen from vendors who are being paid big money. It’s orders of magnitude better in terms of effectiveness.

Do one thing and do it well

It’s my proposition that if you choose a good Web 2.0 service provider, rather than being more risky than purchasing, installing and owning your own institutional version of the service, it is actually less risky, less expensive and results in better quality on a number of fronts. This is because a good Web 2.0 service provider has scale and is doing one thing and doing it well.

Unlike an integrated system (e.g. an LMS) WordPress.com only has to concentrate on blog engines. So it’s blog service is always going to be streets ahead of that provided by the LMS. Even if the LMS is open source.

A commercial LMS vendor is going to have to weight the requirements of huge numbers of very different clients, wanting different things and consequently won’t be able to provide exactly the service the institution needs. Not to mention that they will be spread really thin to cover all the clients.

An open source LMS generally has really good support. But the institution needs to have smart people who know about the system in order to properly engage with that support and be flexible with the system.

There’s more to draw out here, but I don’t have time. Have a paper to write.

BIM#5: Getting a prototype BIM going

In the last bit of work I did on BIM, I got to the stage of having some initial working code for BIM module that allow someone to create a BIM activity and have that data saved to the database. The activity wouldn’t do anything, but it’s a start.

The aim today is to try and make some progress on getting a prototype up and going. i.e. some working Moodle code that academic staff can interact with and get some idea of how BIM will work. I’m still uncertain how far I will go with this. I have two main options:

  1. hard coded HTML; or
    Have the code return hard-coded HTML, don’t read any database. Just give the same information.

    This would be the simplest approach in terms of database tables and code. However, given that Moodle uses a forms library, I won’t be able to do the simplest thing – copy the HTML from BAM into BIM. I’ll have to do some translation. It may turn out to be simpler to do the next bit.

  2. generate HTML from a pre-populated database.
    Take/manipulate some data from the existing BAM database to create a BIM database in Moodle. Write code in BIM that will generate HTML based on that data, but not allow modification of the data.

    Some increased complexity, but also like to be a temptation to write the whole code which will slow down the production of the prototype.

Based on that bit of reflection, I think I’ll start with a hard-coded HTML approach and see what happens.

What to show

First step, I should probably ask if <a href="http://www.cqu.edu.au/CQU has a theme for its Moodle implementation. If I apply it to my dev box, I can make the initial prototype experiments look like the live system. Have to ask.

Okay, with the current status of BIM, if I “view” the activity, it doesn’t produce any HTML. The plan here is that different users will see different information when the view the activity. The different views are:

  • Student
    • If they haven’t registered their blog, see the information about how to create and register their blog.
    • If they have registered their blog, they should see
      • Details about their blog, including an interface to change their registered blog (if so configured by the coordinator).
      • Details about their posts/answers.
        This is where they see which posts to their blog BAM has recognised as an answer to a required question. It will also show whether the answer has been marked and also any comments from the marker.
  • Staff – the following draws on screen shots of the existing system. The appearance will change to fit Moodle and also possibly to improve the interface.
    • By default the “student blog details” screen (see below)
      BAM show student blog details
    • Link to the “answers page”
      BAM show all student posts page
    • Which in turn links to the marking page
      BAM mark post page

To find out

This means that I need to find out how to do the following in Moodle:

  • Perform different operations for different types of users.
  • Ensure only the authorised users can perform those operations.

Different operations

Viewing an activity is done via the view.php file in the module. At this stage it looks like this PHP code should check various parameters as well as course and user details and decide what to do as a result.

It seems that view.php follows a fairly set structure (not suprisingly).

  • Parameter check
    Check each of the parameters exist and are valid – including checking that there is an instance of the activity (e.g. bim) that matches the id that’s come in. Crash and burn if these checks don’t pass.
  • Security check
    Get the login details/objects of the user, perform security/capability checks.
  • Log some activity
    i.e.
    add_to_log($course->id, "bim", "view", "view.php?id=$cm->id", "$bim->id");
  • Display the HTML
    Which often involves a fair bit of calculation and then some use of standard header/footers.

The quiz module appears to use the idea of pagelib.php – which appears to implement/extend a factory class. i.e. a class that determines which type of quiz is being displayed and how to display it. There’s a global Moodle pagelib.php which seems to define the base classes for these. There’s a number of them – quiz uses page_generic_activity.

The LAMS module in the contrib collection appears to take the simple if approach i.e.

if (has_capability('mod/lams:manage', $context)){
....
}else if(has_capability('mod/lams:participate', $context)){
....
if ($lams->introduction) {

In the long run this will have to be thought through. The if/else option isn’t a technically nice and neat solution. I’m happy for a hard-coded prototype to use it though.

Authorised users, capabilities etc.

The question now is how to determine between different types of users. How to know the difference between students and staff.

According to the intro to moodle course docs there’s a roles and capabilities system that has replaced fixed roles. That sounds like, and based on the modules I’ve looked at, the way to go. More documentation here.

Capabilities etc are defined in the db/access.php file for the module which looks a bit like this

$mod_lams_capabilities = array(

    'mod/lams:participate' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'student' => CAP_ALLOW
        )
    ),

    'mod/lams:manage' => array(

        'captype' => 'write',
        'contextlevel' => CONTEXT_MODULE,
        'legacy' => array(
            'teacher' => CAP_ALLOW,
            'editingteacher' => CAP_ALLOW,
            'admin' => CAP_ALLOW
        )
    )
);

Should be able to add a couple of dummy ones and use that to add in some if/else to display different HTML based on the type of user.

First problem is that it appears changes to db/access.php only get recognised if you increment the version and/or reinstall

Next problem is that the little test I’m doing isn’t working. I thought I’d set a capability only for a student – but the code is being executed for the admin user. Either I’ve done it wrong or the admin user has some additional “powers”.

Looks like the latter. Need to create another user and assign as a teacher. Yep, that works.

Now, rather than simply “else not student” let’s add a capability the identifies teachers and maybe another one that identifies admin. Okay, the administrator version is working. But not the teacher one.

At this stage, I’d like to know if there’s anyway, in the code, to spit out information about the available capabilities. Would that be in the context variable? Nope, it’s fairly simple….doesn’t seem to be any reasonably straight forward code.

need to move on. I’m stuck at the moment with two of the capabilities working, but not the one with the student. Guess, I’ll have to go with a default.

Put in the student details page

While this is fairly straight forward. The other unlooked for complication is the need to grasp the use of weblib.php and its functions. So far, the introduction to weblib is not straight forward.

It looks like it will require a dive into weblib.php and some trial and error. Can’t seem to find anything in terms of decent overview documentation – apart from that generated automatically from the code.

Again, it’s another one of those frustrating jobs, not difficult, just painful.

Looks like it is time to go.

Status

Have made some progress on the prototype. But really identified some additional reading and understanding that’s required to do this in “proper” Moodle-ese.

BIM #4: Re-jigging how BIM works

The last post in this series saw me struggling – the long way around – to the realisation that the implementation model I had in my head wasn’t going to work. At least not with the constraints of the model adopted by Moodle.

This post is about me struggling to come up with a implementation model that will actually fit the Moodle model and hoepfully also the students and teaching staff that will use BIM.

Getting in the Moodle model more

Perhaps part of the problem, is that I’m not familiar enough with the Moodle model to feel how it works. So, let’s play with some of the standard modules and add activities.

  • Quiz
    • First page is the main configuration page, lots of options. But nowhere to specify the questions or question bank.
    • View the page (as the admin user) and you get to see the question bank editing/adding interface. Also see a range of other buttons.
    • A student view doesn’t include the whole question bank interface, just a message “no questions yet”
    • The update interface returns back to the original configuration page.
    • Once a question is answers, the student sees an “Attempt quiz now” button
    • Each of the different operations draw on different php script in the mod/quiz directory.

Quiz inspired BIM model

Based on the above, the BIM model might become:

  • A BIM activity is added to the course.
  • This brings up the BIM configure page.
    This covers everything need to set it up initially. Including the HTML/text to explain to the student the purpose of the assignment and how it works. i.e. not a URL

    This might also include an option to change the use of “blog”. i.e. if they want BIM to aggregate something other than a blog, just some RSS etc.

  • The configure page becomes what is shown for the “update”
    So this means that there is no need for a configure activity.
  • A student would then have the following options if they were to view the BIM activity
    • View background information i.e. what it’s all about.
    • Register their blog and/or see information about their blog.
    • View progress.
      This would include a list of the questions they are meant to answer and indications of which they have answered.
  • A staff member would see
    • Details – list of all students, who are registered, who is not etc.
    • Post summary – list of all matched answers for each student.
    • Questions – a list of all the questions
      The coordinator would be able to configure these. Normal teacher would just see the details. The code would be much the same as that for the view progress for the students.

That seems more doable, probably need the block at a later stage.

Get going

So, let’s not rest and do some design. Let’s get coding. Start with the configure/update/add option. This is essentially a modification and play with the dummy function provided by the NEWMODULE template. First step should be to identify what configuration data will be needed – at least at a minimum. Here’s the first list:

  • Name for the bim activity.
    This becomes the name displayed on the course page.
  • Instructions for students.
    This is the background/instructions for the students about the BIM activity.
  • Mirror
    Should the feed for students in this course be mirrored?
  • Register
    Can students register their feeds.
  • Change
    Can students change their feed.

That’s probably enough for now. Some of the obvious ideas for later would include:

  • Dates for when students can register.

Config form

So let’s get going on modifying this thing:

  • Uses the formslib stuff from Moodle.
    Various PHP functions to automate setting up the HTML form and having it play nicely with the Moodle checks etc.
  • Draws on the language files lang/*/bim.php to specify various strings that are used in the interface.
  • Seems to be a standard to start with “General” settings, then specific activity settings, then some more specific ones.
  • Mirror, Register and Change are all essentially booleans, they need to be checkboxes.
    Quiz uses these a lot. So might steal the examples. Probably not the best approach. How are the docs? Probably better to start with the more generic ones

    So the code goes something like

            $mform->addElement('advcheckbox', 'register',
                        get_string('register', 'bim'), '' );
            $mform->addElement('advcheckbox', 'change',
                        get_string('change', 'bim'), '' );
            $mform->addElement('advcheckbox', 'mirror',
                        get_string('mirror', 'bim'), '' );
    

    Will need to do some additional checks as we go along, but that’s working in terms of display at the moment.

  • Add help links for the BIM settings.
    This makes use of the setHelpButton method of the form class. Need to create an appropriate HTML file within the lang/*/bim/help/bim directory that matches the string name used in lang/*/bim.php. Then various parameters make the link
    $mform->setHelpButton( 'register', array( 'register',
          get_string( 'register', 'bim' ), 'bim' ));
    $mform->setHelpButton( 'mirror', array( 'mirror',
          get_string( 'mirror', 'bim' ), 'bim' ));
    $mform->setHelpButton( 'change', array( 'change',
          get_string( 'change', 'bim' ), 'bim' ));
  • Get it stored in the database.
    Done the simple interface stuff, now to get it stored in the database. I’m assuming this is going to related to update_instance in lib.php

    The intro and other standard stuff in the form is handled by default in the mdl_bim table. And by some fairly simple code.

    And if I do a print_r( $bim ) in the function I can see that the form data is all passed in as expected. All nicely put into 1s and 0s for the checkboxes so it can be put straight into the mdl_bim_configure table I set up earlier. All I have to do now is to figure out how it works.

Working with the database

Most of the example modules I’m looking at seem to be accessing the global $DB, retrieving data from the form object, doing some checks/manipulationg and then calling various methods of $DB to stick it in the database. So, probably just means getting a grasp on $DB and its methods.

So this is one area where a move to Moodle 2.0 will need a change. The DML for pre-2.0 is different than for 2.0 onwards. Pre-2.0 docs

Tasks to do

  • Change the config of mdl_bim_configure to use bim id rather than course id.
    • Of course this is when I discover the “change” is a reserved name by XMLDBB. Have to change this and the other code.
    • In the end, rather than figure out how to upgrade, I just deleted the module and reinstalled – blowing away the old dbase
  • Modify add_instance to insert initial default values in mdl_bim_configure
    • Need to get the id for the entry in the mdl_bim table, used as field for the mdl_bim_configure table
      The insert_record function is meant to return the id.
    • Create a default record and then insert it into mdel_bim_configure.

    Well that works ok. Should I be putting error checking in? Maybe eventually. Still working on the prototype.

  • Modify the form so that it retrieves the information from bim_configure and shows it
    • I’m assuming this implies mod_form.php needs updating?
  • Wrong – much simpler way is to modify bim table to include what’s necessary. Much smarter and more Moodle approach.

Yes, well that works much better.

Status

Have other things to do. Today’s seen some progress, mostly in terms of getting a better understanding of the Moodle model and figuring out how BIM might fit within that. The main measurable outcome of the day is that a BIM module exists and it can be used to add an activity to a Moodle course.

Of course, it won’t do anything, but all the other stuff is there.

At this stage, I think next Tuesday’s task will be to implement some hard-coded HTML to develop a prototype. However, that’s not likely to look too Moodle like. I might look at going a step further and having it be able to use an existing set of tables. Almost hard-coded but with some real data….

BIM #3: Getting the module work, making some progress?

The story of trying to get BAM into Moodle (BIM) continues, today’s saga continues on from the last post which had progress stalled. The NEWMODULE template module was put in place, I had thought most of the necessary steps were being taken, however, the module name is not showing up as expected.

First, I’ll try and solve that problem, then make some moves on starting to put in some initial functionality into the BIM module to get it working as a prototype.

Getting NEWMODULE BIM working

Summary of steps taken to move forward:

  • Perhaps I didn’t change all the NEWMODULE labels into BIM.
    Nope, that wasn’t it. Only a couple minor left overs in some HTML. Changing those, still no movement.
  • Before the next step, perhaps we’ll do a restart of Apache, the last resort of the clueless – the big red button.
    That was too much to hope for.
  • New thought, have I changed all the filenames?
    Nope, the language file was still newmodule. Okay, that hasn’t solved the problem, but the wrong filename could have screwed up installation?
  • Uninstall and try again?
    There’s a delete option in the “Manage activities” page, let’s try that. Okay, it looks like it only deletes the database stuff, doesn’t touch the files. Though it does give advice to remove those. Let’s try to reinstall.
  • Reinstall.
    Ok, reinstallation of dbase tables works fine. But still not added to the list. Perhaps time to look at the Moodle forums and see what common mistake I’ve made.
  • First, let’s identify the write Moodle language to use.
    “Site adminstration block” is the name for the “block” in the left hand menu where the bim name is not appearing.
  • Wrong NEWMODULE?
    By this issue in the Moodle tracker it appears that I might have the wrong NEWMODULE. Yep, looks like the version in the contrib code is for version 2.0. The issue includes a link to a version for 1.9, which is what I’m currently working with. Oh dear, time to start again.

Reflection on the experience so far

It’s been a few weeks now trying to get my head into Moodle. Some reflections on the experience so far:

  • The context in which I’m trying to do this is far from ideal, so that may influence some of the experience.
  • Trying to get an overview of Moodle, how it works, its structure, its terminology etc. has been really hard. I’m yet to find a clear, concise overview of this in any of the documentation. The different versions, while understandable, adds to the problems. The half-finished nature of some of the beginners documentation also doesn’t help (yes, I know the point of an open source community is that if you have an itch, you scratch – but I don’t have the time nor energy at the moment, perhaps later). This is perhaps, the biggest problem I’ve faced so far.
  • The developers’ community on the forums seems to be quite active and very good. Perhaps the biggest plus that Moodle has. But there’s also a limit to how much you want to rely on folk.
  • Some of the ideas in the Moodle design are quite good, perhaps limited somewhat by the implementation language, but it’s also an advantage – there’s no single right answer there. However, while only a little way into understanding, there does appear to be some “ad hoc’ness” to some aspects of the design. But then you get that in any long-term software product.

But then perhaps I’m just being overly critical because I’m making newbie mistakes.

Starting over with the 1.9 NEWMODULE

Here we go again:

  • Save the old version, just in-case.
  • Delete it from the Moodle instance.
  • Copy the new NEWMODULE across and start following the instructions in README.
    These are instructions are a bit different and possibly better.
  • One of the differences is that this one suggests you use XMLDB (the apparently hated web-based XML/dbase editor in Moodle).
    Yep, the bim db stuff shows up. What the hell, let’s bring the old BAM tables across now.
  • Maybe, just add the BAM_CONFIGURE table
    That works well. If you put in a duplicate of a table that already exists, it errors and then loses your data! Similar happens in other places. I’m beginning to see why people hate this thing. I’ll leave it at just this one table.
  • Saving the changes?
    There’s a cryptic (for a newbie like me) directive in the README to make sure you use the SAVE link on the XMLDB main page. It’s cryptic because I can’t see a SAVE link on the page I’m on and can’t really see an obvious indication of where the “XMLDB main page” might be in relation to where I am.

    Ahh, there’s a “back” link at the end of a list of other, very different links. But no “save” on that page, but wait, there’s a “Back to main” link in much the same place, again at the end of long list of unrelated links.

    Okay, this must be the main XMLDB page, but there’s no save link operational. Does this mean that the save has already been done? The install.xml still seems to have the same timestamp.

    Ok, there’s a point about the link not being active because the apache user doesn’t have permission. Yep that’s the problem.

    Would’ve thought there would be an error message if the file couldn’t be written to!

  • Okay, next step is notifications. Yep that worked.
  • Does it appear in the site adminstration block?
    Bugger (and other more serious words), no it doesn’t. We’re back at the same place. It’s in the list of activities shown when viewing the long list, but it doesn’t appear in the site administration block.
  • Is this a permission problem?
    Nope all looks the same.
  • Check the courses. Ahh, can add bim now as an activity. Okay. This must mean that you only get in the Site Administration block based on something else that I haven’t done yet.

That was a bit of time wasted, wasn’t it?

I’m guessing the killer was the permissions and perhaps the different version of NEWMODULE for 1.9 and my lack of understanding about the site administration block.

Putting in some initial BIM code

If I try to add a new bim activity, it simply uses some default forms from the NEWMODULE template. I’ll want to be changing this at a latter date. However, first, I think I’ll look at how I’ll be providing two different activities within BIM:

  1. Staff BIM.
    This allows staff to track, mark and manage BIM. The coordinator (what’s the Moodle equiv) will have something slightly different.
  2. Student BIM.
    Where they can register and track progress with marking on BIM.

The Assignments activity is the only one that appears to have multiple different activities to add, so I guess I’m off to look at that code.

First, the NEWMODULE readme.txt suggests looking through the lib.php, index.php and view.php files. The following summarises what I find about each of the three files, including some insight from here:

  • index.php – a page to list all instances in a course
    This one should be fairly simple/straight forward extension of what’s already here.
  • view.php – a page to view a particular instance
    More complex in terms of what BIM will do, but fairly straight forward (I hope)
  • lib.php – any/all functions defined by the module should be in here
    Standard set of functions called by Moodle to perform things (e.g. create an instance of the activity). This is a bit of where getting into the Moodle mindset will be interesting.

Multiple activities – learning from assignment

view.php for assignment appears to implement a simple equivalent of the “factory” pattern. Given an assignment id, determine the type and then call a library that is specific that assignment type.

The “types” are implemented in a type directory, where each sub-directory matches an assignment type (offline, online, upload, uploadsingle) within each of those directories is an assignment.class.php file that extends a base class defined in lib.php. This is where the assignment type specific stuff is implemented.

How does the module get the multiple entries in the “Add an activity” menu? “Advanced uploading” and “Assignments” are some of the phrases it produces. Where are they used? Well, that’s a bit of a problem. I’m not finding everything I think I need.

Ahh, perhaps assignment, as one of the core ones, is using config/libraries from elsewhere – outside the module. Yes, the language file that defines strings is outside in the main lang directory.

modulenameplural typeoffline typeonline typeupload typeuploadsingle are strings used for assignment related to the “add an activity” menu. Where did those get used in the code?

  • lib.php::assignment_get_types
    Seems to be it. Uses a thing called MOD_CLASS_ACTIVITY and returns an array of those. Yep, that’s the one. Added a “HELLO” and it shows up.

Time for lunch

So, I’ve identified where the function in the assignments module lib.php that creates the array of “objects” necessary to update the “Add an activity” drop menu. I need to figure out how this function is called by Moodle.

Bugger, it’s in the ~/moodle/tags file. A “system” level type thing…..bugger.

Might have to think about a single activity. Not worth the hassle.

BIM#2 – Starting the module

As outlined in the last BIM post the aim here is to take the “template” NEWMODULE and start creating a BIM module. Initially, this will contain hard-coded HTML or perhaps some initial non-functioning forms, we might progress onto some canned examples and finally to the real thing.

The NEWMODULE template

The aim here is copy this code into a “bim” module directory and update it a bit to get it working, but not doing anything useful.

The NEWMODULE module is part of the contrib code for Moodle and is essentially a template for all the stuff a new module should cover. There are some issues, it appears, about whether or not it has kept up to date with version of Moodle. I guess there’s only one way to find out.

Here’s what I did:

  • Create a directory ~/moodle/mod/bim
    This is where I think the bim code will live.
  • Copy the contents of NEWMODULE over into bim.
  • Go into Moodle and see if that’s changed anything.
    Apparently, modules/blocks when first installed can take additional installation steps via the web interface.
  • Nothing there, but that is expected as the instructions for NEWMODULE suggest that I have edit the files to replace NEWMODULE with bim.
  • Go to Notifications as the admin via the web interface and yes, the databases for the module get created.
  • At this stage, bim should be showing up in the list of installed activities — but no, it’s not!
  • At least not in the administration section, there is a new [[modulename]] in the “Add an activity” in a course site. Looks like this might have been missed.
  • Ahh, it’s not in the main list that appears in the navigation menu, however, if I head into “Manage Activities” it is there. So it would appear it can be added, for some reason. Maybe I need to write a bit of code.
  • Ahh, looking at the code I find that if the version variable is set to 0, then it will not be installed. That needs to be set to the typical timestamp format that Moodle uses.
  • Having set that, it appears there’s a need to re-visit notifications to get it installed. Some warnings as the dbase already installed. In fact, it reports upgrading failed. Looks like we’re in an endless loop now. The problems are due to “bim” rows inserted into the log. So, I’ve deleted those entries and dropped the bim table.
  • At this stage, there’s a complaint about bim needing upgrading and the table mdl_bim not existing. Seems to imply there’s another entry for bim in another table, probably need to delete that.
    delete from mdl_modules where name='bim';
    
  • So that is working, but still bim only appears in the “Manage activities” not in the list of activities. Something else missing? There are other activities that aren’t showing up as well

Gotta love a positive place to stop.

BIM #1: Working on the prototype

Over the last few weeks I’ve slowly been getting into Moodle/PHP as part of need to put the BAM project into Moodle. I’ve decided today to abbreviate this project into BIM – BAM into Moodle. It’ll do for now.

The last post left off on the development of a eStudyGuide block. I’m leaving that behind now and trying to focus on ideas/development of a prototype of BIM so that other folk can look and play with it.

Requirements for a prototype

I think the aim will be to set up a prototype of how I think BIM will work in such a way that other people can experiment and discover what I think BIM will do. Some ideas:

  • Use an old CQU course that has already used BAM.
  • Set it up as a Moodle course.
  • Add the various BIM links/blocks I’m thinking of initially as HTML, later as hard-coded, then display only, finally working??

I’ll use the 2006/T2 offering of COIS20025 as the prototype course. It’s the first course to use BAM and I was the coordinator – that lessens issues with permission etc.

Functionality and plans

A previous post outlined a list of tasks users will have to perform with BAM. Each of these will have to be integrated into the prototype and decisions made about how it will be implemented. In the following the tasks are divided into students, coordinator and teaching staff.

The end result of all that, is I need to discover the following:

  • Can a Moodle module be used to add a number of different activities?
    In this case, need to be able to add a “Create and register blog” activity for students and a “BIM Manage” activity for staff.

    Yes. It appears that this is what the Assignment activity does

  • Can a Moodle module generate a block – or does the block need to be implemented as block? (I’m guessing the later)
    Would like there to be a BIM block that shows different information specific to the student/staff looking at the site.

    May work around this by simply having a single student BIM activity. Initially it requires registration, then it shows progress.

  • How does Moodle handle the allocation of students to a marker/staff member?
    Is this done in the gradebook, for groups? How is done at CQU?
  • How can BIM put results into the gradebook?
    Each blog post will be marked separately and then all results manipulated into a final result. That final result will generally, but not always, need to go into the gradebook. Some other courses may not use the gradebook, so I don’t think BIM should be implemented within the gradebook. Just have a connection to it.

    This fits with the Moodle model – there’s a gradebook API.

  • How should BIM configure/connect to an assessment item within the gradebook?
    The gradebook API?? Will check on this.

Will continue this at some later stage.

One Moodle module – different activities

Initially I’m going to do a search for examples of a Moodle Module that supports multiple activities, however, I’m starting to feel that understanding the Moodle module/activity process might be a better way to go.

Doesn’t seem to be anything easily findable via Google – perhaps says more about my grasp of the Moodle vocabulary.

Let’s go via the code

  • Example activities in a default install – Wiki, Survey, SCORM/AICC, Quiz, Lesson, Gloassary, Forum, choice etc.
  • URL is all to mod.php with an id (course?), section, and a “add” parameter
    Each of the values for “add” appear to match the name of a folder in the ~/mod directory. Implying, one directory, one activity.
  • Interestingly, there are 7 mod.php files in Moodle. The one used here is for course.
  • mod.php can be passed a range of values – add, type, indent, update, hide, show, copy, moveto, movetosection….
  • Ahh, the assignments activity has options – online text, upload, offline, chat specified by a type parameter that is passed in as a parameter.

Ahh, finally found the right words for Google searches, online resources include:

Assignments activity

This activity is an example of an activity with different related tasks. Here’s a description of some investigations:

  • The “Add activity” drop down on a course page has sub-items for “Assignments” matching each type.
    So, BIM could be equivalent to “Assignments” and then have two sub-types: CreateAndRegister and Manage?
  • Now, does this mean a different form when adding this activity. – Add an online text – add an offline.
    There are similarities and differences in the forms used.
  • Once the assignment activities are added, they use view.php in the activity code with an ID passed. Again, it displays some information that is customised to the type.
  • Those that require a form, also go via view with additional parameters.
  • There’s also an index.php for assignments that takes the course id and shows all the relevant activities in a page.
  • The index.php is used as a link in an “Activities” block that lists all activities in a course.

Perceived mismatch

There seems to be a mismatch here between my ideas and how Moodle works. The first time you add a BIM activity, the Moodle approach seems to be that this is when you configure BIM for the course.

Similarly, the separation of create/register and the progress activities for the student into an activity and a block may not be the best way to go. Perhaps, just a single activity – check progress or something similar.

Grades

Docs on the grades/gradebook is the place to find out about this. Some comments:

  • Gradebook is designed to be the repository – modules push grades to it, gradebook doesn’t go the other way.
  • The pushing is done via the gradebook public API.
  • Related terms include:
    • Grades – scores attributed to participants.
    • grade category – collection of grades
    • grade item – stores a grade for each participant.

Will need to read more of this eventually.

Where next?

After all of that, it appears that a path forward might be to start work on the new module, initially as a prototype and eventually, over time, add the real functionality into it.

So that’s the next step.

BAM into Moodle #9 – a working eStudyGuide block?

The last post finalised some bits of knowledge I needed, now it is time to put it into action and complete the eStudyGuide block to a barely useful level.

Steps required include:

  • Add the username/password to global config.
  • Retrieve the xml file for the course using curl.
  • Parse the InDesign xml using Moodle.
  • Modify the HTML produced to use that information.
  • Retrieve the file for the name of the module, chapter etc.
  • Generate the HTML for the block based on that content
  • Initially, retrieve the PDF files via normal http connections to where the guides are located (will require user to login again).
  • Replace that with the use of curl.

There’s still an outstanding problem with the naming used in some courses. i.e. those that have an “introduction”.

Add username/password to global config

Fairly simple to add the form elements to the global config – simply edit config_global.html. However, small problem the text elements are giving the following errors

Notice: Undefined property: stdClass::$block_estudy_guide_username in … on line 8

Interesting, there doesn’t seem to be any difference between the use of those variables in the code and the existing one for base_url. The one difference is that base_url already has a manually set value. Surely there should be a way to initialise these to empty?

Ahh, it turns out it’s connected with the level of debug options, had everything turned on for development. Return it to normal levels for live box – no worries.

Retrieve the xml file

All the necessary variables have been calculated, let’s add a function to return the xml file as a variable.

function getXml() {
global $CFG;

// $base_url/YEAR/PERIOD/COURSE/eStudyGuide/COURSE.xml
$url = $CFG->block_estudy_guide_base_url .
$this->content->year . “/” . $this->content->period . “/” .
$this->content->course . “/eStudyGuide/” .
$this->content->course . “.xml”;
$auth = $CFG->block_estudy_guide_username . “:” .
$CFG->block_estudy_guide_password ;

$curl_handle = curl_init();

if ( $curl_handle )
{
// $fp = fopen(“tmpfile”, “w”);
// Configure curl options
curl_setopt($curl_handle, CURLOPT_URL, $url );
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CULTOPT_HTTPAUTH,CURLAUTH_ANY);
curl_setopt($curl_handle,CURLOPT_USERPWD, $auth);

// get the stuff
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

return $buffer;
}
}

Well that compiles, all I have to do now is figure out how to call it properly. Ahh, $this of course.

Oops, undefined constant CULTOOPT_HTTPAUTH – dyslexic fingers – CURLOPT

Next problem, the base url doesn’t seem to be coming across properly. Ahh, web server error only gives path – the wrong course code. Testing course code doesn’t have a guide for 2092. Yep, that’s working. Now to parse the bugger.

Parse the XML

The first question is exactly what information do I need to get out of the XML file. The file basically gives a summary of the chapters and headings within the study guide. The tag is used for the chapter titles. The original version gets the titles for each chapter from the XML file and displays that next to the number of the chapter. Given the sparse real estate in a Moodle block, the title of the chapter isn’t going to fit. So we don’t need that.

Essentially, all we need to do is count the number of TOClev1 entries in the XML file.

Xmlize uses a collection of nested associative arrays where, at least for some, the key is the tag. So, from one extent should be able to simply count the number of TOClev1 keys.

Ahh, there’s a nice little function traverse_xmlize within Xmlize that displays the array Xmlize produces in a format that is pretty readable. Here’s an example

$xml_[Story][#][Heading1][0][#] = “Contents
” $xml_[Story][#][TOClev1][0][#] = “The auditing and assurance services profession 9
” $xml_[Story][#][TOClev1][1][#] = “Ethics, independence and corporate governance 19
” $xml_[Story][#][TOClev1][2][#] = “The legal liability of auditors 29
” $xml_[Story][#][TOClev1][3][#] = “The financial report audit process 43
” $xml_[Story][#][TOClev1][4][#] = “Planning and evaluating business risk 51
” $xml_[Story][#][TOClev1][5][#] = “Assessing specific business risks and materiality 59
” $xml_[Story][#][TOClev1][6][#] = “Internal control 65
” $xml_[Story][#][TOClev1][7][#] = “Tests of controls 73
” $xml_[Story][#][TOClev1][8][#] = “Substantive tests of transactions and balances 81
” $xml_[Story][#][TOClev1][9][#] = “Audit sampling 97
” $xml_[Story][#][TOClev1][10][#] = “Completion and review 105
” $xml_[Story][#][TOClev1][11][#] = “The auditor’s reporting obligations 111
” $xml_[Story][#][TOClev2][0][#] = “Introduction 9
” $xml_[Story][#][TOClev2][1][#] = “Learning objectives 9
”

Very helpful. Essentially all I need do is count the number of elements in one of the arrays. How do you count array elements in PHP? Why, the count function of course. That’s easy

print “count is ” . count( $data[‘Story’][‘#’][‘TOClev1’] ) . “
“;

Of course, Rolley was thinking about using the chapter titles in a roll over or some other GUI rubbish. We should probably get the titles after all. So, simple loop through and a bit of RE replacement to get rid of the page number.

$title = $data[‘Story’][‘#’][‘TOClev1’][0][‘#’];
$title = preg_replace( ‘/s+[0-9]+/’, ”, $title );

Modify the HTML

Well that’s worked. Simple mod of existing for loop with all the above data.

Small problem, the title is being set to “Array”, seems something is going wrong. Also no code in there to get rid of the page number either. Need to look at this.

Ahh, forgot the [‘#’] needed at the end of the array de-reference. You’ve gotta love complicated, large nested associative arrays – maybe there was some benefit of all those years of Perl programming.

And here’s the “proof”, a “working” eStudyGuide block for Moodle – though it still needs a bit of polishing.

Moodle eStudyGuide block

Retrieve the name of the module

Different courses use different titles for the chapters. So far the options include: module, chapter, topic, and week. Need the block to use the appropriate name. Am wondering if the possible options should be part of the global configuration — probably. Can I be bothered? Yes, probably should.

So, add a textarea to the global config and allow those options to be entered – one to a line. Idea will be that the code will split it up into an array and work on that. A simple kludge.

Oops, not so simple. I enter data into the chapter titles and it disappears. Why?

You know it’s getting to be a long day, perhaps past when you should stop coding when you make a mistake like this. They are disappearing because you’re not displaying the variable you are storing them in when you are showing the form.

How do you split a string in PHP into an array? Spoilt for choice. I’ll go with preg_split – like my REs.

Okay, got curl checking for the various files. However, there appears to be some issues with checking to see if the retrieval actually worked. We’re returning straight away with the first title in the config, even though there should be a file for it. When it doubt, try the negation of what you just did – and that worked – ! $buffer

So, this should be a fully working. Time for some tests.

This is why you shouldn’t test. SOCL11056 is a bit different. Not all the files use the file naming format that involves the “module title”. The first one has “introduction”. Bugger. And the old Perl scripts handle it. Will have to see what the deal is there. How did that work?

Ahh, the relied on being able to access the file system. That’s not going to be possible here. That’s going to have to change. Need to talk to some folk about that. Solution can wait.

Serve PDFs with curl

This will be interesting. The problem is that the location of the eStudyGuide PDFs is behind a HTTP basic auth. Student accounts have permission to access the files, however, they will need to login again (having already logged into Moodle). Want to avoid this. One solution to this might be to have the block generate a link that points back to itself or another service. The “other service” uses curl to go through the HTTP auth, get the file and then send it back to the use.

Question: can you generate a URL to access a service provided by a block? This sounds like it might be beyond the scope of a block.

Actually, it might be as simple as putting a “standard” PHP file into the directory for the block and calling it directly from the block. This seems to work. Probably only need to pass the URL as the form element. The getPDF.php file simply takes a URL, checks that it is within the BASE_URL and sends it back to the user’s browser.

That means, I need to figure out how to:

  • send a URL via http appropriately – urlencode probably, maybe not worry about it, at least for now.
  • have the getPDF.php file access the global variables so it can get base_url

Ahh, there’s a whole rigmarole (good value though) setting up a form processing. No time to do that. Will have to leave it there.

BAM into Moodle #8 – finishing the eStudyGuide building block

The last post in this series described the start of a little project to learn more about PHP/Moodle programming in order to get BAM into Moodle. Essentially everything is done, there are two main tasks left:

  • Identify how to “properly” retrieve a file over http in PHP/Moodle and figure out how to use it.
  • Confirm the phpxml is the best way to parse XML in PHP/Moodle and figure out how to use it.

Once those are done, a rudimentary eStudyGuide block will be complete and I’ll have filled in two of the main holes in my knowledge necessary to put BAM into Moodle.

How to retrieve a file over http in PHP/Moodle

What a difference some time makes. I spent a bit of time Tuesday hunting the web and Moodle for information on this. This morning, apparently, it took 5 minutes. curl seems to be the go.

Starting with this curl tutorial – not to mention the examples here

Here’s a list of questions I think I need to answer around the use of curl, and hopefully the answers I’ve found:

  • How do you use curl to get through basic auth?
     curl_setopt($curl_handle,CULTOPT_HTTPAUTH,CURLAUTH_ANY);
    curl_setopt($curl_handle,CURLOPT_USERPWD,'username:password');

    CURLAUTH_ANY is a ?constant? that says use any HTTP auth method.

  • How do you set a mime-type on what’s going back to the client?
    The simplest examples simply get the remote file and return it to the browser. If you do this with a non-HTML file there appears to be some issues around the client handling it appropriately.

    One solution I’ve found is to use the CURLOPT_FILE option to save what is returned by curl to the file system. Then use the header and readfile functions to set everything up appropriately i.e.

    header("Content-type: image/jpeg");
    header("Content-Disposition: attachment; filename=imageName.jpg");
    readfile("tmpfile");

    Would imagine you’d have to use some sort of session variable to keep the filename unique and also remember to remove the file.

    Wonder if you can use header without the need for readfile? Yep, the works, use the CURLOPT_RETURNTRANSFER option so that the file is returned as a string and then use the following

    header("Content-type: image/jpeg");
    header("Content-Disposition: attachment; filename=imageName.jpg");
    print $buffer;

    Of course the question now becomes what if you are transferring really large files. Won’t that consume “RAM” for the web server and on a heavily used site cause some “issues”? So maybe the file option is better.

  • What are the necessary checks etc you should do when using curl?
    Seem to be all fairly standard ones, check return values etc, don’t do horrible security stuff. That said, there seems to be some variability within the existing Moodle code that is using curl – some seems to be quite anal about checks.
  • What’s TRUE in php?
    CURLOPT_BINARYTRANSFER needs to be set to TRUE for transferring binary files. What’s the numeric value for TRUE in PHP? Okay, 0 is false. Somewhat familiar.

Parsing XML

Appears, at the moment that the “xmlize” library in Moodle is the simplest method to parse XML. Produces a nested data structure with the content. Pretty similar to what is done at the moment. Is there something better?

Given that parsing XML isn’t a main requirement for BAM, I won’t bother going any further. I think I’ll be using Magpie to parse the RSS that BAM needs to manipulate.

xmlize is simple to use, looks like it is time for lunch. After lunch will be trying to code all this up. I want a working eStudyGuide block by the end of the day.

BAM into Moodle #7 – an eStudyGuide block

The last post provided an overview of what is required to put BAM into Moodle and generated a list of things I have to learn in order to implement it.

This post will tell at least some of the story of developing my first CQU Moodle block. Whether the block ever gets used in action, is beside the point. The main aim is to give me the opportunity to engage in a bit of constructionism. In particular, the block I’ve decided to have a crack at will help me learn answers to the following questions developed at the end of the last post.

  • In Moodle/PHP, how do you retrieve remote documents over HTTP? Is there a LWP::Simple equivalent?
  • In Moodle/PHP, how do you parse XML?

Introducing the eStudyGuide block

CQU has a history that includes a significant investment in print-based distance education (“The institution” section in this post offers some background). That means that this year there are at least 10,500 students enrolled at CQU studying by distance education. For many of those students the primary scaffolding of their study, which occurs off-campus, is a study guide. A print based guide written by CQU staff that summarises what they should read and do each week.

For the last couple of years CDDU has been working on a variety of innovations around these study guides. Including developing a process that produces better quality versions of study guide in both hard copy and online. Some work has been done to integrate the online study guides with the VLEs used by CQU. However, the institution has now adopted Moodle and while there is a level of integration, it’s not great.

The aim here is to develop a Moodle block (an eStudyGuide block) that allows the online version of a CQU study guide to be added to a course.

Strictly speaking the online study guide should be included in the main guts of the course home page, not as a block. But the aim here is learn more while producing something reasonably useful, without wasting too much time.

Functionality

The eStudyGuide block will display a bit of HTML that will provide a list of links to each module/chapter of the study guide. The PDFs of the study guide will be stored on a remote web server. When the block is added to the course site it will need to:

  • Identify the course, period and year associated with the current course.
    I believe that CQU currently uses the format
    COIS20025_2092

    for Moodle courses. This translates into the Term 2, 2009 offering of the course COIS20025.

  • Formulate the URL of the folder containing the e-study guide.
    This will be
    $BASE_URL/Guides/$YEAR/$PERIOD/$COURSE/
  • Check that the folder/URL exists.
  • Retrieve and parse the XML file that details the study guide.
    The XML file is produced by InDesign, the publishing system used to generate the guides. It contains information such as the number of chapters/modules, the names of the files, the titles of each module/chapter etc.

    The XML file will be protected by Basic AUTH so it will need to authenticate before getting the XML file.

  • Generate a list of links to each module/chapter.
    Initially these will be just straight URLs.

The development process

The following tells the story of the process I used to put the block together, it may not be complete, but includes the following steps:

  • Create a dummy eStudyGuide block that generates dummy HTML. DONE
  • Add in a global configuration for the block for the BASE_URL for the files. DONE
  • Get it to parse the CQU Moodle course format and use the new URL in the static HTML generated. DONE
  • Get it to retrieve the XML file.
  • Get it to parse the XML file.
  • Dynamically generate the HTML.

Getting a dummy eStudyGuide block

BAM into Moodle post #5 details some of the mechanics for this process and it in turn draws heavily on this page on the Moodle site

The process goes something like this:

  • Create the dummy block_estudy_guide.html file using the template on the Moodle site.
  • Login to Moodle, click on notifications, dummy estudy_guide up and going, eStudyGuide block added to course
  • No need to add configure options for the block, in real life the block will get the course code from some variables, there’s nothing to configure.
  • Add a specialization function to set the title.
    Eventually the title will include the course code, which is set from variables. To set the title this way we need the specialization function. Set this to a constant for now. Will replace this with the real course code in a later stage.
  • Add in the global configuration data.
    In this case the BASE_URL for the location of the eStudyGuides on the external website. Needs a file with the HTML/form for the configuration, at this stage BASE_URL. Done: config is even saving from action to action.

    Had some trouble using the global configuration data in the instance, turned out I needed the

    global

    PHP statement to bring the

    $CFG

    variable into scope.

  • Create HTML guide links
    Going to do this by creating a hard coded associative array and a for loop. The idea being is that eventually the parsed XML will replace the hard coding.
  • Convert to using block_list – not done for now
    Moodle’s block abstraction includes a special case where the block is used to display a list. Where each item has it’s own image. I don’t have easy access to an image set. Addition: Talk to Rolley about the idea of a specific image.

Parse the CQU course format

The task here is to get the Moodle course ID/code, assume it’s in CQU format and parse it into it’s constitute parts.

  • Where is the course variable?
    I’m assuming this is a global variable which is discussed here in the Moodle programming course. Ahh, there’s a global $COURSE with
    $COURSE->id

    being the Moodle ID, but there’s also entries for fullname, shortname. Assume id.

  • Modify the block to use this in the title.
    Ahh, id is the unique number id. What about shortname? That seems to be the one. At least until further confirmation.

    Need to look at REs etc in PHP. Okay, that’s over. Difficult getting use to the slightly new approaches.

  • Parse the format and stick in content variables – done.

Retrieving the XML file

Now the interesting stuff.

  • Get the full path format for the XML file
    Currently it’s BASE_URL/Guides/YEAR/PERIOD/COURSE/eStudyGuide/COURSE.xml
  • Find out how to retrieve files over HTTP within Moodle/PHP
    Well, using xref it’s possible to see within lib phpxml – probably useful for XML parsing. Couldn’t see anything else useful.

    Looking through existing modules might be useful. There’s a flickr module that uses a class called RSSCache – which looks very interesting. Which is included as part of the magpie RSS parser. This came with the default install of Moodle – so one problem solved for the broader BAM project.

And that’s where I have to leave it. Haven’t found the retrieval mechanism. But once I have it, should be straight forward.

BAM into Moodle #6 – Planning and some real coding

The previous post in this series started me along the lines of actually coding something in Moodle. It was only a pretend thing but indicated that blocks are fairly simple to implement. That previous post also pondered about the need to do some planning. Which brings me to the two main tasks for today

  1. Put some rough planning down on “paper”.
    I still don’t know enough about Moodle and its model to get into detailed planning. This planning will be a rough outline of the major tasks that need to be done to give me a heads up.
  2. Start some real coding.
    I need to develop my PHP/Moodle skills and real life tasks are the best way to do this – isn’t this in keeping with the social constructionism (or is that constructivism) at the heart of Moodle – so I’m looking for useful blocks I can produce that help me develop the skills I need for BAM.

Big up front design

Traditional software projects love to promote their rationality through their use of Big Up Front Design (BUFD). i.e. they gather all the requirements, analyse all the tasks and then come up with the perfect design. At this stage they can pass the design over to the lowly technicians who will implement the design.

Far from being rational, I’m a strong believer from both a theoretical and practice perspective, that BUFD is irrational, it’s plan stupid, even insane. It doesn’t have any basis in the cognition of people nor the nature of complex systems. It’s an approach that is certain to fail.

So anyone looking for BUFD (and there will be a few) in this project is going to be disappointed. Actually, there’s a chance some might be pleased, because for them the absence of BUFD will indicate that I’m “cowboy” coding, that I’m not being rational.

To put it simply, I don’t know enough about Moodle to engage in BUFD. I doubt there is anyone at my current institution who knows enough about Moodle, BAM and how academics might like to use BAM. The aim of the next bit of planning is to allow me to identify the necessary tasks I need to undertake to increase my level of understanding. So, that at within the last steps of the project, I’ll be able to develop a BUFD.

For a related perspective, have to love Dilbert (click on the cartoon to see a version you can read).

Dilbert.com

Planning

Some “planning” points

  • BAM will not be part of the Moodle assignment system, it will integrate with it.
    Currently, BAM is used mostly for assignments. Students post to their blogs in order to be marked and receive feedback. However, BAM is not a part of the assignment submission system at CQU. It does integrate with that system, but it’s not part of it. I plan to continue this approach.
  • One Moodle module with many activities
    My current assumption is that I’ll be able to implement a single Moodle module that will be able to provide each of the activities required to implement BAM. I suspect this will be possible, given Moodle’s strong modular nature, but I don’t know for certain.
  • The main BAM activities
    The following are a summary of the main activities that users will perform with BAM
    • Configure BAM for a course – Coordinator
      The first step in using BAM is configuring it. This requires the coordinator to provide the following information:
      • Can students register their blog?
      • Should the student blogs be mirrored?
      • For each question the students have to respond to: question title, question body. Addition: include some dates about when the question should be answered??
    • Register blog with BAM – student
      Having created a blog, the student provides a copy of their blog URL to BAM. BAM checks that it can find an RSS feed associated with that blog and also that the student hasn’t made some common mistakes (e.g. registered the WordPress home page/blog, rather than their individual blog)
    • Check progress – student
      Visiting this page allows the student to check their progress with BAM on two fronts. First, what posts from their blog has BAM matched with the required questions (Addition: maybe a good idea for BAM to show the questions). Second, they can see the marks and comments made by the markers. (Addition: would be nice for the marks/comments to be able to be posted back to the students blog as comments – perhaps a step too far at the moment.
    • Check progress – staff
      Staff can see a page that lists all of their students and gives an indication of if they’ve registered their blogs, how many entries, when the last post was and a link to the live blog.
    • Check student posts – staff
      Similar to the above, but this one gives an overview of all the required questions and the status of the student’s responses to those questions. This is the main starting place for the marking process.
    • Mark a student post – staff
      Usually linked to from the previous page (Addition: would be good to provide a cooked RSS feed of student posts for markers. Each cooked item could include a link back to the mark a post activity. Would allow markers to use an RSS reader to keep up with student posts and then mark them from there)
    • Mirror blog entries – cron
      At a configured time interval visit each the RSS feed for each individual student blog and, if updated save a new copy of the RSS feed on the Moodle server.
    • Modify student blog feed/posts – staff member
      While BAM tries to match student posts to the required questions, it doesn’t always work. This interface is for the marker to handle these problems. Essentially displays a list of all the student posts and whether or not they have been allocated to a question. Allows the marker to “de-allocate” a post or allocate it as the answer to a question.
    • Manage marking – coordinator
      The coordinator of a course, based on CQU practice, needs to be able to manage if and when marks/comments are returned to the student. Depending on how Moodle works, the coordinator may also need to be able to manage which staff are marking which students. Personally, I’d like to avoid doing this.
    • Integrate with assignments – coordinator
      Provide some form of control/management over how the data within BAM is integrated with assignments in Moodle.

Functionality uncertainty

The following is an attempt to take the major user activities listed above and summarise the major functionality required to implement these as currently used in the Webfuse version of BAM. The point is that I probably don’t know how to implement this functionality in Moodle/PHP or if it can be implemented. i.e. it’s the stuff I need to learn.

  • Configure BAM for a course
    This will be a fairly standard web application. Present a form, allow the user to modify the form, store the data in a database. I don’t see this being all that difficult. Probably a good place to start with BAM coding.
  • Register blog with BAM
    Fairly standard web application, however, once the blog URL is inserted/changed there are some additional tasks including:
    • Is the URL valid?
    • Does it exist? Can it be retrieved?
    • Does it have an attached RSS/Atom feed?
      In Perl this is done using LWP::Simple to retrieve the file and XML::Feed to check the resulting file to see if it has an attached feed and to discover what the URL for that feed is.
  • Check progress – student
    A simple web application, given the student’s details, retrieve information from the database and display it for the student.
  • Check progress – staff
    Same as the above
  • Check student posts
    Same as the above
  • Mark a student post
    Same as the above
  • Mirror blog entries
    This is perhaps the most difficult one. It goes through each student blog in courses that are currently being mirrored and
    • Compares the feed against the one saved on disk. If no change, stop now. Otherwise
    • Parse the XML of the feed into internal data structures
    • Look through all the posts in the feed looking for new ones.
    • Compare each new post against the unanswered questions, if there’s a match stick details in the marking database, ready for the marker.
  • Modify student blog posts/answers
    This one is also difficult as it shares a need to parse XML with Mirror and needs to compare that with the data in the database. Needs the XML parsing functionality.
  • Manage marking – coordinator
    Fairly straight forward web application. Need to identify if there are already ways in Moodle for storing this information.
  • Integrate with assignments
    Currently, this is essentially
    • Apply a formula to translate marks for each answer to a single mark result.
    • Copy that result to the assignment system database table.

    Need to find out how this works (the assignment database) in Moodle.

Where to know?

Some specific technical questions to answer

  • In Moodle/PHP, how do you retrieve remote documents over HTTP? Is there a LWP::Simple equivalent?
  • In Moodle/PHP, how do you parse XML?
  • Can a Moodle module support multiple activities?
  • How does “integration” with the Moodle assignment system work?
  • Exactly how do you code up a fairly standard database-backed web app/form in Moodle/PHP?

Have to come up with projects that let me learn the answers to those questions.

ePortfolios in universities – forget it?

I continue to have a high level of skepticism around the concept of universities investing in ePortfolios. I feel that it is another example of how people within universities tend to over-emphasize their importance in the scheme of things, extend the university role into areas it where it should never have been and subsequently waste resources and more importantly the time and energy of academic staff that would be better spent focusing on other aspects of improving learning and teaching. In particular, I see ePortfolios being another approach that is being over-run by the technologists alliance.

This latest restating of my prejudice arises from a find from Stephen Downes OLDaily newsletter which eventually traces back to this post from a Spanish higher school teacher which in turn draws on this post from Derek Wenmoth.

Perhaps this is some limitation of mine. I just don’t see the point of ePortfolios. What is all the fuss about?

The diagram

The core of the post is the following image that, at least for me, does a good job of giving a road map of what learner’s do within their learning: do stuff, manage the outcomes, present it to various audiences, share it with others.

ePortfolio roadmap by Perfil de Sonia Guilana

My immediate though was where in any of this is there a need for a formal institution of learning (e.g. university or school) to provide the learner with the tools to perform any of this? Why does the advent of elearning technologies change any of the relationships?

From the discussion it appears that the institution’s role can be seen in providing a VLE – shown as one place the learner might “do stuff” and also talked about one place they may “manage stuff” – and one part of “presenting stuff”. The institution’s role in “presenting stuff” is in assessment and accreditation.

Already the VLE provided by institution’s is falling behind the usability and functionality provided by external tools. Sorry, but having seen both Moodle and Blackboard up close, I’d much prefer to be using external tools. I even prefer, for functionality and ease of use reason, using Google Mail to the email system provided by institution. Given they are already falling behind, why should an institution believe it can provide a better suite of systems for the learner to “present stuff” with.

Institution’s providing portfolio systems becomes a bit more silly when you add in the observations that informal learning far outweighs formal learning and that increasingly learners will engage in formal learning from many different providers. One solution proposed to address these issues is for education systems to standardise portfolio systems so either they are all using the same one or have systems that talk to each other. Given the long history of failure of such attempts at standarisation, I’m surprised anyone still doesn’t laugh uproariously when someone suggests such a project.

What is an alternative?

Only very briefly, have to stop procrastinating and get back to the thesis, the following are some initial suggestions:

  • Ensure that institutional systems integrate/interface simply and effectively with all the other tools that make up the above diagram.
    e.g. it should be easy for learners to export the “stuff” they produce in a VLE into their own tools. As part of this, VLEs should be generating RSS feeds for most if not all of its functions. Ensure institutional systems work within global authentication systems (e.g. OpenID), rather than institutional or system specific authentication systems. (e.g. Australian Access Federation)
  • Focus institutional technology on only those tasks that the institution must perform and aim on doing it well.
    e.g. Rather than providing an ePortfolio system that helps learners present their work (something they can do themselves). Focus on implementing significant improvements on the systems around assessment and accreditation. The assignment submission systems in most VLEs is woeful, and that’s only in simple implementation details that would significantly increase the efficiency of the assessment process. Most don’t offer any support for activities that might significantly improve learning and assessment from an educational perspective.

In part, this is one aspect of the BAM project. One area it is trying to experiment with. Rather than require students to use blogs provided within an institution LMS (which are mostly really limited), allow them to use real-world blog engines and focus the institutional information technology on the assessment aspect.

BAM into Moodle #5 – Coding a block?

Up to Unit 7 of the introduction to Moodle programming course, this one is titled “Replicating a moodle block”. So the programming begins.

Creating a simple block

Looks like we’ll be doing most of the standard stuff, adding tables, using forms CRUD…Staring with this tutorial from the Moodle site. THe process

  • Create a single file in a single directory
    ~/blocks/lowercase name of block is the directory and block_lowercase name of block.php is the file.
  • File format:
    • first line is block class definition – fixed naming convention
    • class must have an init() method – initially to set to class member variables title and version
    • get_content – required before it will display something on screen

Bugger, laptop migration didn’t work 100% with permissions – XAMPP is playing silly buggers, and now so is Moodle. Ahh, CVS wasn’t brought across in the migration either. Bugger, Apple developer CDs – long time to download to get CVS…..

Okay, back to it.

Misc other stuff

  • instance_allow_config method returns true to allow instance configuration
  • config_instance.html – used to specify HTML/PHP/Moodle functions to implement form to allow configuration
  • can’t use config variables in init section of blocks
  • specialization method is automatically called after init – used to apply config i.e. to specialize the block
  • instance_allow_multiple method allows multiple instances of the block for a single course – if it returns true
  • has_config – indicates global configuration exists if it returns true – i.e. allows application of config to all instances in all courses.
  • config_global.html – specify HTML form for global configuration

Skip to Unit 9 – requirements documents

While that’s downloading, time to move on. Will need to think about a requirements document some time soon to keep the organisational hierarchy happy and it will probably not require any code. Onto unit 9 – requirements documents.

Ahh, believes a requirements document will reduce feature creep – philosophically I disagree with this. It allows the developer to ignore the user’s growing knowledge of what they’d like to do with the application. It closes off possibilities – or at least that is how it is used.

It’s all fairly standard requirements document guff, little specific to Moodle. Most of it is just really limited in being of any use in a real situation.

This section of the Moodle developer docs seems to be a bit more useful and talks about creating a specification in Moodle docs. This one is used as the example.

. Some other alternatives include: specification of Workshop 2.0, blog improvements.

This will have to come later.

What’s next?

Looks like the reinstall of Moodle is going to take a while. Running out of time today. Not all that productive – but that’s what you get for changing laptops.

At this stage, it looks like it will be time to move onto the planning and documentation. Which also implies doing a presentation at CQU to generate more requirements. The interesting part of this will be working out which of the types of plugins (or how many of them) BAM will required.

For example, for students, registering their blog and checking marking progress could be thought of as activities. Configuring BAM for a course could, as it stands, be for an assignment. However, I’m not sure I want to limit use of BAM only for assessment. Why not use it as a basis for a course blog – aggregate – oops, is this feature creep?

BAM into Moodle Step #4 – Learning more about Moodle

In the previous step I got to know a bit more about the Moodle code base, libraries and idioms. Even got to modify a bit of code – nothing much more complex than hello world. Time to continue that journey.

Roles and capabilities

Continuing my journey through Unit 6 of the Moodle Programming Unit. This time with roles and capabilities.

Apparently before v1.7 there were fixed roles. Gee, I learnt that in Webfuse in 1996 – sorry, writing historical chapters of the thesis, revisiting old ground and getting pissy about it all.

Main terms are:

  • Contexts – hierarchical “spaces” in which “permissions” apply
    • 7 of them – from broadest to most specific: CONTEXT_SYSTEM, CONTEXT_PERSONAL, CONTEXT_USER (spelled CONETXT in docs), CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE, CONTEXT_BLOCK.
    • Permissions not set within a context are inherited from a more general context.
    • Capacilities – a specific Moodle action that can be executed by a user
      • e.g. ‘moodle/course:update’ – updating course settings
      • e.g. ‘moodle/course:viewhiddencourses’ – guess?
    • Roles – a named set of all the capabilities with associated permissions (which ain’t a great explanation)
      • e.g. student, forum moderator etc.
    • Permissions – describes the ability of a role to perform a certain capability (Que?)
      • permissions for a capbility are set within a context – e.g. course.
      • Four permissions available to be set for a capability of a role within a context:
        • CAP_INHERIT – inherit permission from more general context
        • CAP_ALLOW – guess
        • CAP_PREVENT – deny the capability in the current context and more specific contexts, unless over-ridden
        • CAP_PROHIBIT – deny a capability and don’t allow it to be over-ridden.

      Functions for roles and capabilities

      • require_login – require user to be logged in and perform some other checks
      • get_context – returns a context instance object containing a context level and an instance id – e.g. CONTEXT_COURSE and a course id. This is needed to do the next step.
      • require_capability
      • has_capability

      Documentation

      PHPDoc used for code documentation – another thing to learn.

Page 1 of 3

Powered by WordPress & Theme by Anders Norén

css.php