Esempio n. 1
0
def get_term():
    term = CanvasTerm()
    term.sis_term_id = "2015-winter"
    term.name = "Winter 2014"
    term._start_date = parser.parse("2015-01-05")
    term._end_date = parser.parse("2015-03-20")

    return term
Esempio n. 2
0
def get_term():
    term = CanvasTerm()
    term.sis_term_id = settings.ANALYTICS_TERM_SIS_ID
    term.name = getattr(settings, "ANALYTICS_TERM_NAME", "Current Term")
    term._start_date = parser.parse(settings.ANALYTICS_TERM_START_DATE)
    term._end_date = parser.parse(settings.ANALYTICS_TERM_END_DATE)

    return term
Esempio n. 3
0
    def _course_from_json(self, data):
        course = CanvasCourse()
        course.course_id = data["id"]
        course.sis_course_id = data[
            "sis_course_id"] if "sis_course_id" in data else None
        course.account_id = data["account_id"]
        course.code = data["course_code"]
        course.name = data["name"]
        course.workflow_state = data["workflow_state"]
        course.public_syllabus = data["public_syllabus"]

        course_url = data["calendar"]["ics"]
        course_url = re.sub(r"(.*?[a-z]/).*", r"\1", course_url)
        course.course_url = "%scourses/%s" % (course_url, data["id"])

        # Optional attributes specified in the course URL
        if "term" in data:
            course.term = CanvasTerm(term_id=data["term"]["id"],
                                     sis_term_id=data["term"]["sis_term_id"],
                                     name=data["term"]["name"])

        if "syllabus_body" in data:
            course.syllabus_body = data["syllabus_body"]

        return course
Esempio n. 4
0
    def get_term_by_sis_id(self, sis_term_id):
        """
        Return a term resource for the passed SIS ID.
        """
        params = {"workflow_state": "all", "per_page": 500}
        url = "/api/v1/accounts/%s/terms" % (
            settings.RESTCLIENTS_CANVAS_ACCOUNT_ID)
        data = self._get_resource(url, params=params)

        for term in data["enrollment_terms"]:
            if term["sis_term_id"] == sis_term_id:
                term = CanvasTerm(term_id=term["id"],
                                  sis_term_id=term["sis_term_id"],
                                  name=term["name"])
                return term