Newer
Older
'flow_id': page_context.flow_session.flow_id},
message,
getattr(settings, "GRADER_FEEDBACK_EMAIL_FROM",
page_context.course.get_from_email()),
[page_context.flow_session.participation.user.email])
msg.bcc = [page_context.course.notify_email]
if grading_form.cleaned_data["may_reply"]:
msg.reply_to = [request.user.email]
if hasattr(settings, "GRADER_FEEDBACK_EMAIL_FROM"):
from relate.utils import get_outbound_mail_connection
msg.connection = get_outbound_mail_connection("grader_feedback")
msg.send()
if (grading_form.cleaned_data["notes"]
and grading_form.cleaned_data["notify_instructor"]
and page_context.flow_session):
with translation.override(settings.RELATE_ADMIN_EMAIL_LOCALE):
from django.template.loader import render_to_string
from course.utils import will_use_masked_profile_for_email
staff_email = [page_context.course.notify_email, request.user.email]
message = render_to_string("course/grade-internal-notes-notify.txt",
{
"page_title": self.title(page_context, page_data),
"course": page_context.course,
"participation": page_context.flow_session.participation,
"notes_text": grade_data["notes"],
"flow_session": page_context.flow_session,
"review_uri": page_context.page_uri,
"sender": request.user,
"use_masked_profile":
will_use_masked_profile_for_email(staff_email)
from django.core.mail import EmailMessage
msg = EmailMessage(
string_concat("[%(identifier)s:%(flow_id)s] ",
_("Grading notes from %(ta)s"))
% {'identifier': page_context.course.identifier,
'flow_id': page_context.flow_session.flow_id,
'ta': request.user.get_full_name()
},
message,
getattr(settings, "GRADER_FEEDBACK_EMAIL_FROM",
page_context.course.get_from_email()),
[page_context.course.notify_email])
msg.bcc = [request.user.email]
msg.reply_to = [request.user.email]
if hasattr(settings, "GRADER_FEEDBACK_EMAIL_FROM"):
from relate.utils import get_outbound_mail_connection
msg.connection = get_outbound_mail_connection("grader_feedback")
return grade_data
def grading_form_to_html(self, request, page_context, grading_form, grade_data):
ctx = {
"form": grading_form,
"rubric": markup_to_html(page_context, self.page_desc.rubric)
}
from django.template.loader import render_to_string
return render_to_string(
Dong Zhuang
committed
"course/human-feedback-form.html", ctx, request)
def grade(
self,
page_context, # type: PageContext
page_data, # type: Any
answer_data, # type: Any
grade_data, # type: Any
):
# type: (...) -> Optional[AnswerFeedback]
"""This method is appropriate if the grade consists *only* of the
feedback provided by humans. If more complicated/combined feedback
is desired, a subclass would likely override this.
"""
if answer_data is None:
return AnswerFeedback(correctness=0,
if grade_data is None:
return None
if not grade_data["released"]:
return None
if (grade_data["grade_percent"] is not None
or grade_data["feedback_text"]):
if grade_data["grade_percent"] is not None:
correctness = grade_data["grade_percent"]/100
feedback_text = "<p>%s</p>" % get_auto_feedback(correctness)
else:
correctness = None
feedback_text = ""
if grade_data["feedback_text"]:
feedback_text += (
string_concat(
"<p>",
_("The following feedback was provided"),
":<p>")
+ markup_to_html(
page_context, grade_data["feedback_text"],
use_jinja=False))
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
return AnswerFeedback(
correctness=correctness,
feedback=feedback_text)
else:
return None
class PageBaseWithCorrectAnswer(PageBase):
def allowed_attrs(self):
return super(PageBaseWithCorrectAnswer, self).allowed_attrs() + (
("correct_answer", "markup"),
)
def correct_answer(self, page_context, page_data, answer_data, grade_data):
if hasattr(self.page_desc, "correct_answer"):
return markup_to_html(page_context, self.page_desc.correct_answer)
else:
return None
# }}}
def get_editor_interaction_mode(page_context):
if (page_context.flow_session is not None
and page_context.flow_session.participation is not None):
return page_context.flow_session.participation.user.editor_mode
else:
return "default"