Permalink
Browse files

changes to database and most scripts to allow enhancements for HotPot…

… v2.1

  - click-by-click reporting
  - manipulate "chains" of hotpot activities
  - standardized reporting across all quiz types
  - several smaller features
  • Loading branch information...
1 parent 1c02f70 commit 410229b6047f7cd45fd002c85f13ab8709c6a439 gbateson committed Sep 16, 2005
View
@@ -1,5 +1,10 @@
-This is v2.0.8 of the HotPot module
- It has been tested on Moodle 1.1 thru 1.5, MySQL and PostGres7 databases and PHP 4.1 thru 5.0.4
+This is v2.1.0 of the HotPot module
+ This module allows teachers to administer Hot Potatoes and TexToys quizzes via Moodle.
+ It has been tested on:
+ - Hot Potatoes 6
+ - Moodle 1.1 thru 1.5
+ - PHP 4.1 thru 5.0.4
+ - MySQL and PostgreSQL databases
This module may be distributed under the terms of the General Public License
(see http://www.gnu.org/licenses/gpl.txt for details)
@@ -9,7 +14,7 @@ This is v2.0.8 of the HotPot module
================
IMPORTANT NOTICE
================
-* Please be sure to use Hot Potatoes according to the conditions of use which are listed at the end of this file. If you restrict use via a required Moodle login, you most likely can still meet the 'freely available' condition if you make the same material on a separate URL that permits free access. Otherwise, please purchase a license.
+* Please be sure to use Hot Potatoes according to the conditions of use which are listed at the end of this file. If you restrict use via a required Moodle login, you most likely can still meet the 'freely available' condition if you make the same material on a separate URL that permits free access. Otherwise, please purchase a license.
TO INSTALL OR UPDATE THIS MODULE
@@ -121,13 +126,13 @@ HOT POTATOES CONDITIONS OF USE
**Reproduced from the Hot Potatoes site**
Hot Potatoes is offered free to the educational community by the University of Victoria Humanities Computing and Media Centre (formerly the Language Centre), under certain conditions. Hot Potatoes is free for use by state educational institutions which are non-profit making, on the condition that the material produced using the program is freely available to anyone via the WWW. However, you need to purchase a licence under any of the following conditions:
-? You do not work for a public sector educational establishment.
-? You charge money for access to the material you make with Hot Potatoes.
-? You restrict access to the material in some way. (The only exception here is if you have an account on www.hotpot.net, where you ARE allowed to use password restrictions.)
-? You want to use the Masher program included with the Hot Potatoes suite.
+* You do not work for a public sector educational establishment.
+* You charge money for access to the material you make with Hot Potatoes.
+* You restrict access to the material in some way. (The only exception here is if you have an account on www.hotpot.net, where you ARE allowed to use password restrictions.)
+* You want to use the Masher program included with the Hot Potatoes suite.
For more information on licences, and details on how to purchase one, check out our Website at:
- http://www.halfbakedsoftware.com/hotpot/
+ http://www.halfbakedsoftware.com/hotpot/
If you intend using the programs to generate more than a handful of exercises, please make sure you register. This costs you nothing -- see How to register for details.
-Martin Holmes, Half-Baked Software and the University of Victoria HCMC, 1998-2004.
+Martin Holmes, Half-Baked Software and the University of Victoria HCMC, 1998-2004.
View
@@ -2,8 +2,9 @@
require_once("../../config.php");
require_once("lib.php");
- $next_url = "";
$msg = '';
+ $next_url = "";
+ $quiz_is_finished = true;
$attemptid = required_param("attemptid");
if (is_numeric($attemptid)) {
@@ -33,50 +34,132 @@
// make sure this user is enrolled in this course
require_login($course->id);
- if ($attempt->timefinish && false) {
+ $time = time();
+ $msg = get_string('resultssaved', 'hotpot');
- $msg = 'This attempt has already been submitted';
+ // update attempt record fields using incoming data
+ $attempt->score = optional_param('mark', NULL, PARAM_INT);
+ $attempt->status = optional_param('status', NULL, PARAM_INT);
+ $attempt->details = optional_param('detail', NULL, PARAM_RAW);
+ $attempt->endtime = optional_param('endtime', NULL, PARAM_ALPHA);
+ $attempt->starttime = optional_param('starttime', NULL, PARAM_ALPHA);
+ $attempt->timefinish = $time;
- } else {
- $time = time();
- $msg = get_string('resultssaved', 'hotpot');
-
- $attempt->score = isset($_POST['mark']) ? $_POST['mark'] : NULL;
- $attempt->details = isset($_POST['detail']) ? $_POST['detail'] : NULL;
- $attempt->endtime = isset($_POST['endtime']) ? strtotime($_POST['endtime']) : NULL;
- $attempt->starttime = isset($_POST['starttime']) ? strtotime($_POST['starttime']) : NULL;
- $attempt->timefinish = $time;
-
- // for the rare case where a quiz was "in progress" during an update from hotpot v1 to v2
- if (empty($attempt->timestart) && !empty($attempt->starttime)) {
- $attempt->timestart = $attempt->starttime;
+ if ($attempt->endtime) {
+ $attempt->endtime = strtotime($attempt->endtime);
+ }
+ if ($attempt->starttime) {
+ $attempt->starttime = strtotime($attempt->starttime);
+ }
+
+ // set clickreportid, (for click reporting)
+ $attempt->clickreportid = $attempt->id;
+
+ if (empty($attempt->status)) {
+ if (empty($attempt->endtime)) {
+ $attempt->status = HOTPOT_STATUS_INPROGRESS;
+ } else {
+ $attempt->status = HOTPOT_STATUS_COMPLETED;
}
+ }
- // remove slashes added by lib/setup.php
- $attempt->details = stripslashes($attempt->details);
+ // for the rare case where a quiz was "in progress" during an update from hotpot v1 to v2
+ if (empty($attempt->timestart) && !empty($attempt->starttime)) {
+ $attempt->timestart = $attempt->starttime;
+ }
+
+
+ // check if this is the second (or subsequent) click
+ if (get_field("hotpot_attempts", "timefinish", "id", $attempt->id)) {
+
+ if ($hotpot->clickreporting==HOTPOT_YES) {
+ // add attempt record for each form submission
+ // records are linked via the "clickreportid" field
- // add details of this attempt
- hotpot_add_attempt_details($attempt);
+ // update status in previous records in this group
+ set_field("hotpot_attempts", "status", $attempt->status, "clickreportid", $attempt->clickreportid);
- // add slashes again, so the details can be added to the database
- $attempt->details = addslashes($attempt->details);
+ // add new attempt record
+ unset ($attempt->id);
+ $attempt->id = insert_record("hotpot_attempts", $attempt);
- if (! update_record("hotpot_attempts", $attempt)) {
- error("Could not update attempt record: ".$db->ErrorMsg(), $next_url);
+ if (empty($attempt->id)) {
+ error("Could not insert attempt record: ".$db->ErrorMsg(), $next_url);
+ }
+
+ // add attempt details record, if necessary
+ if (!empty($attempt->details)) {
+ unset($details);
+ $details->attempt = $attempt->id;
+ $details->details = $attempt->details;
+ if (! insert_record("hotpot_details", $details, false)) {
+ error("Could not insert attempt details record: ".$db->ErrorMsg(), $next_url);
+ }
+ }
+
+ } else {
+ // remove previous responses for this attempt
+ // (N.B. this does NOT remove the attempt record, just the responses)
+ $ok = delete_records("hotpot_responses", "attempt", $attempt->id);
}
+ }
- // set previously unfinished attempts of this quiz by this user to "finished"
- hotpot_close_previous_attempts($hotpot->id, $USER->id, $time);
+ // remove slashes added by lib/setup.php
+ $attempt->details = stripslashes($attempt->details);
- add_to_log($course->id, "hotpot", "submit", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id");
+ // add details of this attempt
+ hotpot_add_attempt_details($attempt);
+
+ // add slashes again, so the details can be added to the database
+ $attempt->details = addslashes($attempt->details);
+
+ // update the attempt record
+ if (! update_record("hotpot_attempts", $attempt)) {
+ error("Could not update attempt record: ".$db->ErrorMsg(), $next_url);
}
- if ($hotpot->shownextquiz==HOTPOT_YES && is_numeric($next_cm = hotpot_get_next_cm($cm))) {
- $next_url = "$CFG->wwwroot/mod/hotpot/view.php?id=$next_cm";
+
+ // get previous attempt details record, if any
+ $details_exist = record_exists("hotpot_details", "attempt", $attempt->id);
+
+ // delete/update/add the attempt details record
+ if (empty($attempt->details)) {
+ if ($details_exist) {
+ delete_records("hotpot_details", "attempt", $attempt->id);
+ }
+ } else {
+ if ($details_exist) {
+ set_field("hotpot_details", "details", $attempt->details, "attempt", $attempt->id);
+ } else {
+ unset($details);
+ $details->attempt = $attempt->id;
+ $details->details = $attempt->details;
+ if (! insert_record("hotpot_details", $details)) {
+ error("Could not insert attempt details record: ".$db->ErrorMsg(), $next_url);
+ }
+ }
+ }
+
+ if ($attempt->status==HOTPOT_STATUS_INPROGRESS) {
+ $quiz_is_finished = false;
+
+ } else { // quiz is finished
+
+ add_to_log($course->id, "hotpot", "submit", "review.php?id=$cm->id&attempt=$attempt->id", "$hotpot->id", "$cm->id");
+
+ if ($hotpot->shownextquiz==HOTPOT_YES && is_numeric($next_cm = hotpot_get_next_cm($cm))) {
+ $next_url = "$CFG->wwwroot/mod/hotpot/view.php?id=$next_cm";
+ }
}
}
- // redirect to the next quiz or the course page
- redirect($next_url, $msg);
+ if ($quiz_is_finished) {
+ // redirect to the next quiz or the course page
+ redirect($next_url, $msg);
+ } else {
+ // continue the quiz
+ header("Status: 204");
+ header("HTTP/1.0 204 No Response");
+ }
// =================
Oops, something went wrong.

0 comments on commit 410229b

Please sign in to comment.