]> git.mjollnir.org Git - moodle.git/commitdiff
Small robustness fixes
authormoodler <moodler>
Mon, 6 Jan 2003 13:55:37 +0000 (13:55 +0000)
committermoodler <moodler>
Mon, 6 Jan 2003 13:55:37 +0000 (13:55 +0000)
course/weeks.php
lib/datalib.php
lib/moodlelib.php
lib/weblib.php
mod/assignment/lib.php
mod/assignment/mod.html
mod/assignment/submissions.php
mod/choice/index.php
user/edit.html

index ecc2d09f7c968c341a249af4b30bc26f6e1bea42..9d369d76a9ae92de79d6fdd6249563c494bca80d 100644 (file)
     }
     echo "</TABLE>";
     
-    if ($news or $course->showrecent) {
+    if (!empty($news) or !empty($course->showrecent)) {
         echo "</TD><TD WIDTH=210>";
 
         // Print all the news items.
 
-        if ($news) {
+        if (!empty($news)) {
             print_side_block_start(get_string("latestnews"), 210, "sideblocklatestnews");
             echo "<FONT SIZE=\"-2\">";
             forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
         }
         
         // 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();
index eacbcf555ca8a6a04cfcab0825d2990b687a02bf..7d460c7e68409f832182f2b54cc5b293dbe77035 100644 (file)
@@ -955,7 +955,7 @@ function add_to_log($course, $module, $action, $url="", $info="") {
                                         '$url',
                                         '$info')");
 
-    if (!$result) {
+    if (!$result and ($CFG->debug > 7)) {
         echo "<P>Error: Could not insert a new entry to the Moodle log</P>";  // Don't throw an error
     }    
 }
index 69290538c053fad60588daa97489c54ac6269586..f99ece13fa369aeb420e888dd8656031dd69193c 100644 (file)
@@ -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;
index 8d9c91b9566b258fe33dfd2bbc648d5cae31ac7c..c3e422ad52d1b58fe360b677a76286f6187e4594 100644 (file)
@@ -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();
index 97526afebd10fdafc6cb035aa1ea62dafc3bdb0c..d31b9ae309fc9923c0af0dc30b6600c0e112ea1d 100644 (file)
@@ -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<TABLE BORDER=1 CELLSPACING=0 valign=top cellpadding=10 align=center>";
 
@@ -433,7 +433,7 @@ function assignment_print_upload_form($assignment) {
 
     echo "<DIV ALIGN=CENTER>";
     echo "<FORM ENCTYPE=\"multipart/form-data\" METHOD=\"POST\" ACTION=upload.php>";
-    echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$assignment->maxfilesize\">";
+    echo " <INPUT TYPE=hidden NAME=MAX_FILE_SIZE value=\"$assignment->maxbytes\">";
     echo " <INPUT TYPE=hidden NAME=id VALUE=\"$assignment->id\">";
     echo " <INPUT NAME=\"newfile\" TYPE=\"file\" size=\"50\">";
     echo " <INPUT TYPE=submit NAME=save VALUE=\"".get_string("uploadthisfile")."\">";
index 27f239c9cfef44fdceea43e83deda8155e567045..c235e785158df06386171238bd878a86eb758b53 100644 (file)
@@ -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 = "";
index 1654da237be588b1c6fb89a1f8c0c7a793f0cfd8..8aef7afa1c57fe88d4acd62ced5b9bb2cb94812d 100644 (file)
@@ -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) {
         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)
index e57303691912bc8a19e1297bfc66730e35729bc7..bd901b1aaa7711b307be3e54da387b69b6523b1c 100644 (file)
         } 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,
                                     "<A HREF=\"view.php?id=$choice->coursemodule\">$choice->name</A>",
-                                    "$aa");
+                                    $aa);
         } else {
             $table->data[] = array ("<A HREF=\"view.php?id=$choice->coursemodule\">$choice->name</A>",
-                                    "$aa");
+                                    $aa);
         }
     }
     echo "<BR>";
index 0a4e31b5b27387b263df08c065f068fc4d1a744d..0fa63cd4f7d5e2df8dafde3799716387812f51f8 100644 (file)
@@ -1,3 +1,13 @@
+<?PHP
+   if (empty($user->htmleditor)) {
+       $user->htmleditor = 1;
+   }
+   if (empty($user->lang)) {
+       $user->lang = $CFG->lang;
+   }
+
+?>
+
 <FORM METHOD="post" ENCTYPE="multipart/form-data" action="edit.php">
 <table cellpadding=9 cellspacing=0 >
 <?