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://davidtjones.wordpress.com/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.