Commit ff31afa0 by Muhammad Shoaib

added the test cases and css for the modal pop up.

parent f040c95f
...@@ -31,7 +31,7 @@ Backbone.ModalView = ...@@ -31,7 +31,7 @@ Backbone.ModalView =
pressingEscapeClosesModal: true, pressingEscapeClosesModal: true,
css: css:
{ {
"border": "2px solid #111", "border": "1px solid #111",
"display": "block", "display": "block",
"background-color": "#fff", "background-color": "#fff",
"-webkit-box-shadow": "0px 0px 15px 4px rgba(0, 0, 0, 0.5)", "-webkit-box-shadow": "0px 0px 15px 4px rgba(0, 0, 0, 0.5)",
...@@ -39,7 +39,8 @@ Backbone.ModalView = ...@@ -39,7 +39,8 @@ Backbone.ModalView =
"box-shadow": "0px 0px 15px 4px rgba(0, 0, 0, 0.5)", "box-shadow": "0px 0px 15px 4px rgba(0, 0, 0, 0.5)",
"-webkit-border-radius": "10px", "-webkit-border-radius": "10px",
"-moz-border-radius": "10px", "-moz-border-radius": "10px",
"border-radius": "10px" "border-radius": "6px",
"padding": "0px"
} }
}, },
...@@ -268,6 +269,34 @@ Backbone.ModalView = ...@@ -268,6 +269,34 @@ Backbone.ModalView =
}; };
$el.css( this.options.css); $el.css( this.options.css);
$el.find('.modal-header').css({
"color": "#1580b0",
"font-size": "20px",
"font-weight": "600",
"line-height": "normal",
"padding": "10px 15px",
"border-bottom": "1px solid #ccc"
});
$el.find('form').css({
"padding": "15px"
});
$el.find('form table.compact td').css({
"vertical-align": "middle",
"padding": "4px 8px"
});
$el.find('form label').css({
"display": "block",
"font-size": "14px",
"margin": 0
});
$el.find('form input[type="text"]').css({
"height": "26px",
"padding": "5px 8px"
});
$el.find('form input[type="submit"]').css({
"margin-top": "10px",
"padding": "2px 32px"
});
this.showModalBlanket(); this.showModalBlanket();
this.keyup = _.bind( this.keyup, this); this.keyup = _.bind( this.keyup, this);
...@@ -342,8 +371,8 @@ Backbone.ModalView = ...@@ -342,8 +371,8 @@ Backbone.ModalView =
$("<a href='#' id='modalCloseButton'>&#160;</a>") $("<a href='#' id='modalCloseButton'>&#160;</a>")
.css({ .css({
"position":"absolute", "position":"absolute",
"top":"-8px", "top": "-8px",
"right":"-513px", "right": "-495px",
"width":"32px", "width":"32px",
"height":"32px", "height":"32px",
"z-index": "999999", "z-index": "999999",
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td></td>
<td> <td>
<input id='addNewAllowance' type='submit' value='Save' /> <input id='addNewAllowance' type='submit' value='Save' />
</td> </td>
......
...@@ -16,7 +16,9 @@ from edx_proctoring.api import ( ...@@ -16,7 +16,9 @@ from edx_proctoring.api import (
get_exam_attempt, get_exam_attempt,
create_exam_attempt, create_exam_attempt,
get_student_view, get_student_view,
get_all_exams_for_course, get_exams_by_course_id,
get_allowances_for_course,
get_all_exams_for_course
) )
from edx_proctoring.exceptions import ( from edx_proctoring.exceptions import (
ProctoredExamAlreadyExists, ProctoredExamAlreadyExists,
...@@ -118,6 +120,15 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -118,6 +120,15 @@ class ProctoredExamApiTests(LoggedInTestCase):
proctored_exam_id=self.proctored_exam_id, user_id=self.user_id, key=self.key, value=self.value proctored_exam_id=self.proctored_exam_id, user_id=self.user_id, key=self.key, value=self.value
) )
def test_get_exams_by_course_id(self):
"""
Test to get the exams by course_id
"""
proctored_exams = get_exams_by_course_id(self.course_id)
self.assertEqual(len(proctored_exams), 1)
self.assertEqual(proctored_exams[0]['exam_name'], self.exam_name)
self.assertEqual(proctored_exams[0]['course_id'], self.course_id)
def test_create_duplicate_exam(self): def test_create_duplicate_exam(self):
""" """
Test to create a proctored exam that has already exist in the Test to create a proctored exam that has already exist in the
...@@ -208,6 +219,15 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -208,6 +219,15 @@ class ProctoredExamApiTests(LoggedInTestCase):
self.assertIsNotNone(student_allowance) self.assertIsNotNone(student_allowance)
self.assertEqual(student_allowance.value, 'new_value') self.assertEqual(student_allowance.value, 'new_value')
def test_get_allowances_for_course(self):
"""
Test to get all the allowances for a course.
"""
allowance = self._add_allowance_for_user()
course_allowances = get_allowances_for_course(self.course_id)
self.assertEqual(len(course_allowances), 1)
self.assertEqual(course_allowances[0]['proctored_exam']['course_id'], allowance.proctored_exam.course_id)
def test_get_non_existing_allowance(self): def test_get_non_existing_allowance(self):
""" """
Test to get an allowance which does not exist. Test to get an allowance which does not exist.
......
...@@ -276,6 +276,32 @@ class ProctoredExamViewTests(LoggedInTestCase): ...@@ -276,6 +276,32 @@ class ProctoredExamViewTests(LoggedInTestCase):
self.assertEqual(response_data['external_id'], proctored_exam.external_id) self.assertEqual(response_data['external_id'], proctored_exam.external_id)
self.assertEqual(response_data['time_limit_mins'], proctored_exam.time_limit_mins) self.assertEqual(response_data['time_limit_mins'], proctored_exam.time_limit_mins)
def test_get_exam_by_course_id(self):
"""
Tests the Get Exam by course id endpoint
"""
# Create an exam.
proctored_exam = ProctoredExam.objects.create(
course_id='a/b/c',
content_id='test_content',
exam_name='Test Exam',
external_id='123aXqe3',
time_limit_mins=90
)
response = self.client.get(
reverse('edx_proctoring.proctored_exam.exams_by_course_id', kwargs={
'course_id': proctored_exam.course_id
})
)
self.assertEqual(response.status_code, 200)
response_data = json.loads(response.content)
self.assertEqual(response_data[0]['course_id'], proctored_exam.course_id)
self.assertEqual(response_data[0]['exam_name'], proctored_exam.exam_name)
self.assertEqual(response_data[0]['content_id'], proctored_exam.content_id)
self.assertEqual(response_data[0]['external_id'], proctored_exam.external_id)
self.assertEqual(response_data[0]['time_limit_mins'], proctored_exam.time_limit_mins)
def test_get_exam_by_bad_content_id(self): def test_get_exam_by_bad_content_id(self):
""" """
Tests the Get Exam by content id endpoint Tests the Get Exam by content id endpoint
...@@ -613,6 +639,40 @@ class TestExamAllowanceView(LoggedInTestCase): ...@@ -613,6 +639,40 @@ class TestExamAllowanceView(LoggedInTestCase):
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_get_allowances_for_course(self):
"""
Remove allowance for a user for an exam.
"""
# Create an exam.
proctored_exam = ProctoredExam.objects.create(
course_id='a/b/c',
content_id='test_content',
exam_name='Test Exam',
external_id='123aXqe3',
time_limit_mins=90
)
allowance_data = {
'exam_id': proctored_exam.id,
'user_id': self.student_taking_exam.id,
'key': 'a_key',
'value': '30'
}
response = self.client.put(
reverse('edx_proctoring.proctored_exam.allowance'),
allowance_data
)
self.assertEqual(response.status_code, 200)
response = self.client.get(
reverse('edx_proctoring.proctored_exam.allowance', kwargs={'course_id': proctored_exam.course_id})
)
self.assertEqual(response.status_code, 200)
response_data = json.loads(response.content)
self.assertEqual(len(response_data), 1)
self.assertEqual(response_data[0]['proctored_exam']['course_id'], proctored_exam.course_id)
self.assertEqual(response_data[0]['key'], allowance_data['key'])
class TestActiveExamsForUserView(LoggedInTestCase): class TestActiveExamsForUserView(LoggedInTestCase):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment