This post summarises the work necessary to take the next step in BIM development. As summarised in the last post the plan is to implement the remaining screens roughly complete so that potential users can interact and give feedback. This included the need to start designing and populating remaining database tables.
This post focuses on the implementation of the Show student details screen. This screen is used by students to show what BIM knows about their blog. This includes # of posts, blog url, allocation of posts to questions and any marks/formal comments from academic staff. Two steps:
- Create and populate database tables.
- Code up the display function.
The question of saving data into the local file system also comes up at the end.
Create and populate database tables
Let’s start with the tables BAM uses:
BAM_CONFIGUREHas been replaced with the table
The table is used to hold details about which course is using BAM.
BAM_BLOG_STATISTICSHas been replaced by
Holds details about individual student blogs. The URLs for blog and feed, number of entries etc.
BAM_BLOG_MARKINGSuggest replacement with
Holds information about individual student posts that have been allocated to a particular question and eventually marked and formally commented on by a marker.
BAM_QUESTIONSSuggest replacement with
The idea is that the student will have to respond to some specific questions through blog posts. This table holds the detail about those questions. The title, a textual description and some details about how they can be marked (not currently used).
BAM_UNALLOCATEDWill probably replace with
This summarises the list of posts from the student that have not been allocated to a question. Used in the management process (can’t remember exactly how/why)
COURSE,PERIOD,YEAR (and A_TITLE) in all of the above is replaced by the
bim field/identifier that links back to the bim table. i.e. this is how each course/bim activity relationship is tracked.
STUD is replaced with
Looking at the following fields:
- id bigint(10)
- bim bigint(10)
- userid bigint(10) – ID into user table for student/author
- marker bigint(10) – ID into user table
- question bigint(10) – ID into bim_questions
- mark double
- status (Submitted, Marked, Released) – what about Unallocated?
- timepublished bigint(10)
- timemarked bigint(10) – seems to be a Moodle trend to use time as bigint(10)
- link varchar(255)
- post text
- comments text
At this stage, for the show student details screen. This is the only table needed. So let’s create it and do some coding.
Oh, the joys of the XMLDB editor. enum values are defined using quoted (single quotes), comma separate values.
There’s still the question of how to get it to create the tables in the database after adding them in XMLDB. Will need to follow up on that. Kludged it with the SQL generated by XMLDB.
Time to put in some dummy data so that the show student details screen will work. Will use my own blog as the dummy for this case.
Code up the display function
The current hard-coded show student details screen looks like this. This is what I need to code up.
All fairly basic stuff:
- Identify and retrieve the necessary data from the database.
- Perform any calculations to generate new data.
- Display the output.
Only problems getting used to the PHP way.
Saving data in the file system
BIM keeps a local RSS file that mirrors the students’ blog RSS. BAM worked by saving a copy of the RSS file into the file system. I plan for BIM to work the same. So, need to find out how to save data properly into the Moodle file system. Details:
- Called “moodledata” or the Moodle data directory, outside DOCROOT.
- Each course will have a sub-directory within that area.
- Each course sub-directory has 2 sub-directories:
moddatais for files associated with activities.
moddatacontains a sub-directory named for the activity module that is saving the data.
There’s much more being saved there. But this is what I’m interested in.
Seems there is a Moodle library file
/lib/rsslib.php that includes functions that allow for the creation of an RSS file from scratch, including giving the file name. Not sure this is exactly what I want here. But close. (More discussion page 189 of the Extension development book)
There are a few other examples to use. Back to that later.