From 7b6c7ae3a602db27f642b9dbee4666fed19e7ee2 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 11 Jan 2016 14:08:11 -0600 Subject: [PATCH] Add lock_down_as_exam_session start rule attribute --- course/flow.py | 5 +++++ course/utils.py | 3 +++ course/validation.py | 1 + doc/flow.rst | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/course/flow.py b/course/flow.py index b7f20c1a..48d46941 100644 --- a/course/flow.py +++ b/course/flow.py @@ -941,6 +941,11 @@ def post_start_flow(pctx, fctx, flow_id): access_rules_tag=session_start_rule.tag_session, now_datetime=now_datetime) + if session_start_rule.lock_down_as_exam_session: + pctx.request.session[ + "relate_session_locked_to_exam_flow_session_pk"] = \ + session.pk + return redirect("relate-view_flow_page", pctx.course.identifier, session.id, 0) diff --git a/course/utils.py b/course/utils.py index 76bd498e..9eb45e03 100644 --- a/course/utils.py +++ b/course/utils.py @@ -61,6 +61,7 @@ class FlowSessionStartRule(FlowSessionRuleBase): "tag_session", "may_start_new_session", "may_list_existing_sessions", + "lock_down_as_exam_session", ] @@ -204,6 +205,8 @@ def get_session_start_rule(course, participation, role, flow_id, flow_desc, rule, "may_start_new_session", True), may_list_existing_sessions=getattr( rule, "may_list_existing_sessions", True), + lock_down_as_exam_session=getattr( + rule, "lock_down_as_exam_session", False), ) return FlowSessionStartRule( diff --git a/course/validation.py b/course/validation.py index 4076f6a4..6c2685b1 100644 --- a/course/validation.py +++ b/course/validation.py @@ -470,6 +470,7 @@ def validate_session_start_rule(ctx, location, nrule, tags): ("tag_session", (six.string_types, type(None))), ("may_start_new_session", bool), ("may_list_existing_sessions", bool), + ("lock_down_as_exam_session", bool), ] ) diff --git a/doc/flow.rst b/doc/flow.rst index 07d0778c..670774c4 100644 --- a/doc/flow.rst +++ b/doc/flow.rst @@ -340,6 +340,11 @@ Rules for starting new sessions (Mandatory) A Boolean (True/False) value indicating whether, if the rule applies, the participant may view a list of existing sessions. + .. attribute:: lock_down_as_exam_session + + (Optional) Once this flow has been started, access to all content + except for this session on this RELATE instance will be denied. + .. attribute:: tag_session (Optional) An identifier that will be applied to a newly-created session as a "tag". -- GitLab