diff --git a/mod/exercise/lib.php b/mod/exercise/lib.php
index 4d8cc22dda1..9a4c0b47b16 100644
--- a/mod/exercise/lib.php
+++ b/mod/exercise/lib.php
@@ -336,6 +336,9 @@ global $EXERCISE_FWEIGHTS;
if (! $course = get_record("course", "id", $exercise->course)) {
error("Course is misconfigured");
}
+ if (!$return->maxgrade = $exercise->grade) {
+ return NULL;
+ }
// calculate scaling factor
$scaling = $exercise->grade / (100.0 * ($EXERCISE_FWEIGHTS[$exercise->gradingweight] +
@@ -374,7 +377,6 @@ global $EXERCISE_FWEIGHTS;
$return->grades[$userid] = number_format($g, 1);
}
}
- $return->maxgrade = $exercise->grade;
return $return;
}
diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php
index 208fc8d54a9..87ccf2e06fd 100644
--- a/mod/lesson/lib.php
+++ b/mod/lesson/lib.php
@@ -5,11 +5,11 @@
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"),
@@ -17,14 +17,14 @@ $LESSON_NEXTPAGE_ACTION = array (0 => get_string("normal", "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");
@@ -107,13 +107,13 @@ function lesson_choose_from_menu ($options, $name, $selected="", $nothing="choos
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\n";
// } else {
// $output .= ">$value\n";
- // }
- $output .= ">$label\n";
+ // }
+ $output .= ">$label\n";
}
}
@@ -137,12 +137,12 @@ function lesson_add_instance($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);
return insert_record("lesson", $lesson);
}
@@ -156,11 +156,11 @@ function lesson_update_instance($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);
@@ -233,27 +233,27 @@ function lesson_user_complete($course, $user, $mod, $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) {
@@ -261,13 +261,13 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
} else {
$ncorrect = 0;
}
- }
- }
- if ($npages) {
- $table->data[] = array($retry + 1, $npages, $ncorrect, userdate($timeseen));
+ }
}
- print_table($table);
- print_simple_box_end();
+ if ($npages) {
+ $table->data[] = array($retry + 1, $npages, $ncorrect, userdate($timeseen));
+ }
+ 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")) {
@@ -318,9 +318,12 @@ function lesson_grades($lessonid) {
/// 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");
@@ -335,7 +338,6 @@ function lesson_grades($lessonid) {
$return->grades[$userid] = number_format($grade * $lesson->grade / 100.0, 1);
}
}
- $return->maxgrade = $lesson->grade;
return $return;
}
diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php
index db85635099a..5aa5e02865b 100755
--- a/mod/scorm/lib.php
+++ b/mod/scorm/lib.php
@@ -38,7 +38,7 @@ function scorm_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.
-
+
require('../config.php');
if (! $scorm = get_record("scorm", "id", "$id")) {
@@ -109,43 +109,45 @@ function scorm_grades($scormid) {
/// 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.="
wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string("completed","scorm")."\" title=\"".get_string("completed","scorm")."\"> $scores->completed ";
- if ($scores->incomplete)
- $result.="
wwwroot/mod/scorm/pix/incomplete.gif\" alt=\"".get_string("incomplete","scorm")."\" title=\"".get_string("incomplete","scorm")."\"> $scores->incomplete ";
- if ($scores->failed)
- $result.="
wwwroot/mod/scorm/pix/failed.gif\" alt=\"".get_string("failed","scorm")."\" title=\"".get_string("failed","scorm")."\"> $scores->failed ";
- if ($scores->browsed)
- $result.="
wwwroot/mod/scorm/pix/browsed.gif\" alt=\"".get_string("browsed","scorm")."\" title=\"".get_string("browsed","scorm")."\"> $scores->browsed ";
- if ($scores->notattempted)
- $result.="
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.="
wwwroot/mod/scorm/pix/completed.gif\" alt=\"".get_string("completed","scorm")."\" title=\"".get_string("completed","scorm")."\"> $scores->completed ";
+ if ($scores->incomplete)
+ $result.="
wwwroot/mod/scorm/pix/incomplete.gif\" alt=\"".get_string("incomplete","scorm")."\" title=\"".get_string("incomplete","scorm")."\"> $scores->incomplete ";
+ if ($scores->failed)
+ $result.="
wwwroot/mod/scorm/pix/failed.gif\" alt=\"".get_string("failed","scorm")."\" title=\"".get_string("failed","scorm")."\"> $scores->failed ";
+ if ($scores->browsed)
+ $result.="
wwwroot/mod/scorm/pix/browsed.gif\" alt=\"".get_string("browsed","scorm")."\" title=\"".get_string("browsed","scorm")."\"> $scores->browsed ";
+ if ($scores->notattempted)
+ $result.="
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;
}
@@ -176,30 +178,30 @@ function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM")
{
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";
}
}
@@ -211,12 +213,12 @@ function scorm_delete_files($directory)
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);
}
@@ -225,21 +227,21 @@ function scorm_delete_files($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"];
}
}
@@ -249,9 +251,9 @@ function scorm_endElement($parser, $name) {
$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) {
@@ -278,7 +280,7 @@ function scorm_parse($basedir,$file,$scorm_id) {
}
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)));
@@ -299,17 +301,17 @@ function scorm_parse($basedir,$file,$scorm_id) {
$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;
}
@@ -331,20 +333,20 @@ function scorm_get_scoes_records($sco_user) {
function scorm_remove_spaces($sourcestr) {
// Remove blank space from a string
$newstr="";
- for( $i=0; $i$len ) {
- return "".substr($stringa,0,$len-4)."...".substr($stringa,strlen($stringa)-1,1)."";
+ return "".substr($stringa,0,$len-4)."...".substr($stringa,strlen($stringa)-1,1)."";
} else
- return $stringa;
+ return $stringa;
}
function scorm_external_link($link) {
@@ -352,19 +354,19 @@ 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;
}
?>
diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php
index 2950b21b12b..87b921e7db2 100644
--- a/mod/wiki/lib.php
+++ b/mod/wiki/lib.php
@@ -9,7 +9,7 @@ $site = get_site();
$WIKI_TYPES = array ('teacher' => $site->teacher,
'group' => get_string('groups',"wiki"),
'student' => $site->student );
-define("EWIKI_ESCAPE_AT", 0); # For the algebraic filter
+define("EWIKI_ESCAPE_AT", 0); # For the algebraic filter
function wiki_add_instance($wiki) {
/// Given an object containing all the necessary data,
@@ -145,10 +145,7 @@ function wiki_grades($wikiid) {
/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
- $return->grades = NULL;
- $return->maxgrade = NULL;
-
- return $return;
+ return NULL;
}
function wiki_get_participants($wikiid) {
@@ -1360,4 +1357,4 @@ function wiki_admin_revert($proceed, $authorfieldpattern, $changesfield, $howtoo
} #-- while($row)
return $ret;
}
-?>
\ No newline at end of file
+?>
\ No newline at end of file