diff --git a/quiz.module b/quiz.module
index e25c959..6af1565 100644
--- a/quiz.module
+++ b/quiz.module
@@ -1957,6 +1957,28 @@ function quiz_take_question($quiz, $question_number) {
 
   // Added the progress info to the view.
   $quiz_result = quiz_result_load($_SESSION['quiz'][$quiz->nid]['result_id']);
+  
+  // If time limits are enabled and a time limit is set for this quiz and we've reached the time limit, finalize the quiz attempt.
+  if (variable_get('quiz_has_timer', 0) && $quiz->time_limit && (REQUEST_TIME >= $quiz_result->time_start + $quiz->time_limit)) {
+    $score = quiz_end_scoring($_SESSION['quiz'][$quiz->nid]['result_id']);
+    
+    // Call hook_quiz_finished().
+    module_invoke_all('quiz_finished', $quiz, $score, $_SESSION['quiz'][$quiz->nid]);
+    
+    // Remove all information about this quiz from the session.
+    // @todo but for anon, we might have to keep some so they could access
+    // results
+    // When quiz is completed we need to make sure that even though the quiz has
+    // been removed from the session, that the user can still access the
+    // feedback for the last question, THEN go to the results page.
+    $_SESSION['quiz']['temp']['result_id'] = $quiz_result->result_id;
+    unset($_SESSION['quiz'][$quiz->nid]);
+    
+    drupal_set_message(t("Time limit reached! All answers entered before the end of the time limit have been submitted."), 'warning');
+    
+    drupal_goto("node/{$quiz->nid}/quiz-results/{$quiz_result->result_id}/view");
+  }
+  
   $questions = array();
   $i = 0;
   $found_pages = 0;

diff --git a/quiz.module b/quiz.module
index 68d760e..57dba44 100644
--- a/quiz.module
+++ b/quiz.module
@@ -2012,7 +2012,7 @@ function quiz_take_question($quiz, $question_number) {
     $js = "
             function finished() {
               // Find all buttons with a name of 'op'.
-              var buttons = jQuery('input[type=submit][name=op], button[type=submit][name=op]');
+              var buttons = jQuery('input[type=submit][name=op]:not(#edit-navigation-submit-hidden), button[type=submit][name=op]:not(#edit-navigation-submit-hidden)');
               // Filter out the ones that don't have the right op value.
               buttons = buttons.filter(function() {
                 return this.value == $button_op1 || this.value == $button_op2;
