]> git.mjollnir.org Git - moodle.git/commitdiff
made sure that ungraded modules would not show up in gradebook
authorgustav_delius <gustav_delius>
Wed, 9 Jun 2004 22:50:42 +0000 (22:50 +0000)
committergustav_delius <gustav_delius>
Wed, 9 Jun 2004 22:50:42 +0000 (22:50 +0000)
mod/exercise/lib.php
mod/lesson/lib.php
mod/scorm/lib.php
mod/wiki/lib.php

index 4d8cc22dda187c3463d00fc234fb7c91fdca845a..9a4c0b47b1697e3335bae982322abea3b90f6014 100644 (file)
@@ -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;
 }
index 208fc8d54a9e56abd95bf2cce7712e9acaf71468..87ccf2e06fd95ce55ffb783619230e45f75ddfbc 100644 (file)
@@ -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</OPTION>\n";
             // } else {
             //     $output .= ">$value</OPTION>\n";
-                       //  }
-                       $output .= ">$label</OPTION>\n";
+            //  }
+            $output .= ">$label</OPTION>\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));
+                $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")) {
@@ -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;
 }
index db85635099a58a7c86b498b4fbe2349a2b9d173d..5aa5e02865bc412dec49f0139ff9da43c0177fee 100755 (executable)
@@ -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.="<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;
 }
@@ -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<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) {
@@ -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;
 }    
 ?>
index 2950b21b12bcbc667d3d1f7949abccca37ff7015..87b921e7db241c54029f4b334c06042ebeda6968 100644 (file)
@@ -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