Newer
Older
"feedback": shown_feedback,
"correct_answer": correct_answer,
"may_change_graded_answer": (
(flow_permission.change_answer
and flow_session.in_progress),
"will_receive_feedback": will_receive_feedback(permissions),
"show_answer": show_answer,
}
if fpctx.page.expects_answer():
args["max_points"] = fpctx.page.max_points(fpctx.page_data)
return render_course_page(
pctx, "course/flow-page.html", args,
allow_instant_flow_requests=False)
# {{{ view: finish flow
@course_view
def finish_flow_session_view(pctx, flow_identifier):
request = pctx.request
flow_session = find_current_flow_session(
request, pctx.course, flow_identifier)
if flow_session is None:
messages.add_message(request, messages.WARNING,
"No session record found for this flow. "
"Redirected to flow start page.")
return redirect("course.flow.start_flow",
pctx.course.identifier,
fctx = FlowContext(pctx.repo, pctx.course, flow_identifier,
participation=pctx.participation,
flow_session=flow_session)
current_access_rule = fctx.get_current_access_rule(
flow_session, pctx.role, pctx.participation,
get_now_or_fake_time(request))
answer_visits = assemble_answer_visits(flow_session)
from course.content import markup_to_html
completion_text = markup_to_html(
fctx.course, fctx.repo, fctx.flow_commit_sha,
fctx.flow_desc.completion_text)
(answered_count, unanswered_count) = count_answered(
fctx, flow_session, answer_visits)
is_graded_flow = bool(answered_count + unanswered_count)
if flow_permission.view not in current_access_rule.permissions:
raise PermissionDenied()
def render_finish_response(template, **kwargs):
render_args = {
"flow_identifier": fctx.flow_identifier,
"flow_desc": fctx.flow_desc,
}
render_args.update(kwargs)
return render_course_page(
pctx, template, render_args,
allow_instant_flow_requests=False)
if request.method == "POST":
if "submit" not in request.POST:
raise SuspiciousOperation("odd POST parameters")
if not flow_session.in_progress:
raise PermissionDenied("Can't end a session that's already ended")
# Actually end the flow session
request.session["flow_session_id"] = None
grade_info = finish_flow_session(fctx, flow_session, current_access_rule)
if is_graded_flow:
return render_finish_response(
"course/flow-completion-grade.html",
completion_text=completion_text,
grade_info=grade_info)
else:
return render_finish_response(
"course/flow-completion.html",
last_page_nr=None,
completion_text=completion_text)
# }}}
if (not is_graded_flow
and fctx.flow_commit_sha == fctx.course_commit_sha):
# Not serious--no questions in flow, and no new version available.
# No need to end the flow visit.
return render_finish_response(
"course/flow-completion.html",
completion_text=completion_text)
elif not flow_session.in_progress:
# Just reviewing: re-show grades.
grade_info = gather_grade_info(flow_session, answer_visits)
return render_finish_response(
"course/flow-completion-grade.html",
completion_text=completion_text,
grade_info=grade_info)
else:
# confirm ending flow
return render_finish_response(
"course/flow-confirm-completion.html",
answered_count=answered_count,
unanswered_count=unanswered_count,
total_count=answered_count+unanswered_count)
# }}}
# vim: foldmethod=marker