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:
def test_can_validate_submission(self):
self._login()
self._go_to_subscription()
code = self._reconstruct_submission_code()
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()
def correct():
code = self._reconstruct_submission_code()
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))
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
user_snd = 'tutor_snd'
......@@ -225,13 +234,38 @@ class UntestedParent:
login(self.browser, self.live_server_url, user_snd, password)
self._go_to_subscription(stage='validate')
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('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(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):
def setUp(self):
......@@ -241,5 +275,6 @@ class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric):
self.role = UserAccount.TUTOR
fact.UserAccountFactory(
username=self.username,
password=self.password
password=self.password,
role=self.role
)
......@@ -24,6 +24,11 @@ class LoginPageTest(LiveServerTestCase):
def setUp(self):
self.test_data = make_test_data(data_dict={
'exams': [{
'module_reference': 'Test Exam 01',
'total_score': 100,
'pass_score': 60,
}],
'submission_types': [
{
'name': '01. Sort this or that',
......@@ -39,8 +44,16 @@ class LoginPageTest(LiveServerTestCase):
}
],
'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': [
{'username': 'tutor01', 'password': 'p'},
......
......@@ -94,11 +94,9 @@ class GradyUserFactory:
""" Creates a student. Defaults can be passed via kwargs like in
relation managers objects.update method. """
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:
student_info.matrikel_no = identifier
if exam:
student_info.exam = exam
student_info.save()
return user
......
......@@ -253,10 +253,9 @@ def do_load_submission_types():
def do_load_module_descriptions():
print('''
This loader imports descriptions of modules in an exam. This step is purely
optional -- Grady works just fine without these information. If you want to
distinguish students within one instance or give information about the
grading type you should provide this info.
This loader imports descriptions of modules in an exam. This information
is used to distinguish students within one instance or give information
about the grading type.
CSV file format: module_reference, total_score, pass_score, pass_only
......@@ -377,10 +376,11 @@ def do_load_submissions():
file = i('Get me the file with all the submissions',
'submissions.json', is_file=True)
exam_obj = {}
if ExamType.objects.all() and \
i('Do you want to add module/exam information?', NO):
if not ExamType.objects.all():
raise Exception('Modules need to be loaded before submissions.')
else:
exam_query_set = ExamType.objects.all()
print('Please select the corresponding module')
print('You have the following choices:\n')
for j, exam_type in enumerate(exam_query_set):
print(f'\t[{j}] {exam_type.module_reference}')
......