def set_session_profile(survey, survey_session, profile): """Set up the survey session using a given profile. :param survey: the survey to use :type survey: :py:class:`euphorie.content.survey.Survey` :param survey_session: survey session to update :type survey_session: :py:class:`euphorie.client.model.SurveySession` :param dict profile: desired profile :rtype: :py:class:`euphorie.client.model.SurveySession` :return: the update session (this might be a new session) This will rebuild the survey session tree if the profile has changed. """ if not survey_session.hasTree(): BuildSurveyTree(survey, profile, survey_session) return survey_session current_profile = extractProfile(survey, survey_session) if current_profile == profile and not treeChanges(survey_session, survey): survey_session.touch() return survey_session new_session = create_survey_session( survey_session.title, survey, survey_session.account) BuildSurveyTree(survey, profile, new_session, survey_session) new_session.copySessionData(survey_session) object_session(survey_session).delete(survey_session) return new_session
def set_session_profile(survey, survey_session, profile): """Set up the survey session using a given profile. :param survey: the survey to use :type survey: :py:class:`euphorie.content.survey.Survey` :param survey_session: survey session to update :type survey_session: :py:class:`euphorie.client.model.SurveySession` :param dict profile: desired profile :rtype: :py:class:`euphorie.client.model.SurveySession` :return: the update session (this might be a new session) This will rebuild the survey session tree if the profile has changed. """ if not survey_session.hasTree(): BuildSurveyTree(survey, profile, survey_session) return survey_session current_profile = extractProfile(survey, survey_session) if current_profile == profile and not treeChanges(survey_session, survey): survey_session.touch() return survey_session new_session = create_survey_session(survey_session.title, survey, survey_session.account) BuildSurveyTree(survey, profile, new_session, survey_session) new_session.copySessionData(survey_session) object_session(survey_session).delete(survey_session) return new_session
def _setup_session(portal): from euphorie.content.tests.utils import BASIC_SURVEY from euphorie.client.tests.utils import addAccount from euphorie.client.tests.utils import addSurvey from euphorie.client.session import create_survey_session from euphorie.client.profile import set_session_profile addSurvey(portal, BASIC_SURVEY) survey = portal.client['nl']['ict']['software-development'] account = addAccount(password='******') survey_session = create_survey_session(u'Dummy session', survey, account) survey_session = set_session_profile(survey, survey_session, {}) return (account, survey, survey_session)