if (!defined("LESSON_UNSEENPAGE")) {
- define("LESSON_UNSEENPAGE", 1); // Next page -> any page not seen before
- }
+ define("LESSON_UNSEENPAGE", 1); // Next page -> any page not seen before
+ }
if (!defined("LESSON_UNANSWEREDPAGE")) {
- define("LESSON_UNANSWEREDPAGE", 2); // Next page -> any page not answered correctly
- }
+ define("LESSON_UNANSWEREDPAGE", 2); // Next page -> any page not answered correctly
+ }
$LESSON_NEXTPAGE_ACTION = array (0 => get_string("normal", "lesson"),
LESSON_UNSEENPAGE => get_string("showanunseenpage", "lesson"),
if (!defined("LESSON_NEXTPAGE")) {
- define("LESSON_NEXTPAGE", -1); // Next page
- }
+ define("LESSON_NEXTPAGE", -1); // Next page
+ }
if (!defined("LESSON_EOL")) {
- define("LESSON_EOL", -9); // End of Lesson
- }
+ define("LESSON_EOL", -9); // End of Lesson
+ }
if (!defined("LESSON_UNDEFINED")) {
- define("LESSON_UNDEFINED", -99); // undefined
- }
+ define("LESSON_UNDEFINED", -99); // undefined
+ }
if (!defined("LESSON_SHORTANSWER")) {
define("LESSON_SHORTANSWER", "1");
if ($value == $selected) {
$output .= " SELECTED";
}
- // stop zero label being replaced by array index value
+ // stop zero label being replaced by array index value
// if ($label) {
// $output .= ">$label</OPTION>\n";
// } else {
// $output .= ">$value</OPTION>\n";
- // }
- $output .= ">$label</OPTION>\n";
+ // }
+ $output .= ">$label</OPTION>\n";
}
}
$lesson->timemodified = time();
$lesson->available = make_timestamp($lesson->availableyear,
- $lesson->availablemonth, $lesson->availableday, $lesson->availablehour,
- $lesson->availableminute);
+ $lesson->availablemonth, $lesson->availableday, $lesson->availablehour,
+ $lesson->availableminute);
$lesson->deadline = make_timestamp($lesson->deadlineyear,
- $lesson->deadlinemonth, $lesson->deadlineday, $lesson->deadlinehour,
- $lesson->deadlineminute);
+ $lesson->deadlinemonth, $lesson->deadlineday, $lesson->deadlinehour,
+ $lesson->deadlineminute);
return insert_record("lesson", $lesson);
}
$lesson->timemodified = time();
$lesson->available = make_timestamp($lesson->availableyear,
- $lesson->availablemonth, $lesson->availableday, $lesson->availablehour,
- $lesson->availableminute);
+ $lesson->availablemonth, $lesson->availableday, $lesson->availablehour,
+ $lesson->availableminute);
$lesson->deadline = make_timestamp($lesson->deadlineyear,
- $lesson->deadlinemonth, $lesson->deadlineday, $lesson->deadlinehour,
- $lesson->deadlineminute);
+ $lesson->deadlinemonth, $lesson->deadlineday, $lesson->deadlinehour,
+ $lesson->deadlineminute);
$lesson->id = $lesson->instance;
return update_record("lesson", $lesson);
if ($attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $user->id",
"retry, timeseen")) {
print_simple_box_start();
- $table->head = array (get_string("attempt", "lesson"), get_string("numberofpagesviewed", "lesson"),
- get_string("numberofcorrectanswers", "lesson"), get_string("time"));
- $table->width = "100%";
- $table->align = array ("center", "center", "center", "center");
- $table->size = array ("*", "*", "*", "*");
- $table->cellpadding = 2;
- $table->cellspacing = 0;
+ $table->head = array (get_string("attempt", "lesson"), get_string("numberofpagesviewed", "lesson"),
+ get_string("numberofcorrectanswers", "lesson"), get_string("time"));
+ $table->width = "100%";
+ $table->align = array ("center", "center", "center", "center");
+ $table->size = array ("*", "*", "*", "*");
+ $table->cellpadding = 2;
+ $table->cellspacing = 0;
$retry = 0;
$npages = 0;
$ncorrect = 0;
- foreach ($attempts as $attempt) {
- if ($attempt->retry == $retry) {
- $npages++;
+ foreach ($attempts as $attempt) {
+ if ($attempt->retry == $retry) {
+ $npages++;
if ($attempt->correct) {
$ncorrect++;
}
$timeseen = $attempt->timeseen;
} else {
- $table->data[] = array($retry + 1, $npages, $ncorrect, userdate($timeseen));
+ $table->data[] = array($retry + 1, $npages, $ncorrect, userdate($timeseen));
$retry++;
$npages = 1;
if ($attempt->correct) {
} else {
$ncorrect = 0;
}
- }
- }
+ }
+ }
if ($npages) {
- $table->data[] = array($retry + 1, $npages, $ncorrect, userdate($timeseen));
+ $table->data[] = array($retry + 1, $npages, $ncorrect, userdate($timeseen));
}
- print_table($table);
- print_simple_box_end();
+ print_table($table);
+ print_simple_box_end();
// also print grade summary
if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND userid = $user->id",
"grade DESC")) {
/// indexed by user. It also returns a maximum allowed grade.
global $CFG;
- if (!$lesson = get_record("lesson", "id", $lessonid)) {
- error("Lesson record not found");
- }
+ if (!$lesson = get_record("lesson", "id", $lessonid)) {
+ error("Lesson record not found");
+ }
+ if (!$return->maxgrade = $lesson->grade) {
+ return NULL;
+ }
if (!empty($lesson->usemaxgrade)) {
$grades = get_records_sql_menu("SELECT userid,MAX(grade) FROM {$CFG->prefix}lesson_grades WHERE
lessonid = $lessonid GROUP BY userid");
$return->grades[$userid] = number_format($grade * $lesson->grade / 100.0, 1);
}
}
- $return->maxgrade = $lesson->grade;
return $return;
}
/// Given an ID of an instance of this module,
/// this function will permanently delete the instance
/// and any data that depends on it.
-
+
require('../config.php');
if (! $scorm = get_record("scorm", "id", "$id")) {
/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
- global $CFG;
-
+ global $CFG;
+
+ if (!$return->maxgrade = count_records_select("scorm_scoes","scorm='$scormid' AND launch<>''")) {
+ return NULL;
+ }
+
$return->grades = NULL;
if ($sco_users=get_records_select("scorm_sco_users", "scormid='$scormid' GROUP BY userid")) {
foreach ($sco_users as $sco_user) {
- $user_data=get_records_select("scorm_sco_users","scormid='$scormid' AND userid='$sco_user->userid'");
- $scores->completed=0;
- $scores->browsed=0;
- $scores->incomplete=0;
- $scores->failed=0;
- $scores->notattempted=0;
- $result="";
- $data = current($user_data);
- foreach ($user_data as $data) {
- if ($data->cmi_core_lesson_status=="passed")
- $scores->completed++;
- else
- $scores->{scorm_remove_spaces($data->cmi_core_lesson_status)}++;
-
- }
- if ($scores->completed)
- $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string("completed","scorm")."\" title=\"".get_string("completed","scorm")."\"> $scores->completed ";
- if ($scores->incomplete)
- $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/incomplete.gif\" alt=\"".get_string("incomplete","scorm")."\" title=\"".get_string("incomplete","scorm")."\"> $scores->incomplete ";
- if ($scores->failed)
- $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/failed.gif\" alt=\"".get_string("failed","scorm")."\" title=\"".get_string("failed","scorm")."\"> $scores->failed ";
- if ($scores->browsed)
- $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/browsed.gif\" alt=\"".get_string("browsed","scorm")."\" title=\"".get_string("browsed","scorm")."\"> $scores->browsed ";
- if ($scores->notattempted)
- $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\"> $scores->notattempted ";
-
- $return->grades[$sco_user->userid]=$result;
+ $user_data=get_records_select("scorm_sco_users","scormid='$scormid' AND userid='$sco_user->userid'");
+ $scores->completed=0;
+ $scores->browsed=0;
+ $scores->incomplete=0;
+ $scores->failed=0;
+ $scores->notattempted=0;
+ $result="";
+ $data = current($user_data);
+ foreach ($user_data as $data) {
+ if ($data->cmi_core_lesson_status=="passed")
+ $scores->completed++;
+ else
+ $scores->{scorm_remove_spaces($data->cmi_core_lesson_status)}++;
+
+ }
+ if ($scores->completed)
+ $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string("completed","scorm")."\" title=\"".get_string("completed","scorm")."\"> $scores->completed ";
+ if ($scores->incomplete)
+ $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/incomplete.gif\" alt=\"".get_string("incomplete","scorm")."\" title=\"".get_string("incomplete","scorm")."\"> $scores->incomplete ";
+ if ($scores->failed)
+ $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/failed.gif\" alt=\"".get_string("failed","scorm")."\" title=\"".get_string("failed","scorm")."\"> $scores->failed ";
+ if ($scores->browsed)
+ $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/browsed.gif\" alt=\"".get_string("browsed","scorm")."\" title=\"".get_string("browsed","scorm")."\"> $scores->browsed ";
+ if ($scores->notattempted)
+ $result.="<img src=\"$CFG->wwwroot/mod/scorm/pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" title=\"".get_string("notattempted","scorm")."\"> $scores->notattempted ";
+
+ $return->grades[$sco_user->userid]=$result;
}
}
-
- $return->maxgrade = count_records_select("scorm_scoes","scorm='$scormid' AND launch<>''");
return $return;
}
{
global $CFG;
- if (($existingdir!="") && (is_dir($strPath.$existingdir)))
- return $strPath.$existingdir;
-
- if (is_dir($strPath)) {
- do {
- $datadir="/".$prefix.scorm_randstring();
- } while (file_exists($strPath.$datadir));
- mkdir($strPath.$datadir, $CFG->directorypermissions);
+ if (($existingdir!="") && (is_dir($strPath.$existingdir)))
+ return $strPath.$existingdir;
+
+ if (is_dir($strPath)) {
+ do {
+ $datadir="/".$prefix.scorm_randstring();
+ } while (file_exists($strPath.$datadir));
+ mkdir($strPath.$datadir, $CFG->directorypermissions);
@chmod($strPath.$datadir, $CFG->directorypermissions); // Just in case mkdir didn't do it
- return $strPath.$datadir;
- } else {
- return false;
- }
+ return $strPath.$datadir;
+ } else {
+ return false;
+ }
}
function scorm_validate($manifest)
{
if (is_file ($manifest)) {
- if (file_exists($manifest))
- {
- return "regular";
- }
+ if (file_exists($manifest))
+ {
+ return "regular";
+ }
} else {
- return "nomanifest";
+ return "nomanifest";
}
}
while (($file = readdir($handle)) != '')
{
if ($file != "." && $file != "..")
- {
- if (!is_dir($directory."/".$file))
+ {
+ if (!is_dir($directory."/".$file))
unlink($directory."/".$file);
- else
- scorm_delete_files($directory."/".$file);
- }
+ else
+ scorm_delete_files($directory."/".$file);
+ }
}
rmdir($directory);
}
function scorm_startElement($parser, $name, $attrs) {
global $manifest,$i,$resources,$parent,$level;
if ($name == "ITEM") {
- $i++;
- $manifest[$i]["identifier"] = $attrs["IDENTIFIER"];
- if (empty($attrs["IDENTIFIERREF"]))
- $attrs["IDENTIFIERREF"] = "";
- $manifest[$i]["identifierref"] = $attrs["IDENTIFIERREF"];
- if (empty($attrs["ISVISIBLE"]))
- $attrs["ISVISIBLE"] = "";
- $manifest[$i]["isvisible"] = $attrs["ISVISIBLE"];
- $manifest[$i]["parent"] = $parent[$level];
- $level++;
- $parent[$level] = $attrs["IDENTIFIER"];
+ $i++;
+ $manifest[$i]["identifier"] = $attrs["IDENTIFIER"];
+ if (empty($attrs["IDENTIFIERREF"]))
+ $attrs["IDENTIFIERREF"] = "";
+ $manifest[$i]["identifierref"] = $attrs["IDENTIFIERREF"];
+ if (empty($attrs["ISVISIBLE"]))
+ $attrs["ISVISIBLE"] = "";
+ $manifest[$i]["isvisible"] = $attrs["ISVISIBLE"];
+ $manifest[$i]["parent"] = $parent[$level];
+ $level++;
+ $parent[$level] = $attrs["IDENTIFIER"];
}
if ($name == "RESOURCE") {
- $resources[$attrs["IDENTIFIER"]]["href"]=$attrs["HREF"];
- $resources[$attrs["IDENTIFIER"]]["type"]=$attrs["ADLCP:SCORMTYPE"];
+ $resources[$attrs["IDENTIFIER"]]["href"]=$attrs["HREF"];
+ $resources[$attrs["IDENTIFIER"]]["type"]=$attrs["ADLCP:SCORMTYPE"];
}
}
$level--;
}
if ($name == "TITLE" && $level>0)
- $manifest[$i]["title"] = $datacontent;
+ $manifest[$i]["title"] = $datacontent;
if ($name == "ADLCP:HIDERTSUI")
- $manifest[$i][$datacontent] = 1;
+ $manifest[$i][$datacontent] = 1;
}
function scorm_characterData($parser, $data) {
}
while ($data = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $data, feof($fp))) {
+ if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
$sco->launch = $resources[($manifest[$j]["identifierref"])]["href"];
if (empty($resources[($manifest[$j]["identifierref"])]["type"]))
$resources[($manifest[$j]["identifierref"])]["type"] = "";
- $sco->type = $resources[($manifest[$j]["identifierref"])]["type"];
- if (empty($manifest[$j]["previous"]))
- $manifest[$j]["previous"] = 0;
- $sco->previous = $manifest[$j]["previous"];
- if (empty($manifest[$j]["continue"]))
- $manifest[$j]["continue"] = 0;
- $sco->next = $manifest[$j]["continue"];
- if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false")
- $id = insert_record("scorm_scoes",$sco);
- if ($launch==0 && $sco->launch)
- $launch = $id;
+ $sco->type = $resources[($manifest[$j]["identifierref"])]["type"];
+ if (empty($manifest[$j]["previous"]))
+ $manifest[$j]["previous"] = 0;
+ $sco->previous = $manifest[$j]["previous"];
+ if (empty($manifest[$j]["continue"]))
+ $manifest[$j]["continue"] = 0;
+ $sco->next = $manifest[$j]["continue"];
+ if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false")
+ $id = insert_record("scorm_scoes",$sco);
+ if ($launch==0 && $sco->launch)
+ $launch = $id;
}
return $launch;
}
function scorm_remove_spaces($sourcestr) {
// Remove blank space from a string
$newstr="";
- for( $i=0; $i<strlen($sourcestr); $i++) {
- if ($sourcestr[$i]!=' ')
- $newstr .=$sourcestr[$i];
- }
- return $newstr;
+ for( $i=0; $i<strlen($sourcestr); $i++) {
+ if ($sourcestr[$i]!=' ')
+ $newstr .=$sourcestr[$i];
+ }
+ return $newstr;
}
function scorm_string_round($stringa) {
// Crop a string to $len character and set an anchor title to the full string
$len=11;
if ( strlen($stringa)>$len ) {
- return "<A name=\"\" title=\"$stringa\">".substr($stringa,0,$len-4)."...".substr($stringa,strlen($stringa)-1,1)."</A>";
+ return "<A name=\"\" title=\"$stringa\">".substr($stringa,0,$len-4)."...".substr($stringa,strlen($stringa)-1,1)."</A>";
} else
- return $stringa;
+ return $stringa;
}
function scorm_external_link($link) {
$result = false;
$link = strtolower($link);
if (substr($link,0,7) == "http://")
- $result = true;
+ $result = true;
else if (substr($link,0,8) == "https://")
- $result = true;
+ $result = true;
else if (substr($link,0,4) == "www.")
- $result = true;
+ $result = true;
/*else if (substr($link,0,7) == "rstp://")
- $result = true;
+ $result = true;
else if (substr($link,0,6) == "rtp://")
- $result = true;
+ $result = true;
else if (substr($link,0,6) == "ftp://")
- $result = true;
+ $result = true;
else if (substr($link,0,9) == "gopher://")
- $result = true; */
+ $result = true; */
return $result;
}
?>