# Path: pinax/lms/activities/forms.py
# class SurveyForm(forms.Form):
# 
#     def __init__(self, *args, **kwargs):
# 
#         self.questions = kwargs.pop("questions")
#         super(SurveyForm, self).__init__(*args, **kwargs)
# 
#         for question in self.questions:
#             field_class = question["field_class"]
#             kwargs = {
#                 "label": question["label"],
#             }
# 
#             if question.get("help_text"):
#                 kwargs.update({"help_text": question["help_text"]})
# 
#             if question.get("required") is not None:
#                 kwargs.update({"required": question["required"]})
# 
#             kwargs.update(question.get("extra_args", {}))
#             self.fields[question["name"]] = field_class(**kwargs)
# 
# Path: pinax/lms/activities/signals.py



from django.shortcuts import redirect, render
from .forms import SurveyForm
from .signals import activity_completed
        self.setup()

    def setup(self):
        pass

    def get_context_data(self, session_state, **kwargs):
        kwargs.update({
            "title": self.title,
            "description": self.description,
            "help_text": getattr(self, "help_text", None),
            "complete_session_label": self.complete_session_label,
            "save_session_label": self.save_session_label,
        })
        kwargs.update(self.extra_context)
        return kwargs

    def completed_sessions(self):
        # @@@ move on to model and proxy
        return self.activity_state.all_sessions.filter(completed__isnull=False).order_by("-started")


class Survey(ActivityType):

    template_name = "pinax/lms/activities/survey.html"

    def handle_get_request(self, request):
        form = SurveyForm(questions=self.questions)
        return self.render(request, form=form)

    def handle_post_request(self, request):

# Path: pinax/lms/activities/forms.py
# class SurveyForm(forms.Form):
# 
#     def __init__(self, *args, **kwargs):
# 
#         self.questions = kwargs.pop("questions")
#         super(SurveyForm, self).__init__(*args, **kwargs)
# 
#         for question in self.questions:
#             field_class = question["field_class"]
#             kwargs = {
#                 "label": question["label"],
#             }
# 
#             if question.get("help_text"):
#                 kwargs.update({"help_text": question["help_text"]})
# 
#             if question.get("required") is not None:
#                 kwargs.update({"required": question["required"]})
# 
#             kwargs.update(question.get("extra_args", {}))
#             self.fields[question["name"]] = field_class(**kwargs)
# 
# Path: pinax/lms/activities/signals.py



# Path: pinax/lms/activities/base.py
from django.shortcuts import redirect, render
from .forms import SurveyForm
from .signals import activity_completed

        self.setup()

    def setup(self):
        pass

    def get_context_data(self, session_state, **kwargs):
        kwargs.update({
            "title": self.title,
            "description": self.description,
            "help_text": getattr(self, "help_text", None),
            "complete_session_label": self.complete_session_label,
            "save_session_label": self.save_session_label,
        })
        kwargs.update(self.extra_context)
        return kwargs

    def completed_sessions(self):
        # @@@ move on to model and proxy
        return self.activity_state.all_sessions.filter(completed__isnull=False).order_by("-started")


class Survey(ActivityType):

    template_name = "pinax/lms/activities/survey.html"

    def handle_get_request(self, request):
        form = SurveyForm(questions=self.questions)
        return self.render(request, form=form)

    def handle_post_request(self, request):

        form = SurveyForm(request.POST, questions=self.questions)