diff --git a/mod/choice/lib.php b/mod/choice/lib.php
index 7ed4042..3296b09 100644
--- a/mod/choice/lib.php
+++ b/mod/choice/lib.php
@@ -202,6 +202,8 @@ function choice_prepare_options($choice, $user, $coursemodule, $allresponses) {
     $cdisplay['limitanswers'] = true;
     $context = context_module::instance($coursemodule->id);
+    // Reduce db calls to one call instead of number of choice calls
+    $user_choices = $DB->get_records('choice_answers',array('choiceid'=> $choice->id, 'userid'=> $user->id),'optionid','optionid');
+    
     foreach ($choice->option as $optionid => $text) {
         if (isset($text)) { //make sure there are no dud entries in the db with blank text values.
             $option = new stdClass;
@@ -216,7 +218,7 @@ function choice_prepare_options($choice, $user, $coursemodule, $allresponses) {
             } else {
                 $option->countanswers = 0;
             }
-            if ($DB->record_exists('choice_answers', array('choiceid' => $choice->id, 'userid' => $user->id, 'optionid' => $optionid))) {
+            if (array_key_exists($optionid, $user_choices)) {
                 $option->attributes->checked = true;
             }
             if ( $choice->limitanswers && ($option->countanswers >= $option->maxanswers) && empty($option->attributes->checked)) {
@@ -228,7 +230,7 @@ function choice_prepare_options($choice, $user, $coursemodule, $allresponses) {
 
     $cdisplay['hascapability'] = is_enrolled($context, NULL, 'mod/choice:choose'); //only enrolled users are allowed to make a choice
 
-    if ($choice->allowupdate && $DB->record_exists('choice_answers', array('choiceid'=> $choice->id, 'userid'=> $user->id))) {
+    if ($choice->allowupdate && count($user_choices) > 0) {
         $cdisplay['allowupdate'] = true;
     }
 
@@ -276,13 +278,14 @@ WHERE
             $answers = $DB->get_records("choice_answers", array("optionid" => $formanswer));
         }
 
-        if ($answers) {
-            foreach ($answers as $a) { //only return enrolled users.
-                if (is_enrolled($context, $a->userid, 'mod/choice:choose')) {
-                    $countanswers++;
-                }
-            }
-        }
+//         if ($answers) {
+//             foreach ($answers as $a) { //only return enrolled users.
+//                 if (is_enrolled($context, $a->userid, 'mod/choice:choose')) {
+//                     $countanswers++;
+//                 }
+//             }
+//         }
+        $countanswers = count($answers);
         $maxans = $choice->maxanswers[$formanswer];
     }
 
@@ -293,6 +296,7 @@ WHERE
             $newanswer->optionid = $formanswer;
             $newanswer->timemodified = time();
             $DB->update_record("choice_answers", $newanswer);
+            choice_double_check_choice($formanswer, $newanswer->id, $choice->limitanswers, $maxans, $course->id);
 
             $eventdata = array();
             $eventdata['context'] = $context;
@@ -315,6 +319,7 @@ WHERE
             $newanswer->optionid = $formanswer;
             $newanswer->timemodified = time();
             $newanswer->id = $DB->insert_record("choice_answers", $newanswer);
+            choice_double_check_choice($formanswer, $newanswer->id, $choice->limitanswers, $maxans, $course->id);
 
             // Update completion state
             $completion = new completion_info($course);
@@ -760,6 +765,9 @@ function choice_get_response_data($choice, $cm, $groupmode) {
 
     if ($rawresponses) {
         foreach ($rawresponses as $response) {
+            if(!isset($allresponses[0][$response->userid])) {
+                $allresponses[0][$response->userid] = (object) array( 'id' => $response->userid,'username'=>'unenrolled');                
+            }
             if (isset($allresponses[0][$response->userid])) {   // This person is enrolled and in correct group
                 $allresponses[0][$response->userid]->timemodified = $response->timemodified;
                 $allresponses[$response->optionid][$response->userid] = clone($allresponses[0][$response->userid]);
@@ -874,3 +882,28 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) {
     $module_pagetype = array('mod-choice-*'=>get_string('page-mod-choice-x', 'choice'));
     return $module_pagetype;
 }
+
+/**
+ * double check whether a user choice saved to DB allready exceeds the given limit.
+ * If the limit is exceeded the choice is deleted, an error is printed and the process exits.
+ * REWORK need to be done, if choices of unenrolled users should not be concidered.
+ * @param int $optionid id of the choice the user made.
+ * @param int $id_of_newly_saved_choice_answer id of the users answer, that may be deleted.
+ * @param boolean $limitanswers $choice->limitanswers
+ * @param int $maxans maximum answer for that choice
+ */
+function choice_double_check_choice($optionid, $id_of_newly_saved_choice_answer, $limitanswers, $maxans,$courseid) {
+    if(!$limitanswers || empty($maxans)) {
+        return;
+    }
+    global $DB;
+    //get choice ids ordered by time modified & limit to max answers.
+    $answerids_within_limit = $DB->get_records('choice_answers', array("optionid" => $optionid),'timemodified','id', 0, $maxans);
+    //if answerid not within answerids_within_limit, answer exceeds limit
+    if (!array_key_exists($id_of_newly_saved_choice_answer, $answerids_within_limit)) {
+        $DB->delete_records('choice_answers',array("id" => $newanswer->id));
+        add_to_log($courseid, 'choice', 'undo_bocking','optionid='.$optionid );
+        print_error('choicefull', 'choice');
+        exit;
+    }
+}
diff --git a/mod/choice/renderer.php b/mod/choice/renderer.php
index d3c5af0..a53ff11 100644
--- a/mod/choice/renderer.php
+++ b/mod/choice/renderer.php
@@ -214,13 +214,16 @@ class mod_choice_renderer extends plugin_renderer_base {
                         }
 
                         $userfullname = fullname($user, $choices->fullnamecapability);
+                        if(empty($userfullname)) {
+                            $userfullname = 'unenrolled';
+                        }
                         if ($choices->viewresponsecapability && $choices->deleterepsonsecapability  && $optionid > 0) {
                             $attemptaction = html_writer::label($userfullname, 'attempt-user'.$user->id, false, array('class' => 'accesshide'));
                             $attemptaction .= html_writer::checkbox('attemptid[]', $user->id,'', null, array('id' => 'attempt-user'.$user->id));
                             $data .= html_writer::tag('div', $attemptaction, array('class'=>'attemptaction'));
                         }
-                        $userimage = $this->output->user_picture($user, array('courseid'=>$choices->courseid));
-                        $data .= html_writer::tag('div', $userimage, array('class'=>'image'));
+//                         $userimage = $this->output->user_picture($user, array('courseid'=>$choices->courseid));
+//                         $data .= html_writer::tag('div', $userimage, array('class'=>'image'));
 
                         $userlink = new moodle_url('/user/view.php', array('id'=>$user->id,'course'=>$choices->courseid));
                         $name = html_writer::tag('a', $userfullname, array('href'=>$userlink, 'class'=>'username'));
diff --git a/mod/choice/view.php b/mod/choice/view.php
index 44e0e00..c80b9cc 100644
--- a/mod/choice/view.php
+++ b/mod/choice/view.php
@@ -54,7 +54,7 @@
 
 /// Submit any new data if there is any
     if (data_submitted() && is_enrolled($context, NULL, 'mod/choice:choose') && confirm_sesskey()) {
-        $timenow = time();
+//        $timenow = time(); //not used
         if (has_capability('mod/choice:deleteresponses', $context)) {
             if ($action == 'delete') { //some responses need to be deleted
                 choice_delete_responses($attemptids, $choice, $cm, $course); //delete responses.
