コード例 #1
0
def update_lti_course_membership(self, course_id):
    course = Course.query.get(course_id)
    if course:
        current_app.logger.info(
            "Begin LTI Membership update for course with id: " +
            str(course_id) + " named: " + course.name)

        # allow MembershipNoValidContextsException exceptions to occur without retrying job
        try:
            LTIMembership.update_membership_for_course(course)
        except MembershipNoValidContextsException as err:
            current_app.logger.warning(
                "Error for LTI Membership update for course with id: " +
                str(course_id) + " named: " + course.name +
                ". No valid lti contexts are linked to the course")
        except MembershipNoResultsException as err:
            current_app.logger.warning(
                "Error for LTI Membership update for course with id: " +
                str(course_id) + " named: " + course.name +
                ". The LTI link does not support the membership extension")
        except MembershipInvalidRequestException as err:
            current_app.logger.warning(
                "Error for LTI Membership update for course with id: " +
                str(course_id) + " named: " + course.name +
                ". The membership request was invalid")

        current_app.logger.info(
            "Completed LTI Membership update for course with id: " +
            str(course_id) + " named: " + course.name)
    else:
        current_app.logger.info(
            "Failed LTI Membership update for course with id: " +
            str(course_id) + ". record not found.")
コード例 #2
0
    def post(self, course_uuid):
        """
        refresh the course membership if able
        """
        course = Course.get_active_by_uuid_or_404(course_uuid)
        require(EDIT, course,
            title="Membership Not Updated",
            message="Sorry, your role in this course does not allow you to update membership.")

        if not course.lti_linked:
            abort(400, title="Membership Not Updated",
                message="Sorry, your LTI link settings have no course context. Please edit your LTI link settings and try linking again.")

        try:
            LTIMembership.update_membership_for_course(course)
        except MembershipNoValidContextsException as err:
            abort(400, title="Membership Not Updated",
                message="The LTI link does not support the membership extension. Please edit your LTI link settings or contact your system administrator and try again.")
        except MembershipNoResultsException as err:
            abort(400, title="Membership Not Updated",
                message="The membership service did not return any users. Please check your LTI course and try again.")
        except MembershipInvalidRequestException as err:
            abort(400, title="Membership Not Updated",
                message="The membership request was invalid. Please relaunch the LTI link and try again.")

        on_lti_course_membership_update.send(
            self,
            event_name=on_lti_course_membership_update.name,
            user=current_user,
            data={ 'course_id': course.id })

        return { 'imported': True }
コード例 #3
0
ファイル: lti_launch.py プロジェクト: ubc/acj-versus
    def post(self, course_uuid):
        """
        refresh the course membership if able
        """
        course = Course.get_active_by_uuid_or_404(course_uuid)
        require(EDIT, course)

        if not course.lti_linked:
            return {"error": "Course not linked to lti context"}, 400

        try:
            LTIMembership.update_membership_for_course(course)
        except MembershipNoValidContextsException as err:
            return {"error": "LTI membership service is not supported for this course"}, 400
        except MembershipNoResultsException as err:
            return {"error": "LTI membership service did not return any users"}, 400
        except MembershipInvalidRequestException as err:
            return (
                {
                    "error": "LTI membership request was invalid. Please relaunch the ComPAIR course from the LTI consumer and try again"
                },
                400,
            )

        on_lti_course_membership_update.send(
            self, event_name=on_lti_course_membership_update.name, user=current_user, data={"course_id": course.id}
        )

        return {"imported": True}
コード例 #4
0
def update_lti_course_membership(self, course_id):
    course = Course.query.get(course_id)
    if course:
        current_app.logger.info("Begin LTI Membership update for course with id: "+str(course_id)+" named: "+course.name)

        LTIMembership.update_membership_for_course(course)

        current_app.logger.info("Compelted LTI Membership update for course with id: "+str(course_id)+" named: "+course.name)
    else:
        current_app.logger.info("Failed LTI Membership update for course with id: "+str(course_id)+". record not found.")
コード例 #5
0
ファイル: lti_membership.py プロジェクト: ubc/acj-versus
def update_lti_course_membership(self, course_id):
    course = Course.query.get(course_id)
    if course:
        current_app.logger.info("Begin LTI Membership update for course with id: "+str(course_id)+" named: "+course.name)

        # allow MembershipNoValidContextsException exceptions to occur without retrying job
        try:
            LTIMembership.update_membership_for_course(course)
        except MembershipNoValidContextsException as err:
            current_app.logger.warning("Error for LTI Membership update for course with id: "+str(course_id)+" named: "+course.name+". No valid lti contexts are linked to the course")
        except MembershipNoResultsException as err:
            current_app.logger.warning("Error for LTI Membership update for course with id: "+str(course_id)+" named: "+course.name+". The LTI link does not support the membership extension")
        except MembershipInvalidRequestException as err:
            current_app.logger.warning("Error for LTI Membership update for course with id: "+str(course_id)+" named: "+course.name+". The membership request was invalid")

        current_app.logger.info("Completed LTI Membership update for course with id: "+str(course_id)+" named: "+course.name)
    else:
        current_app.logger.info("Failed LTI Membership update for course with id: "+str(course_id)+". record not found.")
コード例 #6
0
def update_lti_course_membership(self, course_id):
    course = Course.query.get(course_id)
    if course:
        current_app.logger.info("Begin LTI Membership update for course with id: "+str(course_id)+" named: "+course.name)

        try:
            LTIMembership.update_membership_for_course(course)

        except requests.exceptions.ConnectTimeout as error:
            current_app.logger.info("Failed LTI Membership update for course with id: "+str(course_id)+". "+str(error))
            if not self.request.is_eager:
                self.retry(error)

        except requests.exceptions.ConnectionError as error:
            current_app.logger.info("Failed LTI Membership update for course with id: "+str(course_id)+". "+str(error))
            if not self.request.is_eager:
                self.retry(error)

        current_app.logger.info("Compelted LTI Membership update for course with id: "+str(course_id)+" named: "+course.name)
    else:
        current_app.logger.info("Failed LTI Membership update for course with id: "+str(course_id)+". record not found.")