In the last post I’d gotten started having the show student details screen actually getting data from the database. One data source this screen needs is not in the database, it’s in the RSS file from the student’s blog that is mirrored on the Moodle site. This post talks about the process about how BIM will be saving, reading and using that RSS file in its operation.
There will be at least two parts:
- Identifying the location for the RSS file (and putting some dummy ones there).
- Manipulating the RSS files.
As discovered in the last post Moodle works with a directory referred to as moodledata as the file system store. Each course has its own area in a sub-directory based on the course id.
So, the obvious plan would be to put a
bim directory in the course sub-directory. Since there may be the case that more than one BIM activity could be added to a course, I’ll put another layer of sub-directories in place based on the bim id. At that stage, we can use the
userid, actually, I’m going to go with username (I’m still of the opinion that a support person may still look at the file structure and that the username – which @ my institution is the student number – will be more meaningful than the uid) as the filename and put a
.xml extension on the end.
So, the path for my test user (username=david) on my test course (cid=4) and my test BIM activity (bim id=1) would be
Which means I can put some test data into the file.
Sadly, at this stage, the RAW book I’ve been using only has information about using a Moodle API for constructing RSS files from scratch. For BIM, we need to be able to use existing RSS files (also ATOM and other type of feeds) from existing blogs. So I don’t think this is appropriate. Need to find what alternatives exist within the Moodle community.
This won’t be the only place I’ll have to manipulate a student’s feed. So I should abstract this out. Straight procedural and into a library? Or, go object oriented? All my recent experience has been OO, but new to PHP. Might stick with procedural for now.
Next problem is getting SimplePie to parse the feed for this blog as a test. It appears that SimplePie doesn’t like control characters in a feed. The problem here. Remove those and it works fine. To do: Figure out how to handle these cleanly. Need to make this robust.
The SimplePie API is documented online. It has a
get_feed_tags function that should fulfill one of the needs for the registration process.
The show student details screen is now almost fully working – sans any of the normal sanity checking and a few bits to tidy up. Some progress being made.