Moodle Course Creation Management System

Re: Moodle Course Creation Management System (long)

by Scott Krajewski -
Number of replies: 0
Here's our system that is working well for 1.4.4.

We do the logic and gui in zope because I'm comfortable with it. But this could be in php too I'm sure.

  1. There's a basic page restricted to us admins with the following options:
    Create a single course
    Create all courses for an instructor in a year and term
    Create all courses for a department in a year and term
    Create all courses for a term [DANGER DANGER]
    Assign all instructors to courses in moodle

  2. Click one of those to go to further selections if necessary. We have a nightly dump of registrar data (course offerings, instructor assignments, course enrollments) into our postgres database that we use in zope for various projects. Having this data in a form we can easily query is key. We can't directly access the registrar database for live data. But someday we hope to. We use the idnumber field as a unique identifier for the course.

  3. Each of the first 4 selections above sets up a loop of courses. Then we go through the loop calling a course creation procedure. Here's the pseudocode:

    • Check for existence of the course, flag it if it's already there.
    • If doesn't exist, continue else abort course and display error.
      • Lookup category name in tinytable (match BIO in course designation with Biology category name)
      • See if category exists in moodle table, if so grab the id.
        If not, create the category and grab the id. If category not in tinytable or moodle then categorize course in a catchall "uncategorized" category.
    • Create the course using a SQL call to the moodle database table
      The syntax below <dtml-sqlvar > is zopespeak for variables passed to the SQL call. We're passing the category id from above, a sort order which is max+1 from mdl_courses, password is a random string (we use automatic enrollment not self-enrollment), coursetitle and courseid and shortname are built from our registrar data loop above, format is our choice for a default (weekly at the moment), blockinfo is our choice for default block setup, startdate is based on registrar data, numweeks is standard for us, we set the timestamps and leave the description blank (it would be nice to use our course catalog description here, maybe eventually)

      INSERT INTO mdl_course
      (category, sortorder, password, fullname, idnumber, shortname,
      format, showgrades, blockinfo, newsitems,
      teacher, teachers, student, students, startdate, numsections,
      maxbytes, timecreated, timemodified, summary)

      VALUES

      (<dtml-sqlvar categoryid type="int">,
      <dtml-sqlvar crs_sortorder type="int">,
      <dtml-sqlvar password type="string">,
      <dtml-sqlvar coursetitle type="string">,
      <dtml-sqlvar courseid type="string">,
      <dtml-sqlvar shortname type="string">,
      <dtml-sqlvar format type="string">,
      '1',
      <dtml-sqlvar blockinfo type="string">,
      '5',
      'Instructor','Instructors','Student','Students',
      <dtml-sqlvar startdate type="int">,
      <dtml-sqlvar numweeks type="int">,
      <dtml-sqlvar maxbytes type="int">,
      <dtml-sqlvar nowtime type="int">,
      <dtml-sqlvar nowtime type="int">,
      ' '
      )
  4. The instructor assignments are handy. It's a basic loop:
    Loop through all courses in moodle. Lookup instructors in reigstrar info.
    Convert those to moodle user ids. If instructor is not in moodle skip them for now. Check to see if they already are assigned, if not, assign them.

    These are basic SQL lookups and calls to the moodle tables and our tables. We use the idnumber to uniquely identify people in moodle.
Since the idnumber for the course and individual are key, we've locked both of those in the interface. In 1.5 I'll be able to lock the user idnumber field (we're 1.4.4). For the courses I just did a simple hack to edit.html to restrict editing the idnumber to admins.
<tr valign=top>
<td align="right"><P><?php print_string("idnumber") ?>:</td>

<?php
if( isadmin()){

echo "<td><input type=\"text\" name=\"idnumber\" maxlength=\"100\" size=\"10\" value=\"".$form->idnumber."\">";

} else {

echo "<td><input type=\"hidden\" name=\"idnumber\" value=\"".$form->idnumber."\">".$form->idnumber;

}
?>
<?php helpbutton("courseidnumber", get_string("idnumber")) ?>
<?php if (isset($err["idnumber"])) formerr($err["idnumber"]); ?>
</td>
</tr>