<DT> Languages
<DD> German and Italian have been added! Many thanks to the translators (see the credits).
+<DT> Reading module ===> Resource module
+<DD> After much thought and a vote of support (21 "yes" to 6 "no") on the "Using Moodle"
+ web site I changed the name of the "reading" module to "resource" (at the code level
+ and also the English language pack). Better now than later.
+
+ This more generic name will be more meaningful to more people and opens the way to
+ some real development on a resource library.
+ <BR><BR>
+ I don't anticipate ever having to change a module name again! :-)
+
<DT> Other additions
<DD> An admin script to totally delete the Moodle data directory has been included (admin/delete.php)
for people who need to tear down a Moodle installation but don't have root access on their
$adminicon[]="<IMG SRC=\"$CFG->wwwroot/files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$admindata[]="<A HREF=\"$CFG->wwwroot/doc/view.php?id=$course->id&file=teacher.html\">".get_string("help")."...</A>";
- $adminicon[]="<IMG SRC=\"$CFG->wwwroot/mod/reading/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
+ $adminicon[]="<IMG SRC=\"$CFG->wwwroot/mod/resource/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
if ($teacherforum = forum_get_course_forum($course->id, "teacher")) {
// included from view.php
include_once("$CFG->dirroot/mod/forum/lib.php");
- include_once("$CFG->dirroot/mod/reading/lib.php");
+ include_once("$CFG->dirroot/mod/resource/lib.php");
?>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<P><strong><a name="activities" id="activities"></a>Learning Activities</strong></P>\r
<blockquote> \r
<p>These are by far the most important modules, and reside in the 'mod' directory. \r
- There are six default modules: assignment, choice, forum, journal, reading, \r
+ There are seven default modules: assignment, choice, forum, journal, quiz, resource, \r
and survey. Each module is in a separate subdirectory and consists of the \r
following mandatory elements (plus extra scripts unique to each module):</p>\r
<ul>\r
<li>choice.php - strings for choice module</li>\r
<li>forum.php - strings for forum module</li>\r
<li>journal.php - strings for journal module </li>\r
- <li>reading.php - strings for reading module</li>\r
- <li>survey.php - strings for reading module</li>\r
+ <li>quiz.php - strings for quiz module</li>\r
+ <li>resource.php - strings for resource module</li>\r
+ <li>survey.php - strings for survey module</li>\r
<li>.... plus other modules if any.<br>\r
<br>\r
A string is called from these files using the <strong><em>get_string()</em></strong><em> \r
<H2>Features</H2>\r
\r
Here is a big list of some of the features in Moodle 1.0: \r
-<UL><LI>Supports a social constructionist pedagogy (collaboration, activities, critical reflection, etc)</LI><LI>Suitable for 100% online classes as well as supplementing face-to-face learning<LI>Simple, lightweight, browser-compatible interface</LI><LI>Plug-in "themes" allow you to customise the colours, fonts, layout etc</LI><LI>Easy to install on most platforms</LI><LI>Easy administration - students can create their own accounts. Email addresses are verified.</LI><LI>One account works for the whole server</LI><LI>Security - teachers can add an "enrolment key" to their courses to keep out non-students. They can give out this key face-to-face or via personal email etc</LI><LI>Students are encouraged to build an online profile including photos, description etc</LI><LI>Every user can specify their own timezone, and every date in Moodle is translated to that timezone (eg posting dates, assignment due dates etc)</LI><LI>Choice of course formats such as by week, by topic or a discussion-focussed social format</LI><LI>Flexible array of course modules - Forums, Journals, Readings, Choices, Surveys, Assignments.</LI><LI>New modules can be written and plugged in to existing Moodle installations</LI><LI>The code is clearly-written PHP under a GPL license - easy to modify and localise</LI><LI>Full database abstraction supports all major brands of database (except for initial table definition)</LI><LI>Ready for internationalisation - supports plug-in languages and locale-based date formats etc</LI><LI>Mail integration - copies of forum posts, teacher feedback etc can be mailed in HTML or plain text.</LI><LI>Recent changes to the course since the last login are displayed on the course home page</LI><LI>Full user logging and tracking - activity reports for each student are available with graphs and details about each module (last access, number of times read) as well as a detailed "story" of each students involvement including postings, journal entries etc on one page.</LI>\r
+<UL><LI>Supports a social constructionist pedagogy (collaboration, activities, critical reflection, etc)</LI><LI>Suitable for 100% online classes as well as supplementing face-to-face learning<LI>Simple, lightweight, browser-compatible interface</LI><LI>Plug-in "themes" allow you to customise the colours, fonts, layout etc</LI><LI>Easy to install on most platforms</LI><LI>Easy administration - students can create their own accounts. Email addresses are verified.</LI><LI>One account works for the whole server</LI><LI>Security - teachers can add an "enrolment key" to their courses to keep out non-students. They can give out this key face-to-face or via personal email etc</LI><LI>Students are encouraged to build an online profile including photos, description etc</LI><LI>Every user can specify their own timezone, and every date in Moodle is translated to that timezone (eg posting dates, assignment due dates etc)</LI><LI>Choice of course formats such as by week, by topic or a discussion-focussed social format</LI><LI>Flexible array of course modules - Forums, Journals, Resources, Choices, Surveys, Assignments.</LI><LI>New modules can be written and plugged in to existing Moodle installations</LI><LI>The code is clearly-written PHP under a GPL license - easy to modify and localise</LI><LI>Full database abstraction supports all major brands of database (except for initial table definition)</LI><LI>Ready for internationalisation - supports plug-in languages and locale-based date formats etc</LI><LI>Mail integration - copies of forum posts, teacher feedback etc can be mailed in HTML or plain text.</LI><LI>Recent changes to the course since the last login are displayed on the course home page</LI><LI>Full user logging and tracking - activity reports for each student are available with graphs and details about each module (last access, number of times read) as well as a detailed "story" of each students involvement including postings, journal entries etc on one page.</LI>\r
</UL>\r
<B>Forum Module</B>\r
<UL><LI>Different types of forums are available, such as teacher-only, course news, open-to-all, and one-thread-per-user.</LI><LI>All postings have the authors photo attached.</LI><LI>Discussions can be viewed nested, flat or threaded, oldest or newest first.</LI><LI>Individual forums can be subscribed to by each person so that copies are forwarded via email, or the teacher can force subscription for all</LI>\r
</UL>\r
<B>Survey Module</B>\r
<UL><LI>Built-in surveys (COLLES, ATTLS) have been proven as instruments for analysing online classes</LI><LI>Online survey reports always available, including many graphs. Data is downloadable as an Excel spreadsheet or CSV text file.</LI><LI>Survey interface prevents partly-finished surveys.</LI><LI>Feedback is provided to the student of their results compared to the class averages</UL>\r
-<B>Readings Module</B>\r
+<B>Resource Module</B>\r
<UL><LI>Supports display of any electronic content</LI><LI>Files can be uploaded and managed on the server, or created on the fly using web forms (text or HTML)</LI><LI>External content on the web can be linked to or seamlessly included within the course interface.</LI></UL>\r
<B>Choice Module</B>\r
<UL><LI>Like a poll. Can either be used to vote on something, or to get feedback from every student (eg research consent)</LI></UL>\r
<LI>Full user account management (eg connection to external databases, import/export etc)\r
<LI>Full grade management\r
<LI>Ability to define groups and group work\r
- <LI>Automatic linking in texts to uploaded readings (like Wiki)\r
+ <LI>Automatic linking in texts to uploaded resources (like Wiki)\r
<LI>Online support for teachers to design and maintain classes\r
<LI>Online support for students in collaboration processes\r
</UL>\r
<p align="center"><img src="pix/files.jpg" width="400" height="347"></p>\r
<p> </p>\r
<p>This interface is only available to teachers - it is not accessible by students. \r
- Individual files are made available to students later on (as "Readings" \r
+ Individual files are made available to students later on (as "Resources" \r
- see the next section).</p>\r
<p>As you can see in the screenshot, files are listed alongside subdirectories. \r
You can create any number of subdirectories to organise your files and move \r
with the same name as an existing file it will automatically be overwritten.</p>\r
<p>A final note: if your content resides out on the web then you don't need \r
to upload the files at all - you can link directly to them from inside the \r
- course (see the Readings module and the next section).</p>\r
+ course (see the Resources module and the next section).</p>\r
<HR>\r
</blockquote>\r
<H3><A NAME="activities"></A>Setting up activities</H3>\r
and students will receive an automatic email informing them of your feedback.</dd>\r
<BR>\r
<BR>\r
- <dt><strong>Reading</strong></dt>\r
- <dd>Readings are the content of your course. Each reading can be any file \r
+ <dt><strong>Resource</strong></dt>\r
+ <dd>Resources are the content of your course. Each resource can be any file \r
you have uploaded or can point to using a URL. You can also maintain simple text-based pages by typing them\r
directly into a form.</dd>\r
<BR>\r
require("config.php");
include("course/lib.php");
- include("mod/reading/lib.php");
+ include("mod/resource/lib.php");
include("mod/forum/lib.php");
if (! $site = get_site()) {
<?PHP // $Id$
#------------------------------------------------------------
-$string['modulename'] = "Reading";
-$string['modulenameplural'] = "Readings";
+$string['modulename'] = "Resource";
+$string['modulenameplural'] = "Resources";
#------------------------------------------------------------
-$string['addreading'] = "Add reading";
-$string['editingareading'] = "Editing a reading";
+$string['addresource'] = "Add resource";
+$string['editingaresource'] = "Editing a resource";
$string['example'] = "Example";
$string['examplereference'] = "Tobin, K. & Tippins, D (1993) Constructivism as a Referent for Teaching and Learning. In: K. Tobin (Ed) The Practice of Constructivism in Science Education, pp 3-21, Lawrence-Erlbaum, Hillsdale, NJ.";
$string['exampleurl'] = "http://www.example.com/somedirectory/somefile.html";
$string['notefile'] = "To upload more files into the course (so they appear in this list) use the
<A HREF=\$a >File Manager</A>.";
$string['notypechosen'] = "You need to choose a type. Use your back button to go back and retry.";
-$string['readingtype'] = "Type of resource";
-$string['readingtype1'] = "Reference";
-$string['readingtype2'] = "Web Page";
-$string['readingtype3'] = "Uploaded File";
-$string['readingtype4'] = "Plain text";
-$string['readingtype5'] = "Web Link";
-$string['readingtype6'] = "HTML text";
+$string['resourcetype'] = "Type of resource";
+$string['resourcetype1'] = "Reference";
+$string['resourcetype2'] = "Web Page";
+$string['resourcetype3'] = "Uploaded File";
+$string['resourcetype4'] = "Plain text";
+$string['resourcetype5'] = "Web Link";
+$string['resourcetype6'] = "HTML text";
?>
if ($oldversion < 2002101001) {
execute_sql(" ALTER TABLE `user` ADD `htmleditor` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL AFTER `maildisplay` ");
}
+ if ($oldversion < 2002101701) {
+ execute_sql(" ALTER TABLE `reading` RENAME `resource` "); // Small line with big consequences!
+ execute_sql(" DELETE FROM `log_display` WHERE module = 'reading'");
+ execute_sql(" INSERT INTO log_display VALUES ('resource', 'view', 'resource', 'name') ");
+ execute_sql(" UPDATE log SET module = 'resource' WHERE module = 'reading' ");
+ execute_sql(" UPDATE modules SET name = 'resource' WHERE name = 'reading' ");
+ }
return true;
}
// any particular student has been doing.
//
// course = the course id
-// module = forum, journal, reading, course, user etc
+// module = forum, journal, resource, course, user etc
// action = view, edit, post (often but not always the same as the file.php)
// url = the file and parameters used to see the results of the action
// info = additional description information
--- /dev/null
+<?PHP // $Id$
+
+function resource_upgrade($oldversion) {
+// This function does anything necessary to upgrade
+// older versions to match current functionality
+
+ return true;
+}
+
+
+?>
+
--- /dev/null
+# phpMyAdmin MySQL-Dump\r
+# version 2.2.1\r
+# http://phpwizard.net/phpMyAdmin/\r
+# http://phpmyadmin.sourceforge.net/ (download page)\r
+#\r
+# Host: localhost\r
+# Generation Time: Nov 14, 2001 at 04:43 PM\r
+# Server version: 3.23.36\r
+# PHP Version: 4.0.6\r
+# Database : `moodle`\r
+# --------------------------------------------------------\r
+\r
+#\r
+# Table structure for table `resource`\r
+#\r
+\r
+CREATE TABLE resource (\r
+ id int(10) unsigned NOT NULL auto_increment,\r
+ course tinyint(10) unsigned NOT NULL default '0',\r
+ name varchar(255) NOT NULL default '',\r
+ type tinyint(4) NOT NULL default '0',\r
+ reference varchar(255) default NULL,\r
+ summary text NOT NULL,\r
+ alltext text NOT NULL,\r
+ timemodified int(10) unsigned NOT NULL default '0',\r
+ PRIMARY KEY (id),\r
+ UNIQUE KEY id (id)\r
+) TYPE=MyISAM;\r
+\r
+\r
+#\r
+# Dumping data for table `log_display`\r
+#\r
+\r
+INSERT INTO log_display VALUES ('resource', 'view', 'resource', 'name');\r
--- /dev/null
+<?PHP // $Id$
+
+ require("../../config.php");
+ require("lib.php");
+
+ require_login();
+
+ $usehtmleditor = can_use_richtext_editor();
+
+ if (match_referer("$destination") && isset($HTTP_POST_VARS)) { // form submitted
+ $form = (object)$HTTP_POST_VARS;
+
+ if (! $course = get_record("course", "id", $form->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course->id);
+
+ if (!isteacher($course->id)) {
+ error("You can't modify this course!");
+ }
+
+ $strediting = get_string("editingaresource", "resource");
+ $strname = get_string("name");
+
+ print_header("$course->shortname: $strediting", "$course->shortname: $strediting",
+ "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> $strediting");
+
+ if (!$form->name or !$form->type or !$form->summary) {
+ error(get_string("filloutallfields"), $HTTP_REFERER);
+ }
+
+ print_simple_box_start("center", "", "$THEME->cellheading");
+
+ if ($usehtmleditor and $form->type == HTML) {
+ $onsubmit = "onsubmit=\"copyrichtext(theform.alltext);\"";
+ }
+ echo "<FORM NAME=theform METHOD=post $onsubmit ACTION=\"$form->destination\">";
+ echo "<TABLE CELLPADDING=5 ALIGN=CENTER>";
+ echo "<TR><TD ALIGN=right NOWRAP><P><B>$strname:</B></P></TD><TD><P>$form->name</P></A></TD></TR>";
+
+ $strtypename = $RESOURCE_TYPE["$form->type"];
+ $strexample = get_string("example", "resource");
+
+ switch ($form->type) {
+ case REFERENCE:
+ $strexamplereference = get_string("examplereference", "resource");
+ ?>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B><?=$strtypename?>:</B></P>
+ </TD>
+ <TD>
+ <TEXTAREA NAME="reference" ROWS=3 COLS=50 WRAP="virtual"><? p($form->reference) ?></TEXTAREA>
+ </TD>
+ </TR>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B>(<?=$strexample?>)</B></P>
+ </TD>
+ <TD>
+ <P><?=$strexamplereference?></P>
+ </TD>
+ </TR>
+
+ <?
+ break;
+
+ case WEBPAGE:
+ case WEBLINK:
+ $strexampleurl = get_string("exampleurl", "resource");
+ ?>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B><?=$strtypename?>:</B></P>
+ </TD>
+ <TD>
+ <INPUT NAME="reference" SIZE=60 VALUE="<? p($form->reference) ?>">
+ </TD>
+ </TR>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B>(<?=$strexample?>)</B></P>
+ </TD>
+ <TD>
+ <P><?=$strexampleurl?>
+ </P>
+ </TD>
+ </TR>
+
+ <?
+ break;
+
+ case UPLOADEDFILE:
+ $strfilename = get_string("filename", "resource");
+ $strnote = get_string("note", "resource");
+ $strnotefile = get_string("notefile", "resource", "$CFG->wwwroot/files/index.php?id=$course->id");
+ ?>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B><?=$strfilename?>:</B></P>
+ </TD>
+ <TD>
+ <?
+ $rootdir = $CFG->dataroot."/".$course->id;
+ $coursedirs = get_directory_list($rootdir, $CFG->moddata);
+ foreach ($coursedirs as $dir) {
+ $options["$dir"] = $dir;
+ }
+ choose_from_menu ($options, "reference", $form->reference);
+ ?>
+ </TD>
+ </TR>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B><?=$strnote?>:</B></P>
+ </TD>
+ <TD>
+ <P><?=$strnotefile?>
+ </P>
+ </TD>
+ </TR>
+
+ <?
+ break;
+
+ case PLAINTEXT:
+ $strfulltext = get_string("fulltext", "resource");
+ ?>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B><?=$strfulltext?>:</B></P>
+ <BR><? helpbutton("text", get_string("helptext")) ?>
+ </TD>
+ <TD>
+ <TEXTAREA NAME="alltext" ROWS=20 COLS=50 WRAP="virtual"><? p($form->alltext) ?></TEXTAREA>
+ </TD>
+ </TR>
+ <?
+ break;
+
+ case HTML:
+ $strhtmlfragment = get_string("htmlfragment", "resource");
+ ?>
+ <TR VALIGN=top>
+ <TD ALIGN=right NOWRAP>
+ <P><B><?=$strhtmlfragment?>:</B></P>
+ <? if ($usehtmleditor) { ?>
+ <BR><? helpbutton("richtext", get_string("helprichtext")) ?>
+ <? } else { ?>
+ <BR><? helpbutton("html", get_string("helphtml")) ?>
+ <? } ?>
+ </TD>
+ <TD>
+ <? print_textarea($usehtmleditor, 20, 50, 680, 400, "alltext", $form->alltext); ?>
+ </TD>
+ </TR>
+ <?
+ break;
+
+ default:
+ error(get_string("notypechosen", "resource"), $HTTP_REFERER);
+ break;
+ }
+
+ ?>
+ </TABLE>
+ <input type="hidden" name=summary value="<? p($form->summary) ?>">
+ <input type="hidden" name=type value="<? p($form->type) ?>">
+ <input type="hidden" name=name value="<? p($form->name) ?>">
+
+ <input type="hidden" name=course value="<? p($form->course) ?>">
+ <input type="hidden" name=coursemodule value="<? p($form->coursemodule) ?>">
+ <input type="hidden" name=section value="<? p($form->section) ?>">
+ <input type="hidden" name=module value="<? p($form->module) ?>">
+ <input type="hidden" name=modulename value="<? p($form->modulename) ?>">
+ <input type="hidden" name=instance value="<? p($form->instance) ?>">
+ <input type="hidden" name=mode value="<? p($form->mode) ?>">
+ <CENTER>
+ <input type="submit" value="<? print_string("savechanges") ?>">
+ <input type="submit" name=cancel value="<? print_string("cancel") ?>">
+ </CENTER>
+ </FORM>
+<?
+ if ($usehtmleditor) {
+ print_richedit_javascript("theform", "alltext", "yes");
+ }
+ print_simple_box_end();
+ print_footer($course);
+
+ } else {
+ error("This script was called incorrectly");
+ }
+?>
--- /dev/null
+<?PHP // $Id$
+
+ require("../../config.php");
+
+ require_variable($id); // course
+
+ if (! $course = get_record("course", "id", $id)) {
+ error("Course ID is incorrect");
+ }
+
+ if ($course->category) {
+ require_login($course->id);
+ $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+ }
+
+ add_to_log($course->id, "resource", "view all", "index.php?id=$course->id", "");
+
+ $strresource = get_string("modulename", "resource");
+ $strresources = get_string("modulenameplural", "resource");
+ $strweek = get_string("week");
+ $strtopic = get_string("topic");
+ $strname = get_string("name");
+ $strsummary = get_string("summary");
+ $strlastmodified = get_string("lastmodified");
+
+ print_header("$course->shortname: $strresources", "$course->fullname", "$navigation $strresources");
+
+ if ($course->format == "weeks" or $course->format == "topics") {
+ $sortorder = "cw.section ASC";
+ } else {
+ $sortorder = "m.timemodified DESC";
+ }
+
+ if (! $resources = get_all_instances_in_course("resource", $course->id, $sortorder)) {
+ notice("There are no resources", "../../course/view.php?id=$course->id");
+ exit;
+ }
+
+ if ($course->format == "weeks") {
+ $table->head = array ($strweek, $strname, $strsummary);
+ $table->align = array ("CENTER", "LEFT", "LEFT");
+ } else if ($course->format == "topics") {
+ $table->head = array ($strtopic, $strname, $strsummary);
+ $table->align = array ("CENTER", "LEFT", "LEFT");
+ } else {
+ $table->head = array ($strlastmodified, $strname, $strsummary);
+ $table->align = array ("LEFT", "LEFT", "LEFT");
+ }
+
+ foreach ($resources as $resource) {
+
+ $tt = "";
+ if ($course->format == "weeks" or $course->format == "topics") {
+ if ($resource->section) {
+ $tt = "$resource->section";
+ }
+ } else {
+ $tt = "<FONT SIZE=1>".userdate($resource->timemodified);
+ }
+ $table->data[] = array ($tt, "<A HREF=\"view.php?id=$resource->coursemodule\">$resource->name</A>",
+ text_to_html($resource->summary) );
+ }
+
+ echo "<BR>";
+
+ print_table($table);
+
+ print_footer($course);
+
+
+?>
+
--- /dev/null
+<?PHP // $Id$
+
+define("REFERENCE", "1");
+define("WEBPAGE", "2");
+define("UPLOADEDFILE","3");
+define("PLAINTEXT", "4");
+define("WEBLINK", "5");
+define("HTML", "6");
+
+$RESOURCE_TYPE = array (REFERENCE => get_string("resourcetype1", "resource"),
+ WEBPAGE => get_string("resourcetype2", "resource"),
+ UPLOADEDFILE => get_string("resourcetype3", "resource"),
+ PLAINTEXT => get_string("resourcetype4", "resource"),
+ WEBLINK => get_string("resourcetype5", "resource"),
+ HTML => get_string("resourcetype6", "resource") );
+
+function resource_list_all_resources($courseid=0, $sort="name ASC", $recent=0) {
+ // Returns list of all resource links in an array of strings
+
+ global $CFG, $USER;
+
+ if ($courseid) {
+ if (! $course = get_record("course", "id", $courseid)) {
+ error("Could not find the specified course");
+ }
+
+ require_login($course->id);
+
+ } else {
+ if (! $course = get_record("course", "category", 0)) {
+ error("Could not find a top-level course!");
+ }
+ }
+
+ if ($resources = get_all_instances_in_course("resource", $course->id, $sort)) {
+ foreach ($resources as $resource) {
+ $link = "<A HREF=\"$CFG->wwwroot/mod/resource/view.php?id=$resource->coursemodule\">$resource->name</A>";
+ if ($USER->editing) {
+ $link .= "
+ <A HREF=\"$CFG->wwwroot/course/mod.php?delete=$resource->coursemodule\"><IMG
+ SRC=\"$CFG->wwwroot/pix/t/delete.gif\" BORDER=0 ALT=Delete></A>
+ <A HREF=\"$CFG->wwwroot/course/mod.php?update=$resource->coursemodule\"><IMG
+ SRC=\"$CFG->wwwroot/pix/t/edit.gif\" BORDER=0 ALT=Update></A>";
+ }
+ $links[] = $link;
+ }
+ }
+
+ return $links;
+}
+
+
+function resource_user_outline($course, $user, $mod, $resource) {
+ if ($logs = get_records_sql("SELECT * FROM log
+ WHERE user='$user->id' AND module='resource'
+ AND action='view' AND info='$resource->id'
+ ORDER BY time ASC")) {
+
+ $numviews = count($logs);
+ $lastlog = array_pop($logs);
+
+ $result->info = get_string("numviews", "", $numviews);
+ $result->time = $lastlog->time;
+
+ return $result;
+ }
+ return NULL;
+}
+
+
+function resource_user_complete($course, $user, $mod, $resource) {
+ global $CFG, $THEME;
+
+ if ($logs = get_records_sql("SELECT * FROM log
+ WHERE user='$user->id' AND module='resource'
+ AND action='view' AND info='$resource->id'
+ ORDER BY time ASC")) {
+
+ $numviews = count($logs);
+ $lastlog = array_pop($logs);
+
+ $strmostrecently = get_string("mostrecently");
+ $strnumviews = get_string("numviews", "", $numviews);
+
+ echo "$strnumviews - $strmostrecently ".userdate($lastlog->time);
+
+ } else {
+ print_string("neverread", "resource");
+ }
+}
+
+function resource_add_instance($resource) {
+// Given an object containing all the necessary data,
+// (defined by the form in mod.html) this function
+// will create a new instance and return the id number
+// of the new instance.
+
+ $resource->timemodified = time();
+
+ return insert_record("resource", $resource);
+}
+
+
+function resource_update_instance($resource) {
+// Given an object containing all the necessary data,
+// (defined by the form in mod.html) this function
+// will update an existing instance with new data.
+
+ $resource->id = $resource->instance;
+ $resource->timemodified = time();
+
+ return update_record("resource", $resource);
+}
+
+
+function resource_delete_instance($id) {
+// Given an ID of an instance of this module,
+// this function will permanently delete the instance
+// and any data that depends on it.
+
+ if (! $resource = get_record("resource", "id", "$id")) {
+ return false;
+ }
+
+ $result = true;
+
+ if (! delete_records("resource", "id", "$resource->id")) {
+ $result = false;
+ }
+
+ return $result;
+}
+
+
+?>
--- /dev/null
+<form name="form" method="post" action="<?=$CFG->wwwroot?>/mod/resource/details.php">
+<table cellpadding=5>
+<tr valign=top>
+ <td align=right><P><B><? print_string("name") ?>:</B></P></TD>
+ <td>
+ <input type="text" name="name" size=50 value="<? p($form->name) ?>">
+ </td>
+</tr>
+<tr valign=top>
+ <td align=right><P><B><? print_string("resourcetype", "resource") ?>:</B></P></TD>
+ <td>
+ <?
+ require("$CFG->dirroot/mod/resource/lib.php");
+ asort($RESOURCE_TYPE);
+ if (!$form->type) {
+ $form->type = 4;
+ }
+ choose_from_menu($RESOURCE_TYPE, "type", $form->type, "");
+ helpbutton("resourcetype", get_string("resourcetype", "resource"), "resource");
+ ?>
+
+ </td>
+</tr>
+<tr valign=top>
+ <td align=right><P><B><? print_string("summary") ?>:</B></P></TD>
+ <td>
+ <textarea name="summary" rows=5 cols=50 wrap="virtual"><? p($form->summary) ?></textarea>
+ <? helpbutton("summary", get_string("summary"), "resource"); ?>
+ </td>
+</tr>
+</table>
+<CENTER>
+<input type="hidden" name=reference value="<? p($form->reference) ?>">
+<input type="hidden" name=alltext value="<? p($form->alltext) ?>">
+
+<input type="hidden" name=course value="<? p($form->course) ?>">
+<input type="hidden" name=coursemodule value="<? p($form->coursemodule) ?>">
+<input type="hidden" name=section value="<? p($form->section) ?>">
+<input type="hidden" name=module value="<? p($form->module) ?>">
+<input type="hidden" name=modulename value="<? p($form->modulename) ?>">
+<input type="hidden" name=instance value="<? p($form->instance) ?>">
+<input type="hidden" name=mode value="<? p($form->mode) ?>">
+<input type="hidden" name=destination value="<?=$ME ?>">
+<input type="submit" value="<? print_string("continue") ?>">
+</CENTER>
+</FORM>
--- /dev/null
+<?PHP // $Id$
+
+////////////////////////////////////////////////////////////////////////////////
+// Code fragment to define the module version etc.
+// This fragment is called by /admin/index.php
+////////////////////////////////////////////////////////////////////////////////
+
+$module->version = 2002101700;
+$module->cron = 0;
+
+?>
--- /dev/null
+<?PHP // $Id$
+
+ require("../../config.php");
+ require("lib.php");
+
+ require_variable($id); // Course Module ID
+
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $resource = get_record("resource", "id", $cm->instance)) {
+ error("Resource ID was incorrect");
+ }
+
+ $strresource = get_string("modulename", "resource");
+ $strresources = get_string("modulenameplural", "resource");
+ $strlastmodified = get_string("lastmodified");
+
+ if ($course->category) {
+ require_login($course->id);
+ $navigation = "<A TARGET=_top HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
+ <A TARGET=_top HREF=\"index.php?id=$course->id\">$strresources</A> ->";
+ } else {
+ $navigation = "<A TARGET=_top HREF=\"index.php?id=$course->id\">$strresources</A> ->";
+ }
+
+ switch ($resource->type) {
+ case 1: // Reference (eg Journal or Book etc)
+ add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+ print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strresource));
+
+ print_simple_box($resource->reference, "center");
+ echo "<CENTER><P>";
+ echo text_to_html($resource->summary);
+ echo "</P>";
+ echo "<P> </P>";
+ echo "<P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P>";
+ echo "</CENTER>";
+ print_footer($course);
+ break;
+
+ case 5: // Web Link
+ add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+ redirect($resource->reference);
+ break;
+
+ case 2: // Web Page
+ if ($frameset) {
+ print_header("$course->shortname: $resource->name", "$course->fullname",
+ "$navigation <A TARGET=_top HREF=\"$resource->reference\" TITLE=\"$resource->reference\">$resource->name</A>",
+ "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
+
+ } else {
+ add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+ echo "<HEAD><TITLE>$course->shortname: $resource->name</TITLE></HEAD>\n";
+ echo "<FRAMESET ROWS=130,*>";
+ echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=true\">";
+ echo "<FRAME SRC=\"$resource->reference\">";
+ echo "</FRAMESET>";
+ }
+ break;
+
+ case 3: // Uploaded File
+ if ($frameset) {
+ print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
+
+ } else {
+ add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+ if ($CFG->slasharguments) {
+ $ffurl = "file.php/$course->id/$resource->reference";
+ } else {
+ $ffurl = "file.php?file=/$course->id/$resource->reference";
+ }
+ echo "<HEAD><TITLE>$course->shortname: $resource->name</TITLE></HEAD>\n";
+ echo "<FRAMESET ROWS=130,*>";
+ echo "<FRAME SRC=\"view.php?id=$cm->id&frameset=true\">";
+ echo "<FRAME SRC=\"$CFG->wwwroot/$ffurl\">";
+ echo "</FRAMESET>";
+ }
+ break;
+
+ case 4: // Plain text
+ add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+ print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strresource));
+
+ print_simple_box(text_to_html($resource->alltext), "CENTER", "", "$THEME->cellcontent", "20");
+
+ echo "<CENTER><P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P></CENTER>";
+
+ print_footer($course);
+ break;
+
+ case 6: // HTML text
+ add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+ print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strresource));
+
+ print_simple_box_start("CENTER", "", "$THEME->cellcontent", "20");
+
+ echo $resource->alltext;
+
+ print_simple_box_end();
+
+ echo "<CENTER><P><FONT SIZE=1>$strlastmodified: ".userdate($resource->timemodified)."</P></CENTER>";
+
+ print_footer($course);
+ break;
+
+ default:
+ print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
+ "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ print_heading($resource->name);
+
+ print_simple_box("Error: unknown type of resource", "center");
+
+ print_footer($course);
+ break;
+ }
+
+
+?>
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2002101700; // The current version is a date (YYYYMMDDXX)
+$version = 2002101701; // The current version is a date (YYYYMMDDXX)
$release = "1.0.6 dev 2"; // User-friendly version number