Index: lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/choice/lib.php,v
retrieving revision 1.37.2.2
diff -u -r1.37.2.2 lib.php
--- lib.php	15 Oct 2006 23:56:36 -0000	1.37.2.2
+++ lib.php	16 Oct 2006 15:23:57 -0000
@@ -276,8 +276,15 @@
                     $newanswer = $current;
                     $newanswer->optionid = $formanswer;
                     $newanswer->timemodified = time();
-                    if (! update_record("choice_answers", $newanswer)) {
-                        error("Could not update your choice because of a database error");
+                    if ($choice->allowupdate==2){
+                    	if (! insert_record("choice_answers", $newanswer)) {
+                        	error("Could not save your choice");
+                    	}
+                    }
+                    else {
+                    	if (! update_record("choice_answers", $newanswer)) {
+                        	error("Could not update your choice because of a database error");
+                    	}
                     }
                     add_to_log($courseid, "choice", "choose again", "view.php?id=$cm->id", $choice->id, $cm->id);
                 } else {
@@ -343,7 +350,8 @@
 
         if ($allresponses = get_records("choice_answers", "choiceid", $choice->id)) {
             foreach ($allresponses as $aa) {
-                $answers[$aa->userid] = $aa;
+                $answers[$aa->userid][] = $aa;
+                $ids[(int)$aa->optionid][$aa->userid]=$aa->id;
             }
         } else {
             $answers = array () ;
@@ -357,8 +365,11 @@
         if (!empty($users)) {
             foreach ($users as $user) {
                 if (!empty($user->id) and !empty($answers[$user->id])) {
-                    $answer = $answers[$user->id];
+                	//joan Codina
+                    foreach ($answers[$user->id] as $answer ){
                     $useranswer[(int)$answer->optionid][] = $user;
+                     
+                    }
                 } else {
                     $useranswer[0][] = $user;
                 }
@@ -369,6 +380,7 @@
                 unset($useranswer[$optionid]);     // Throw away any data that doesn't apply
             }
         }
+        //to be updated
         ksort($useranswer);
 
         switch ($forcepublish) {
@@ -417,7 +429,8 @@
                     if (!($optionid==0 && isadmin($user->id)) && !($optionid==0 && isteacher($course->id, $user->id) && !(isteacheredit($course->id, $user->id)) )  ) { //make sure admins and hidden teachers are not shown in not answered yet column.
                         echo "<tr>";
                         if (isteacher($course->id, $USER->id) && !($optionid==0)) {
-                            echo '<td width=\"5\" nowrap=\"nowrap\"><input type="checkbox" name="attemptid[]" value="'. $answers[$user->id]->id. '" /></td>';
+                            // joan codina $answers[$user->id]->id $ids[$optionid][$user->id];
+                            echo '<td width=\"5\" nowrap=\"nowrap\"><input type="checkbox" name="attemptid[]" value="'. $ids[$optionid][$user->id]. '" /></td>';
                         }
                         echo "<td width=\"10\" nowrap=\"nowrap\" class=\"picture\">";
                         print_user_picture($user->id, $course->id, $user->picture);
Index: mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/choice/mod.html,v
retrieving revision 1.40
diff -u -r1.40 mod.html
--- mod.html	23 Apr 2006 11:40:25 -0000	1.40
+++ mod.html	16 Oct 2006 15:23:57 -0000
@@ -284,6 +284,7 @@
         <?php
         $menuoptions[0] = get_string("no");
         $menuoptions[1] = get_string("yes");
+        $menuoptions[2] = get_string("unlimited");
         choose_from_menu($menuoptions, "allowupdate", "$form->allowupdate", "");
         ?>
         <br />
