SHARE
TWEET

Untitled

a guest Aug 20th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @method_decorator([login_required, teacher_required], name='dispatch')
  2. class QuizResultsView(DetailView):
  3.     model = Quiz
  4.     context_object_name = 'quiz'
  5.     template_name = 'classroom/teachers/quiz_results.html'
  6.  
  7.     def get_context_data (self, **kwargs):
  8.         quiz = self.get_object()
  9.  
  10.         if (quiz.status == 'Assigned'):
  11.  
  12.             """Some Code"""
  13.  
  14.             cursor = connection.cursor()
  15.  
  16.  
  17.             def dictfetchall (cursor):
  18.                 desc = cursor.description
  19.                 return [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
  20.  
  21.             """ Some More Code """
  22.  
  23.             extra_context = {'taken_quizzes': taken_quizzes, 'total_taken_quizzes': total_taken_quizzes,
  24.                              'quiz_score': quiz_score, 'least_bid': least_bid, 'matching_bids': matching_bids,
  25.                              'driver_num': driver_num, 'lat_lon_orig': lat_lon_orig, 'lat_lon_dest': lat_lon_dest,
  26.                              'user_pass': user_pass, 'username': username, 'password': password, }
  27.  
  28.  
  29.             kwargs.update(extra_context)
  30.  
  31.  
  32.             return super().get_context_data(**kwargs)
  33.  
  34.  
  35.         else:
  36.  
  37.             cursor = connection.cursor()
  38.  
  39.             def dictfetchall (cursor):
  40.                 desc = cursor.description
  41.                 return [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
  42.  
  43.             cursor.execute('''SELECT STATEMENT''', [quiz.id])
  44.  
  45.         """ Some More Code """
  46.  
  47.  
  48.             extra_context = {'taken_quizzes': taken_quizzes, 'total_taken_quizzes': total_taken_quizzes,
  49.                              'quiz_score': quiz_score, 'least_bid': least_bid, 'matching_bids': matching_bids}
  50.             kwargs.update(extra_context)
  51.  
  52.             return super().get_context_data(**kwargs)
  53.  
  54.     def get_queryset (self):
  55.         return self.request.user.quizzes.all()
  56.      
  57. REST_FRAMEWORK = {
  58.     'DEFAULT_RENDERER_CLASSES': [
  59.         'rest_framework.renderers.JSONRenderer',
  60.         'rest_framework.renderers.BrowsableAPIRenderer',
  61.     ]
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top