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

Last but not least, we also need a dedicated function that retrieves the images for any given drag and drop module. The module ID is passed to the function which returns an array of image URLs for the module.

 

function draganddrop_getimages($draganddropid){

    $arrImage = array();

    if ($images = get_records(‘draganddrop_images’,’ddid’,$draganddropid)) {

        foreach ($images as $image) {

            $arrImage[] = $image->url;

        }

    }

    return $arrImage;

}

 

Just as the lib.php is used to define core module functions - the business rules, the view.php file is used to store display related functions. In other words, it is responsible for rendering HTML to the browser. thedraganddrop_getimages() function is called to retrieve and display the images as shown here.

 

/// Print the main part of the page

    echo(“<form method=\”post\” action=\”process.php\”>”);

    echo(“<input type=\”hidden\” name=\”course\” value=\””.$draganddrop->course.”\”>”);

    echo(“<input type=\”hidden\” name=\”ddid\” value=\””.$draganddrop->id.”\”>”);

    echo “<script type=\”text/javascript\” src=\”wz_dragdrop.js\”></script>”;

    echo “<h1>”.$draganddrop->title.”</h1>”;

    $images = draganddrop_getimages($draganddrop->id);

    for($i=0;$i<sizeof($images);$i++){

        echo “<img name=\””.$images[$i].”\” id=\””.$images[$i].

            “\” src=\””.$images[$i]. “\” width=\”240\” height=\”135\”>”;

    }

        echo “<br><br><input type=submit value=\”Submit!\”></form>”;

    echo “<script type=\”text/javascript\”>\r\n<!--\r\n”;

    echo “SET_DHTML(\””.join(“\”,\””,$images).”\”);\r\n//-->\r\n</script>”;




   Previous Page  1 2 3 4 5 6 7 8 9 10 ... Next Page   

HAVE YOUR SAY
This article is rated  Rate this article