International Developer Logo Last Updated 27.08.08 at 11.48
On Sale
This months front cover, click to see the table of contents.
Subscribe
 
TUTORIALS

Online Course Management with Moodle


  05.10.06

 

Moodle automatically interrogates the object passed to the insert_record() function in order to build the INSERT statement. The query is generated from the property names and values belonging to the object being passed through. Consequently, we need to build this object before sending it to the new function.

 

    //insert submission record

    $submission = new object();

    $submission->ddid = $ddid;

    $submission->userid = $USER->id;

    $submission->answer = $result;

    $submission->grade = $grade;

    if (!draganddrop_savesubmission($submission)){

        error(“Could not save drag and drop results.”);

    }else{

        header(“location: finished.php”);

    }

 

The error() function is part of the Moodle API, so all we need to do is include a message to be displayed whenever we encounter an error. In the absence of errors, our user will be redirected to another page which can, for example, display the correct answer and statistics on the course participants’ results.

 

Where to from here?

The module we have built in this tutorial is still bare-bones, lacking many of the features found in the core modules. For instance, there are several functions defined in the view.php page that we have overlooked. These are used to perform data analysis such as reporting on grades, activity and participation. To build a module that fully integrates into a course’s grading system, these functions need to be fleshed-out. Fortunately, there are many existing modules that can be used as templates for adding on these additional features. While the technical documentation is a little light-on, the Moodle source code is littered with excellent descriptive comments, so if you’re ever unsure of a function or feature, checking the source code can be more enlightening than searching the Web site!





   Previous Page  ... 11 12 Next Page   

HAVE YOUR SAY
This article is rated  Rate this article