Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • j.michal/grady
1 result
Show changes
...@@ -211,11 +211,20 @@ class UntestedParent: ...@@ -211,11 +211,20 @@ class UntestedParent:
def test_can_validate_submission(self): def test_can_validate_submission(self):
self._login() self._login()
self._go_to_subscription() self._go_to_subscription()
code = self._reconstruct_submission_code()
self.write_comments_on_lines([(0, 'A comment by me')]) def correct():
self.browser.find_element_by_id('score-zero').click() code = self._reconstruct_submission_code()
self.browser.find_element_by_id('submit-feedback').click() self.write_comments_on_lines([(0, 'A comment by me')])
self.browser.find_element_by_id('score-zero').click()
self.browser.find_element_by_id('submit-feedback').click()
return code
code = correct()
WebDriverWait(self.browser, 10).until(self.wait_until_code_changes(code)) WebDriverWait(self.browser, 10).until(self.wait_until_code_changes(code))
correct()
sub_url = 'subscription/' + str(self.sub_type.pk) + '/ended'
WebDriverWait(self.browser, 10).until(ec.url_contains(sub_url))
reset_browser_after_test(self.browser, self.live_server_url) # logs out user reset_browser_after_test(self.browser, self.live_server_url) # logs out user
user_snd = 'tutor_snd' user_snd = 'tutor_snd'
...@@ -225,13 +234,38 @@ class UntestedParent: ...@@ -225,13 +234,38 @@ class UntestedParent:
login(self.browser, self.live_server_url, user_snd, password) login(self.browser, self.live_server_url, user_snd, password)
self._go_to_subscription(stage='validate') self._go_to_subscription(stage='validate')
self.write_comments_on_lines([(0, 'I disagree'), (1, 'Full points!')]) self.write_comments_on_lines([(0, 'I disagree'), (1, 'Full points!')])
code_final = self._reconstruct_submission_code()
self.browser.find_element_by_id('score-full').click() self.browser.find_element_by_id('score-full').click()
self.browser.find_element_by_id('submit-feedback').click() self.browser.find_element_by_id('submit-feedback').click()
WebDriverWait(self.browser, 10).until(ec.url_contains('subscription/ended'))
submission_for_code = Submission.objects.get(text=code) WebDriverWait(self.browser, 10).until(self.wait_until_code_changes(code_final))
code_non_final = self._reconstruct_submission_code()
self.browser.find_element_by_class_name('final-checkbox').click()
self.browser.find_element_by_id('submit-feedback').click()
sub_url = 'subscription/' + str(self.sub_type.pk) + '/ended'
WebDriverWait(self.browser, 10).until(ec.url_contains(sub_url))
reset_browser_after_test(self.browser, self.live_server_url)
user_rev = 'rev'
password = 'p'
role = UserAccount.REVIEWER
fact.UserAccountFactory(username=user_rev, password=password, role=role)
login(self.browser, self.live_server_url, user_rev, password)
self._go_to_subscription('conflict')
code = self._reconstruct_submission_code()
self.assertEqual(code, code_non_final)
submission_for_code = Submission.objects.get(text=code_final)
self.assertEqual(self.sub_type.full_score, submission_for_code.feedback.score) self.assertEqual(self.sub_type.full_score, submission_for_code.feedback.score)
self.assertEqual(3, submission_for_code.feedback.feedback_lines.count()) self.assertEqual(3, submission_for_code.feedback.feedback_lines.count())
submission_for_code = Submission.objects.get(text=code_non_final)
self.assertEqual(0, submission_for_code.feedback.score)
self.assertEqual(1, submission_for_code.feedback.feedback_lines.count())
class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric): class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric):
def setUp(self): def setUp(self):
...@@ -241,5 +275,6 @@ class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric): ...@@ -241,5 +275,6 @@ class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric):
self.role = UserAccount.TUTOR self.role = UserAccount.TUTOR
fact.UserAccountFactory( fact.UserAccountFactory(
username=self.username, username=self.username,
password=self.password password=self.password,
role=self.role
) )
...@@ -24,6 +24,11 @@ class LoginPageTest(LiveServerTestCase): ...@@ -24,6 +24,11 @@ class LoginPageTest(LiveServerTestCase):
def setUp(self): def setUp(self):
self.test_data = make_test_data(data_dict={ self.test_data = make_test_data(data_dict={
'exams': [{
'module_reference': 'Test Exam 01',
'total_score': 100,
'pass_score': 60,
}],
'submission_types': [ 'submission_types': [
{ {
'name': '01. Sort this or that', 'name': '01. Sort this or that',
...@@ -39,8 +44,16 @@ class LoginPageTest(LiveServerTestCase): ...@@ -39,8 +44,16 @@ class LoginPageTest(LiveServerTestCase):
} }
], ],
'students': [ 'students': [
{'username': 'student01', 'password': 'p'}, {
{'username': 'student02', 'password': 'p'} 'username': 'student01',
'password': 'p',
'exam': 'Test Exam 01'
},
{
'username': 'student02',
'password': 'p',
'exam': 'Test Exam 01'
}
], ],
'tutors': [ 'tutors': [
{'username': 'tutor01', 'password': 'p'}, {'username': 'tutor01', 'password': 'p'},
......
...@@ -94,11 +94,9 @@ class GradyUserFactory: ...@@ -94,11 +94,9 @@ class GradyUserFactory:
""" Creates a student. Defaults can be passed via kwargs like in """ Creates a student. Defaults can be passed via kwargs like in
relation managers objects.update method. """ relation managers objects.update method. """
user = self._make_base_user(username, 'Student', **kwargs) user = self._make_base_user(username, 'Student', **kwargs)
student_info = StudentInfo.objects.get_or_create(user=user)[0] student_info = StudentInfo.objects.get_or_create(user=user, exam=exam)[0]
if identifier: if identifier:
student_info.matrikel_no = identifier student_info.matrikel_no = identifier
if exam:
student_info.exam = exam
student_info.save() student_info.save()
return user return user
......
...@@ -253,10 +253,9 @@ def do_load_submission_types(): ...@@ -253,10 +253,9 @@ def do_load_submission_types():
def do_load_module_descriptions(): def do_load_module_descriptions():
print(''' print('''
This loader imports descriptions of modules in an exam. This step is purely This loader imports descriptions of modules in an exam. This information
optional -- Grady works just fine without these information. If you want to is used to distinguish students within one instance or give information
distinguish students within one instance or give information about the about the grading type.
grading type you should provide this info.
CSV file format: module_reference, total_score, pass_score, pass_only CSV file format: module_reference, total_score, pass_score, pass_only
...@@ -377,10 +376,11 @@ def do_load_submissions(): ...@@ -377,10 +376,11 @@ def do_load_submissions():
file = i('Get me the file with all the submissions', file = i('Get me the file with all the submissions',
'submissions.json', is_file=True) 'submissions.json', is_file=True)
exam_obj = {} if not ExamType.objects.all():
if ExamType.objects.all() and \ raise Exception('Modules need to be loaded before submissions.')
i('Do you want to add module/exam information?', NO): else:
exam_query_set = ExamType.objects.all() exam_query_set = ExamType.objects.all()
print('Please select the corresponding module')
print('You have the following choices:\n') print('You have the following choices:\n')
for j, exam_type in enumerate(exam_query_set): for j, exam_type in enumerate(exam_query_set):
print(f'\t[{j}] {exam_type.module_reference}') print(f'\t[{j}] {exam_type.module_reference}')
......