Skip to content
Snippets Groups Projects
Commit a49d171e authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Secret is now generated if it's empty

parent a2b43005
No related branches found
No related tags found
1 merge request!117Activate deactivate tutors
......@@ -9,6 +9,11 @@ class ExportCSVTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.data = make_test_data(data_dict={
'exams': [{
'module_reference': 'Test Exam 01',
'total_score': 100,
'pass_score': 60,
}],
'submission_types': [
{
'name': '01. Sort',
......@@ -24,8 +29,8 @@ class ExportCSVTest(TestCase):
}
],
'students': [
{'username': 'student01'},
{'username': 'student02'}
{'username': 'student01', 'exam': 'Test Exam 01'},
{'username': 'student02', 'exam': 'Test Exam 01'}
],
'reviewers': [
{'username': 'reviewer'}
......@@ -81,6 +86,6 @@ class ExportCSVTest(TestCase):
def test_data_is_correct(self):
head, student1, student2, _ = self.response.content.split(b'\r\n')
self.assertIn(b'Matrikel;Name;Sum;01. Sort;02. Shuffle', head)
self.assertIn(b';;5;5;0', student1)
self.assertIn(b';;0;0;0', student2)
self.assertIn(b'Matrikel;Name;Exam;Sum;01. Sort;02. Shuffle', head)
self.assertIn(b';;Test Exam 01;5;5;0', student1)
self.assertIn(b';;Test Exam 01;0;0;0', student2)
......@@ -18,7 +18,7 @@ class StudentCSVExport(APIView):
def get_renderer_context(self):
context = super().get_renderer_context()
context['header'] = ('Matrikel', 'Name', 'Sum',
context['header'] = ('Matrikel', 'Name', 'Exam', 'Sum',
*SubmissionType.objects.values_list('name',
flat=True))
context['delimiter'] = ';'
......@@ -33,6 +33,7 @@ class StudentCSVExport(APIView):
content = [{'Matrikel': student.matrikel_no,
'Name': student.user.fullname,
'Sum': student.overall_score,
'Exam': student.exam.module_reference,
**student.score_per_submission()
} for student
in StudentInfo.get_annotated_score_submission_list()]
......
......@@ -12,6 +12,9 @@ const getters = {
},
getSubmissionType: state => pk => {
return state.submissionTypes[pk]
},
findStudentByUser: state => user => {
return Object.values(state.students).find((student: any) => student.user === user)
}
}
......
......@@ -19,7 +19,9 @@ DEBUG = False
SECRET_FILE = 'secret'
try:
SECRET_KEY = open(SECRET_FILE).read().strip()
except IOError:
if len(SECRET_KEY) == 0:
raise Exception
except (IOError, Exception):
try:
SECRET_KEY = ''.join(secrets.choice(string.printable)
for i in range(50))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment