def dashboard_view(self, context): fragment = Fragment() children_context = self._sanitize_context(context) self._add_students_and_workgroups_to_context(children_context) activity_fragments = self._render_children('dashboard_view', children_context, self.activities) activity_contents = [frag.content for frag in activity_fragments] fragment.add_frags_resources(activity_fragments) render_context = { 'project': self, 'activity_contents': activity_contents } fragment.add_content( self.render_template('dashboard_view', render_context)) add_resource(self, 'css', 'public/css/group_project_common.css', fragment) add_resource(self, 'css', 'public/css/group_project_dashboard.css', fragment) add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True) return fragment
def fallback_view(self, view_name, context=None): result = Fragment() child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) result.content = self.content result.add_content(self.runtime.render_template("vertical.html", children=child_frags)) return result
def student_view(self, context=None): template = self.get_template('vertical.html', self.templates_dirs) child_frags = self.runtime.render_children(self, context=context) result = Fragment() result.add_frags_resources(child_frags) result.add_content(template.render( {'children': [frag.body_html() for frag in child_frags]})) return result
def student_view(self,context): result = Fragment() child_frags = self.runtime.render_children(self,context,'thumb_view') result.add_frags_resources(child_frags) all_html = self.runtime.render_template("static/html/verticalqueue.html", child_frags=child_frags) result.add_content(all_html) return result
def student_view(self, context=None): template = self.get_template('vertical.html', self.templates_dirs) child_frags = self.runtime.render_children(self, context=context) result = Fragment() result.add_frags_resources(child_frags) result.add_content( template.render( {'children': [frag.body_html() for frag in child_frags]})) return result
def fallback_view(self, view_name, context=None): result = Fragment() child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) result.content = self.content result.add_content( self.runtime.render_template("vertical.html", children=child_frags)) return result
def staff_view(self): fragment = Fragment(self._render_template('static/html/staff-view.html')) child_frags = self.runtime.render_children(block=self, view_name='student_view') html = self._render_template('static/html/sequence.html', children=child_frags) fragment.add_content(html) fragment.add_frags_resources(child_frags) fragment.add_javascript(self.resource_string("static/js/src/lms_view.js")) fragment.initialize_js('PasswordContainerLmsView') return fragment
def student_view(self, context=None): if self._is_studio(): # studio view fragment = Fragment(self._render_template('static/html/studio.html')) fragment.add_css(self.resource_string('static/css/password-container.css')) return fragment if self._user_is_staff(): return self.staff_view() else: # student view if self.configuration.start_date and self.configuration.end_date: user_started = self.get_user_started() now = timezone.now() if (now > self.configuration.start_date and now < self.configuration.end_date): # with are in the availability interval if self.get_user_allowed(): # user is granted (entered a good password) if self.configuration.duration and (now > user_started + datetime.timedelta(minutes=self.configuration.duration)): # time allowed to access content is elapsed fragment = Fragment(self._render_template('static/html/5-time-elapsed.html')) fragment.initialize_js('PasswordContainerXBlock', 'bindResetButton') # call Run to allow reset in debug mode else: # content is available fragment = Fragment(self._render_template('static/html/3-available.html')) child_frags = self.runtime.render_children(block=self, view_name='student_view', context=context) html = self._render_template('static/html/sequence.html', children=child_frags) fragment.add_content(html) fragment.add_frags_resources(child_frags) fragment.initialize_js('PasswordContainerXBlock', 'startExam') else: # user is not granted if self.get_nb_tries() < MAX_TRIES: # password is now required fragment = Fragment(self._render_template('static/html/2-enter-password.html')) child_frags = self.runtime.render_children(block=self, view_name='student_view', context=context) fragment.add_frags_resources(child_frags) fragment.initialize_js('PasswordContainerXBlock', 'checkPassword') else: # too much password failures fragment = Fragment(self._render_template('static/html/4-not-available-anymore.html')) elif now > self.configuration.end_date: # content is no more available fragment = Fragment(self._render_template('static/html/4-not-available-anymore.html')) else: # content is not yet available fragment = Fragment(self._render_template('static/html/1-not-yet-available.html')) fragment.add_css(self.resource_string('static/css/password-container.css')) fragment.add_javascript(self.resource_string("static/js/src/password_container.js")) return fragment # we should not be here ! frag = Fragment(u"Cette activité n'est pas disponible") return frag
def view(self, context=None): """Provide default student view.""" result = Fragment() child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) result.add_css(u""" .vertical { border: solid 1px #888; padding: 3px; } """) result.add_content(self.runtime.render_template("vertical.html", children=child_frags)) return result
def dashboard_view(self, context): fragment = Fragment() children_context = context.copy() stage_fragments = self._render_children('dashboard_view', children_context, self.stages) stage_contents = [frag.content for frag in stage_fragments] fragment.add_frags_resources(stage_fragments) render_context = {'activity': self, 'stage_contents': stage_contents} fragment.add_content(self.render_template('dashboard_view', render_context)) return fragment
def view(self, context=None): """Provide default student view.""" result = Fragment() child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) result.add_css(u""" .vertical { border: solid 1px #888; padding: 3px; } """) result.add_content( self.runtime.render_template("vertical.html", children=child_frags)) return result
def resources_view(self, context): fragment = Fragment() resources = [resource for stage in self.stages for resource in stage.resources] has_resources = bool(resources) resource_fragments = self._render_children('resources_view', context, resources) resource_contents = [frag.content for frag in resource_fragments] fragment.add_frags_resources(resource_fragments) render_context = {'activity': self, 'resource_contents': resource_contents, 'has_resources': has_resources} fragment.add_content(self.render_template('resources_view', render_context)) return fragment
def navigation_view(self, context): fragment = Fragment() children_context = {} children_context.update(context) stage_fragments = self._render_children('navigation_view', children_context, self.available_stages) stage_contents = [frag.content for frag in stage_fragments] fragment.add_frags_resources(stage_fragments) render_context = {'activity': self, 'stage_contents': stage_contents} fragment.add_content(self.render_template('navigation_view', render_context)) return fragment
def fallback_view(self, view_name, context=None): # pylint: disable=W0613 """ This view is used by the Acid XBlock to test various features of the runtime it is contained in """ acid_fragment = super(AcidParentBlock, self).fallback_view(view_name, context=context) # Save the changes to our fields so that they are visible to our children self.save() children = [ self.runtime.get_block(child_id) for child_id in self.children ] rendered_children = [ self.runtime.render_child(child, view_name, context=context) for child in children ] child_values = { child.name: child.parent_value for child in children if child.scope_ids.block_type == 'acid' and child.name is not None } frag = Fragment( self.render_template( 'html/acid_parent.html.mako', error_class=self.ERROR_CLASS, success_class=self.SUCCESS_CLASS, failure_class=self.FAILURE_CLASS, unknown_class=self.UNKNOWN_CLASS, acid_html=acid_fragment.content, acid_child_values=child_values, acid_child_count=len([ child for child in children if child.scope_ids.block_type == 'acid' ]), rendered_children=(fragment.content for fragment in rendered_children), local_resource_url=self.runtime.local_resource_url( self, 'public/test_data.json'), )) frag.add_frag_resources(acid_fragment) frag.add_frags_resources(rendered_children) frag.add_javascript(self.resource_string('static/js/acid_parent.js')) frag.initialize_js('AcidParentBlock') return frag
def student_view(self, context=None): """ The primary view of the PatientInteractionXBlock, shown to students when viewing courses. """ result = Fragment() result.add_css(resource_string("static/css/pinteraction.css")) result.add_css(resource_string("static/css/icons.css")) child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) html = self.render_template("templates/pinteraction.html",{"children":child_frags, "question":self.question, "name":self.name}) result.add_content(html) result.add_javascript(resource_string("static/js/src/pinteraction.js")) result.initialize_js('PatientInteractionXBlock') return result
def dashboard_view(self, context): fragment = Fragment() children_context = self._sanitize_context(context) self._add_students_and_workgroups_to_context(children_context) activity_fragments = self._render_children('dashboard_view', children_context, self.activities) activity_contents = [frag.content for frag in activity_fragments] fragment.add_frags_resources(activity_fragments) render_context = {'project': self, 'activity_contents': activity_contents} fragment.add_content(self.render_template('dashboard_view', render_context)) add_resource(self, 'css', 'public/css/group_project_common.css', fragment) add_resource(self, 'css', 'public/css/group_project_dashboard.css', fragment) add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True) return fragment
def student_view(self, context=None): user_allowed = False user_state = {} message = "" lti_parameters = {} fragment = Fragment() context.update(self._get_context_for_template()) child_fragments = self.runtime.render_children(block=self, view_name='student_view', context=context) context.update({"child_fragments": child_fragments}) if self._is_studio(): # studio view context["lms_link"] = get_lms_link_for_item(self.location) if get_lms_link_for_item else "" fragment.add_content(self._render_template('static/html/studio.html', context)) else: # Student view if self.launch_url and self._get_exam_id(): try: lti_consumer = LtiConsumer(self) lti_parameters = lti_consumer.get_signed_lti_parameters() exam_id = self._get_exam_id() user_state = self.get_proctorexam_user_state( self._get_exam_id(), lti_parameters ) context["user_state"] = user_state except LtiError: message = _("Proctor Exam xblock configuration is incomplete, LTI passport is invalid") else: message = _("Proctor Exam xblock configuration is incomplete, exam URL is missing") if user_state and "student" in user_state and (user_state["student"].get("status") == "exam_started"): # User have completed Proctor Exam indentification process, # we show him exam content html = self._render_template('static/html/sequence.html', context) fragment.add_content(html) fragment.add_frags_resources(child_fragments) else: if self._allowed_verified(): # User have to complete Proctor Exam indentification process context.update({'lti_parameters': lti_parameters, "message": message}) html = self._render_template("static/html/student.html", context) else: html = self._render_template("static/html/honor.html", context) fragment.add_content(html) fragment.add_css(self.resource_string('static/css/student.css')) return fragment
def view(self, context=None): """Provide default student view.""" result = Fragment() child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) result.add_css(u""" .sidebar { border: solid 1px #888; padding: 10px; background: #ccc; } """) html = [] html.append(u"<div class='sidebar'>") for child in child_frags: html.append(child.body_html()) html.append(u"</div>") result.add_content("".join(html)) return result
def view(self, context=None): """Provide default student view.""" frag = Fragment() child_frags = self.runtime.render_children(self, context=context) frag.add_frags_resources(child_frags) frag.add_content(self.runtime.render_template("sequence.html", children=child_frags)) frag.add_css_url('http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css') frag.add_javascript_url('http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js') # mess things up frag.add_javascript(u""" function Sequence(runtime, element) { $(element).children('.tabs').tabs(); }; """) frag.initialize_js('Sequence') return frag
def fallback_view(self, view_name, context=None): # pylint: disable=W0613 """ This view is used by the Acid XBlock to test various features of the runtime it is contained in """ acid_fragment = super(AcidParentBlock, self).fallback_view(view_name, context=context) # Save the changes to our fields so that they are visible to our children self.save() children = [ self.runtime.get_block(child_id) for child_id in self.children ] rendered_children = [ self.runtime.render_child(child, view_name, context=context) for child in children ] child_values = { child.name: child.parent_value for child in children if child.scope_ids.block_type == 'acid' and child.name is not None } frag = Fragment(self.render_template( 'html/acid_parent.html.mako', error_class=self.ERROR_CLASS, success_class=self.SUCCESS_CLASS, failure_class=self.FAILURE_CLASS, unknown_class=self.UNKNOWN_CLASS, acid_html=acid_fragment.content, acid_child_values=child_values, acid_child_count=len([child for child in children if child.scope_ids.block_type == 'acid']), rendered_children=(fragment.content for fragment in rendered_children), local_resource_url=self.runtime.local_resource_url(self, 'public/test_data.json'), )) frag.add_frag_resources(acid_fragment) frag.add_frags_resources(rendered_children) frag.add_javascript(self.resource_string('static/js/acid_parent.js')) frag.initialize_js('AcidParentBlock') return frag
def view(self, context=None): """Provide default student view.""" result = Fragment() child_frags = self.runtime.render_children(self, context=context) result.add_frags_resources(child_frags) result.add_css(u""" .sidebar { border: solid 1px #888; padding: 10px; background: #ccc; } """) html = [] html.append(u"<div class='sidebar'>") for child in child_frags: html.append(child.body_html()) html.append(u"</div>") result.add_content("".join(html)) return result
def submissions_view(self, context): fragment = Fragment() submissions = [ submission for stage in self.stages if isinstance(stage, SubmissionStage) for submission in stage.submissions ] has_submissions = bool(submissions) submission_fragments = self._render_children('submissions_view', context, submissions) submission_contents = [frag.content for frag in submission_fragments] fragment.add_frags_resources(submission_fragments) render_context = { 'activity': self, 'submission_contents': submission_contents, 'has_submissions': has_submissions } fragment.add_content(self.render_template('submissions_view', render_context)) return fragment
def student_view(self, context=None): frag = Fragment() frag.add_css_url( self.runtime.local_resource_url(self, 'public/css/sequence.css')) frag.add_javascript_url( self.runtime.local_resource_url(self, 'public/js/sequence.js')) frag.initialize_js('SequenceBlock') child_frags = self.runtime.render_children(self, context) frag.add_frags_resources(child_frags) template = self.get_template('sequence.html', self.templates_dirs) template_values = { 'nav_items': [ NavItem(child_id, self.runtime) for child_id in self.children], 'children': child_frags, 'position': self.position} frag.add_content(template.render(template_values)) return frag
def view(self, context=None): """Provide default student view.""" frag = Fragment() child_frags = self.runtime.render_children(self, context=context) frag.add_frags_resources(child_frags) frag.add_content( self.runtime.render_template("sequence.html", children=child_frags)) frag.add_css_url( 'http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css') frag.add_javascript_url( 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js' ) # mess things up frag.add_javascript(u""" function Sequence(runtime, element) { $(element).children('.tabs').tabs(); }; """) frag.initialize_js('Sequence') return frag
def student_view(self, context=None): frag = Fragment() frag.add_css_url( self.runtime.local_resource_url(self, 'public/css/sequence.css')) frag.add_javascript_url( self.runtime.local_resource_url(self, 'public/js/sequence.js')) frag.initialize_js('SequenceBlock') child_frags = self.runtime.render_children(self, context) frag.add_frags_resources(child_frags) template = self.get_template('sequence.html', self.templates_dirs) template_values = { 'nav_items': [NavItem(child_id, self.runtime) for child_id in self.children], 'children': child_frags, 'position': self.position } frag.add_content(template.render(template_values)) return frag
def student_view(self, context=None): """ The primary view of the ProctorUXBlock, shown to students when viewing courses. """ if self._is_studio(): # studio view fragment = Fragment( self._render_template('static/html/studio.html')) fragment.add_css(self.resource_string('public/css/proctoru.css')) return fragment elif self._user_is_staff(): return self.staff_view() elif self._allowed_verified(): api_obj = ProctoruAPI() fragment = Fragment() context = {} fragment.add_css(loader.load_unicode('public/css/proctoru.css')) fragment.add_css( loader.load_unicode('public/css/custom_bootstrap.css')) fragment.add_javascript( loader.load_unicode('static/js/src/proctoru.js')) if self.is_exam_ended: context.update({"self": self}) fragment.add_content( loader.render_template('static/html/exam_ended.html', context)) fragment.initialize_js('ProctorUXBlockExamEnabled') return fragment if self.is_exam_unlocked: context.update({"self": self}) fragment.add_content( loader.render_template('static/html/exam_enabled.html', context)) fragment.initialize_js('ProctorUXBlockExamEnabled') child_frags = self.runtime.render_children( block=self, view_name='student_view') html = self._render_template('static/html/sequence.html', children=child_frags) fragment.add_content(html) fragment.add_frags_resources(child_frags) return fragment elif self.is_exam_start_clicked: exam_data = api_obj.get_student_reservation_list( self.runtime.user_id) if len(exam_data) > 0: exam_found = False for exam in exam_data: start_date = exam.get('start_date') exam_obj = api_obj.get_schedule_exam_arrived( self.runtime.user_id, self.get_block_id()) # check for reseration if int(exam_obj.reservation_no) == int( exam.get('reservation_no')): exam_found = True context.update({ "self": self, "exam": api_obj.get_schedule_exam_arrived( self.runtime.user_id, self.get_block_id()) }) fragment.add_content( loader.render_template( 'static/html/exam_password.html', context)) fragment.initialize_js( 'ProctorUXBlockExamPassword') return fragment else: # if reservatin id not found schedule page exam_found = False if not exam_found: # if reservatin id not found return the self.exam_time = "" self.is_exam_scheduled = False self.is_rescheduled = False self.is_exam_canceled = False self.is_exam_start_clicked = False time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get('status') == "examdatepass": context.update({ 'self': self, 'status': "examdatepass" }) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockSchedule') return fragment else: # if exam not found self.exam_time = "" self.is_exam_scheduled = False self.is_rescheduled = False self.is_exam_canceled = False self.is_exam_start_clicked = False time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get('status') == "examdatepass": context.update({ 'self': self, 'status': "examdatepass" }) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockSchedule') return fragment elif api_obj.is_user_created( self.runtime.user_id) and self.is_rescheduled: time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get('status') == "examdatepass": context.update({'self': self, 'status': "examdatepass"}) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) exam_time_heading = api_obj.get_formated_exam_start_date( self.exam_time, self.runtime.user_id) old_exam_time = dateutil.parser.parse(self.exam_time) exam_start_date_time = time_details.get( 'str_exam_start_date') exam_end_date_time = time_details.get('exam_end_date_time') allowed_keep_old_exam = False if exam_start_date_time <= old_exam_time <= exam_end_date_time: allowed_keep_old_exam = True else: allowed_keep_old_exam = False context.update({ 'exam_time_heading': exam_time_heading, 'allowed_keep_old_exam': allowed_keep_old_exam, }) context.update({ "proctoru_user": api_obj.get_proctoru_user(self.runtime.user_id) }) timezones = api_obj.get_time_zones() context.update( {"time_zone_list": timezones.get("data", None)}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/reshedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/reshedule_form_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockSchedule') return fragment elif self.is_exam_scheduled: exam_data = api_obj.get_student_reservation_list( self.runtime.user_id) context.update({ "proctoru_user": api_obj.get_proctoru_user(self.runtime.user_id) }) timezones = api_obj.get_time_zones() context.update({"time_zone_list": timezones.get("data", None)}) if len(exam_data) > 0: exam_found = False for exam in exam_data: start_date = exam.get('start_date') exam_obj = api_obj.get_schedule_exam_arrived( self.runtime.user_id, self.get_block_id()) # check for reseration if int(exam_obj.reservation_no) == int( exam.get('reservation_no')): exam_found = True exam_obj.start_date = dateutil.parser.parse( start_date) exam_obj.save() pr_user = ProctoruUser.objects.get( student=self.runtime.user_id) start_date = dateutil.parser.parse(start_date) start_date = start_date.replace(tzinfo=pytz.utc) tzobj = pytz.timezone(win_tz[pr_user.time_zone]) start_date = start_date.astimezone(tzobj) current_time = pytz.utc.localize( datetime.datetime.utcnow()).astimezone(tzobj) diff = start_date - current_time remaining_time = (diff.days * 24 * 60) + (diff.seconds / 60) if remaining_time <= PROCTORU_EXAM_AWAY_TIMEOUT: # if examtime pass away self.exam_time = "" self.is_exam_scheduled = False self.is_rescheduled = False self.is_exam_canceled = False time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get( 'status') == "examdatepass": context.update({ 'self': self, 'status': "examdatepass" }) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) fragment.initialize_js( 'ProctorUXBlockSchedule') return fragment else: self.exam_time = start_date.isoformat() context.update({ "exam": exam_obj, "self": self }) fragment.add_content( loader.render_template( 'static/html/exam_arrived_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockArrived') return fragment else: # if reservatin id not found schedule page exam_found = False if not exam_found: # if reservatin id not found return the self.exam_time = "" self.is_exam_scheduled = False self.is_rescheduled = False self.is_exam_canceled = False time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get('status') == "examdatepass": context.update({ 'self': self, 'status': "examdatepass" }) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockSchedule') return fragment else: # if exam not found self.exam_time = "" self.is_exam_scheduled = False self.is_rescheduled = False self.is_exam_canceled = False time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get('status') == "examdatepass": context.update({ 'self': self, 'status': "examdatepass" }) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockSchedule') return fragment elif api_obj.is_user_created( self.runtime.user_id) and not self.is_exam_scheduled: self.exam_time = "" self.is_exam_scheduled = False self.is_rescheduled = False self.is_exam_canceled = False time_details = { 'exam_start_date_time': self.start_date, 'exam_end_date_time': self.end_date, } time_details = api_obj.get_time_details_api( time_details, self.exam_date) if time_details.get('status') == "examdatepass": context.update({'self': self, 'status': "examdatepass"}) fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) else: context = api_obj.render_shedule_ui( self.runtime.user_id, time_details, self.duration) context.update({'self': self}) context.update({ "proctoru_user": api_obj.get_proctoru_user(self.runtime.user_id) }) timezones = api_obj.get_time_zones() context.update( {"time_zone_list": timezones.get("data", None)}) status = context.get('status') if status == "error": fragment.add_content( loader.render_template( 'static/html/error_template.html', context)) elif status == "emptylist": fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) else: fragment.add_content( loader.render_template( 'static/html/shedule_form_proctoru.html', context)) fragment.initialize_js('ProctorUXBlockSchedule') return fragment else: api_obj = ProctoruAPI() timezones = api_obj.get_time_zones() context.update({"self": self}) context.update({"timezones": timezones.get("data", None)}) fragment.add_content( loader.render_template('static/html/proctoru.html', context)) fragment.initialize_js('ProctorUXBlockCreate') return fragment else: fragment = Fragment() context = {} context.update({"self": self}) fragment.add_content( loader.render_template('static/html/blank.html', context)) fragment.initialize_js('ProctorUXBlockBlank') return fragment