From ce78926df0f0390a5fbb80f5fc231c56e2080f93 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 6 Jan 2003 13:55:37 +0000 Subject: [PATCH] Small robustness fixes --- course/weeks.php | 6 +++--- lib/datalib.php | 2 +- lib/moodlelib.php | 2 +- lib/weblib.php | 4 ++-- mod/assignment/lib.php | 4 ++-- mod/assignment/mod.html | 4 ++-- mod/assignment/submissions.php | 7 +++---- mod/choice/index.php | 11 ++++++++--- user/edit.html | 10 ++++++++++ 9 files changed, 32 insertions(+), 18 deletions(-) diff --git a/course/weeks.php b/course/weeks.php index ecc2d09f7c..9d369d76a9 100644 --- a/course/weeks.php +++ b/course/weeks.php @@ -189,12 +189,12 @@ } echo ""; - if ($news or $course->showrecent) { + if (!empty($news) or !empty($course->showrecent)) { echo ""; // Print all the news items. - if ($news) { + if (!empty($news)) { print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews"); echo ""; forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false); @@ -203,7 +203,7 @@ } // Print all the recent activity - if ($course->showrecent) { + if (!empty($course->showrecent)) { print_side_block_start(get_string("recentactivity"), 210, "sideblockrecentactivity"); print_recent_activity($course); print_side_block_end(); diff --git a/lib/datalib.php b/lib/datalib.php index eacbcf555c..7d460c7e68 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -955,7 +955,7 @@ function add_to_log($course, $module, $action, $url="", $info="") { '$url', '$info')"); - if (!$result) { + if (!$result and ($CFG->debug > 7)) { echo "

Error: Could not insert a new entry to the Moodle log

"; // Don't throw an error } } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 69290538c0..f99ece13fa 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1143,7 +1143,7 @@ function check_browser_version($brand="MSIE", $version=5.5) { function can_use_richtext_editor() { /// Is the richedit editor enabled? global $USER, $CFG; - if ($USER->htmleditor and $CFG->htmleditor) { + if (!empty($USER->htmleditor) and !empty($CFG->htmleditor)) { return check_browser_version("MSIE", 5.5); } return false; diff --git a/lib/weblib.php b/lib/weblib.php index 8d9c91b956..c3e422ad52 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -163,11 +163,11 @@ function match_referer($good_referer = "") { /// good_referer is not specified, use qualified_me as the good_referer global $CFG; - if ($CFG->buggy_referer) { + if (!empty($CFG->buggy_referer)) { return true; } - if ($good_referer == "") { + if (empty($good_referer)) { $good_referer = qualified_me(); } return $good_referer == get_referer(); diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 97526afebd..d31b9ae309 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -298,7 +298,7 @@ function assignment_print_difference($time) { } function assignment_print_submission($assignment, $user, $submission, $teachers, $grades) { - global $THEME; + global $THEME, $USER; echo "\n"; @@ -433,7 +433,7 @@ function assignment_print_upload_form($assignment) { echo "
"; echo "
"; - echo " maxfilesize\">"; + echo " maxbytes\">"; echo " id\">"; echo " "; echo " "; diff --git a/mod/assignment/mod.html b/mod/assignment/mod.html index 27f239c9cf..c235e78515 100644 --- a/mod/assignment/mod.html +++ b/mod/assignment/mod.html @@ -21,8 +21,8 @@ if (empty($form->resubmit)) { $form->resubmit = ""; } - if (empty($form->grade)) { - $form->grade = ""; + if (!isset($form->grade)) { + $form->grade = 100; } if (empty($form->maxbytes)) { $form->maxbytes = ""; diff --git a/mod/assignment/submissions.php b/mod/assignment/submissions.php index 1654da237b..8aef7afa1c 100644 --- a/mod/assignment/submissions.php +++ b/mod/assignment/submissions.php @@ -73,7 +73,6 @@ if ($data = data_submitted()) { $feedback = array(); - $data = (array)$data; // Peel out all the data from variable names. foreach ($data as $key => $val) { @@ -89,10 +88,10 @@ foreach ($feedback as $num => $vals) { $submission = $submissions[$num]; // Only update entries where feedback has actually changed. - if (($vals[g] <> $submission->grade) || ($vals[c] <> addslashes($submission->comment))) { + if (($vals['g'] <> $submission->grade) || ($vals['c'] <> addslashes($submission->comment))) { unset($newsubmission); - $newsubmission->grade = $vals[g]; - $newsubmission->comment = $vals[c]; + $newsubmission->grade = $vals['g']; + $newsubmission->comment = $vals['c']; $newsubmission->teacher = $USER->id; $newsubmission->timemarked = $timenow; $newsubmission->mailed = 0; // Make sure mail goes out (again, even) diff --git a/mod/choice/index.php b/mod/choice/index.php index e573036919..bd901b1aaa 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -62,14 +62,19 @@ } else { $aa = ""; } + if (!empty($choice->section)) { + $section = "$choice->section"; + } else { + $section = ""; + } if ($course->format == "weeks" || $course->format == "topics") { - $table->data[] = array ("$choice->section", + $table->data[] = array ($section, "coursemodule\">$choice->name", - "$aa"); + $aa); } else { $table->data[] = array ("coursemodule\">$choice->name", - "$aa"); + $aa); } } echo "
"; diff --git a/user/edit.html b/user/edit.html index 0a4e31b5b2..0fa63cd4f7 100644 --- a/user/edit.html +++ b/user/edit.html @@ -1,3 +1,13 @@ +htmleditor)) { + $user->htmleditor = 1; + } + if (empty($user->lang)) { + $user->lang = $CFG->lang; + } + +?> +