From 987fd4d1ba0ab105ae3565a068768e08e3551a5b Mon Sep 17 00:00:00 2001 From: alangsto <46360176+alangsto@users.noreply.github.com> Date: Tue, 28 Jul 2020 16:43:16 -0400 Subject: [PATCH] Changes what fields are displayed depending on user role (#22) * hides fields based on user permissions * updates for requested changes --- .../ProctoredExamSettings.jsx | 126 +++++++++--------- .../ProctoredExamSettings.test.jsx | 45 ++++++- 2 files changed, 110 insertions(+), 61 deletions(-) diff --git a/src/proctored-exam-settings/ProctoredExamSettings.jsx b/src/proctored-exam-settings/ProctoredExamSettings.jsx index fc4bfa809..010b45692 100644 --- a/src/proctored-exam-settings/ProctoredExamSettings.jsx +++ b/src/proctored-exam-settings/ProctoredExamSettings.jsx @@ -28,6 +28,7 @@ function ExamSettings(props) { const [saveError, setSaveError] = useState(false); const [submissionInProgress, setSubmissionInProgress] = useState(false); const [showProctortrackEscalationEmail, setShowProctortrackEscalationEmail] = useState(false); + const isEdxStaff = getAuthenticatedUser().administrator; function onEnableProctoredExamsChange(event) { setEnableProctoredExams(event.target.checked); @@ -96,10 +97,8 @@ function ExamSettings(props) { const currentDate = moment(moment()).format('YYYY-MM-DD[T]hh:mm:ss[Z]'); const isAfterCourseStart = currentDate > courseStartDate; - const isAdmin = getAuthenticatedUser().administrator; - - // if the user is not an administrator and it is after the course start date, user cannot edit proctoring provider - return !isAdmin && isAfterCourseStart; + // if the user is not edX staff and it is after the course start date, user cannot edit proctoring provider + return !isEdxStaff && isAfterCourseStart; } function isDisabledOption(provider) { @@ -154,34 +153,38 @@ function ExamSettings(props) { {/* ALLOW OPTING OUT OF PROCTORED EXAMS */} -
- - Allow Opting Out of Proctored Exams - onAllowOptingOutChange(true)} - /> - onAllowOptingOutChange(false)} - /> - - If this value is "Yes", learners can choose to take proctored exams without proctoring. - If this value is "No", all learners must take the exam with proctoring. - This setting only applies if proctored exams are enabled for the course. - - -
+ { isEdxStaff && ( +
+ + Allow Opting Out of Proctored Exams + onAllowOptingOutChange(true)} + data-test-id="allowOptingOutYes" + /> + onAllowOptingOutChange(false)} + data-test-id="allowOptingOutNo" + /> + + If this value is "Yes", learners can choose to take proctored exams without proctoring. + If this value is "No", all learners must take the exam with proctoring. + This setting only applies if proctored exams are enabled for the course. + + +
+ )} {/* PROCTORING PROVIDER */} @@ -217,34 +220,37 @@ function ExamSettings(props) { )} {/* CREATE ZENDESK TICKETS */} -
- - Create Zendesk Tickets for Suspicious Proctored Exam Attempts - onCreateZendeskTicketsChange(true)} - data-test-id="createZendeskTicketsYes" - /> - onCreateZendeskTicketsChange(false)} - data-test-id="createZendeskTicketsNo" - /> - - If this value is "Yes", a Zendesk ticket will be created for suspicious proctored exam attempts. - - -
+ { isEdxStaff && ( +
+ + Create Zendesk Tickets for Suspicious Proctored Exam Attempts + onCreateZendeskTicketsChange(true)} + data-test-id="createZendeskTicketsYes" + /> + onCreateZendeskTicketsChange(false)} + data-test-id="createZendeskTicketsNo" + /> + + If this value is "Yes", + a Zendesk ticket will be created for suspicious proctored exam attempts. + + +
+ )}