diff options
-rw-r--r-- | grades/forms.py | 1 | ||||
-rw-r--r-- | online_test/settings.py | 3 | ||||
-rw-r--r-- | yaksh/forms.py | 22 | ||||
-rw-r--r-- | yaksh/models.py | 9 | ||||
-rw-r--r-- | yaksh/test_models.py | 40 | ||||
-rw-r--r-- | yaksh/views.py | 9 |
6 files changed, 64 insertions, 20 deletions
diff --git a/grades/forms.py b/grades/forms.py index 4f9c9a7..745abff 100644 --- a/grades/forms.py +++ b/grades/forms.py @@ -34,6 +34,7 @@ class GradeRangeForm(forms.ModelForm): {'class': "form-control", 'placeholder': 'Description'} ) + class Meta: model = GradeRange fields = "__all__" diff --git a/online_test/settings.py b/online_test/settings.py index 6ff31f8..7129e83 100644 --- a/online_test/settings.py +++ b/online_test/settings.py @@ -165,7 +165,7 @@ TEMPLATES = [ 'social_django.context_processors.login_redirect', 'django.contrib.messages.context_processors.messages', ], - 'debug': True, # make this False in production + 'debug': True, # make this False in production } }, ] @@ -188,4 +188,3 @@ SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = { 'fields': 'id, name, email' } - diff --git a/yaksh/forms.py b/yaksh/forms.py index 767e51f..7d5362b 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -75,15 +75,17 @@ class UserRegisterForm(forms.Form): It has the various fields and functions required to register a new user to the system""" - username = forms.CharField(max_length=30, help_text='Letters, digits,\ + username = forms.CharField( + max_length=30, help_text='Letters, digits,\ period and underscores only.', - widget=forms.TextInput( - {'class': form_input_class, 'placeholder': "Username"}) - ) + widget=forms.TextInput( + {'class': form_input_class, 'placeholder': "Username"}) + ) email = forms.EmailField(widget=forms.TextInput( {'class': form_input_class, 'placeholder': "Email"} )) - password = forms.CharField(max_length=30, + password = forms.CharField( + max_length=30, widget=forms.PasswordInput( {'class': form_input_class, 'placeholder': "Password"})) confirm_password = forms.CharField( @@ -99,23 +101,23 @@ class UserRegisterForm(forms.Form): roll_number = forms.CharField( max_length=30, help_text="Use a dummy if you don't have one.", widget=forms.TextInput( - {'class': form_input_class, 'placeholder': "Roll Number"} + {'class': form_input_class, 'placeholder': "Roll Number"} )) institute = forms.CharField( max_length=128, help_text='Institute/Organization', widget=forms.TextInput( - {'class': form_input_class, 'placeholder': "Institute"} + {'class': form_input_class, 'placeholder': "Institute"} )) department = forms.CharField( max_length=64, help_text='Department you work/study at', widget=forms.TextInput( - {'class': form_input_class, 'placeholder': "Department"} + {'class': form_input_class, 'placeholder': "Department"} )) position = forms.CharField( max_length=64, help_text='Student/Faculty/Researcher/Industry/Fellowship/etc.', widget=forms.TextInput( - {'class': form_input_class, 'placeholder': "Position"} + {'class': form_input_class, 'placeholder': "Position"} )) timezone = forms.ChoiceField( choices=[(tz, tz) for tz in pytz.common_timezones], @@ -420,7 +422,7 @@ class CourseForm(forms.ModelForm): {'class': 'custom-select'} ) if (self.instance.id and - self.instance.teachers.filter(id=user.id).exists()): + self.instance.teachers.filter(id=user.id).exists()): self.fields['grading_system'].widget.attrs['disabled'] = True else: grading_choices = GradingSystem.objects.filter( diff --git a/yaksh/models.py b/yaksh/models.py index e9c025f..3894165 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -317,7 +317,8 @@ class Lesson(models.Model): lesson_file.file.name))) zip_file.writestr(filename, lesson_file.file.read()) unit_file_path = os.sep.join(( - path, "templates", "yaksh", "download_course_templates", "unit.html" + path, "templates", "yaksh", "download_course_templates", + "unit.html" )) lesson_data = {"course": course, "module": module, "lesson": self, "next_unit": next_unit, @@ -577,7 +578,8 @@ class Quiz(models.Model): course_name, module_name, quiz_name )) unit_file_path = os.sep.join(( - path, "templates", "yaksh", "download_course_templates", "quiz.html" + path, "templates", "yaksh", "download_course_templates", + "quiz.html" )) quiz_data = {"course": course, "module": module, "quiz": self, "next_unit": next_unit} @@ -813,7 +815,8 @@ class LearningModule(models.Model): path) module_file_path = os.sep.join(( - path, "templates", "yaksh", "download_course_templates", "module.html" + path, "templates", "yaksh", "download_course_templates", + "module.html" )) module_data = {"course": course, "module": self, "units": units} write_templates_to_zip(zip_file, module_file_path, module_data, diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 4d91b27..6e5a26d 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -589,6 +589,46 @@ class QuestionTestCases(unittest.TestCase): ) self.assertEqual(msg, "Unable to parse test case data") + def test_get_test_case_options(self): + """ + Test if test case options are selected based on + question type and language + """ + + # Given + question_types = [ + "mcq", "integer", "float", "string", "arrange", "upload" + ] + que_list = [] + for i, q_type in enumerate(question_types, 1): + que_list.append(Question.objects.create( + summary='Python Question {0}'.format(i), language='python', + type=q_type, active=True, + description='{0} Question'.format(q_type), + points=1.0, user=self.user1 + )) + + # When + expected_tc_options = [ + ('standardtestcase', 'Standard TestCase'), + ('stdiobasedtestcase', 'StdIO TestCase'), + ('hooktestcase', 'Hook TestCase') + ] + other_tc_options = [ + ('mcqtestcase', 'Mcq TestCase'), + ('integertestcase', 'Integer TestCase'), + ('floattestcase', 'Float TestCase'), + ('stringtestcase', 'String TestCase'), + ('arrangetestcase', 'Arrange TestCase'), + ('hooktestcase', 'Hook TestCase') + ] + + # Then + obtained_tc_options = self.question2.get_test_case_options() + self.assertEqual(expected_tc_options, obtained_tc_options) + for que, tc_option in zip(que_list, other_tc_options): + self.assertEqual(que.get_test_case_options()[0], tc_option) + ############################################################################### class QuizTestCases(unittest.TestCase): diff --git a/yaksh/views.py b/yaksh/views.py index 0ae4a14..8ac8343 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1551,8 +1551,7 @@ def show_all_questions(request): ques = Question() if file_extension == "zip": files, extract_path = extract_files(questions_file) - message = ques.read_yaml(extract_path, user, - files) + message = ques.read_yaml(extract_path, user, files) elif file_extension in ["yaml", "yml"]: questions = questions_file.read() message = ques.load_questions(questions, user) @@ -1572,8 +1571,7 @@ def show_all_questions(request): response.write(zip_file.read()) return response else: - message = ("Please select atleast " + - "one question to download") + message = "Please select atleast one question to download" if request.POST.get('test') == 'test': question_ids = request.POST.getlist("question") @@ -2320,7 +2318,8 @@ def _read_user_csv(request, reader, course): counter, user.username)) else: _add_to_course(user, course) - messages.info(request, + messages.info( + request, "{0} -- {1} -- User Added Successfully".format( counter, user.username)) continue |