示例#1
0
文件: api.py 项目: Mattivc/plan
    def scrape(self):
        # Only bother with courses that have already been loaded.
        for course in Course.objects.filter(semester=self.semester).order_by('code'):
            result = fetch_course(course.code)
            if not result:
                continue

            for exam in result.get('assessment', []):
                if not match_assessment(exam, self.semester):
                    continue

                exam_date = exam.get('date', None)
                exam_time = exam.get('appearanceTime', None)
                handout_date = exam.get('withdrawalDate', None)
                handin_date = exam.get('submissionDate', None)
                duration = exam.get('duration', None)
                combination = exam['combinationCode']
                type_code = exam['assessmentFormCode']
                type_name = exam['assessmentFormDescription']

                yield {'course': course,
                       'exam_date': utils.parse_date(handin_date or exam_date),
                       'exam_time': utils.parse_time(exam_time),
                       'combination': combination,
                       'handout_date': utils.parse_date(handout_date),
                       'type': self.exam_type(type_code, type_name),
                       'duration': duration}
示例#2
0
    def scrape(self):
        # Only bother with courses that have already been loaded.
        for course in self.course_queryset():
            result = fetch_course(course.code)
            if not result:
                continue

            for exam in result.get('assessment', []):
                if not match_assessment(exam, self.semester):
                    continue

                exam_date = exam.get('date', None)
                exam_time = exam.get('appearanceTime', None)
                handout_date = exam.get('withdrawalDate', None)
                handin_date = exam.get('submissionDate', None)
                duration = exam.get('duration', None)
                combination = exam['combinationCode']
                type_code = exam['assessmentFormCode']
                type_name = exam['assessmentFormDescription']

                yield {'course': course,
                       'exam_date': utils.parse_date(handin_date or exam_date),
                       'exam_time': utils.parse_time(exam_time),
                       'combination': combination,
                       'handout_date': utils.parse_date(handout_date),
                       'type': self.exam_type(type_code, type_name),
                       'duration': duration}
示例#3
0
文件: xml.py 项目: mydos/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester, template='{year}{letter}')
        url = 'http://www.ntnu.no/eksamen/plan/%s/dato.XML' % prefix

        courses = Course.objects.filter(semester=self.semester)
        courses = {c.code: c for c in courses}

        root = fetch.xml(url)
        if root is None:
            return

        for row in root.xpath('//dato/dato_row'):
            course_code = get(row, 'emnekode')
            course_version = get(row, 'versjonskode')
            status_code = get(row, 'vurdstatuskode')

            if status_code != 'ORD':
                continue
            elif not ntnu.valid_course_code(course_code):
                logging.warning("Invalid course code: %s", course_code)
                continue
            elif course_code not in courses:
                logging.debug("Unknown course %s.", course_code)
                continue
            elif not self.should_proccess_course(code):
                continue

            combination = get(row, 'vurdkombkode')
            duration = get(row, 'varighettimer')
            exam_date = get(row, 'dato_eksamen')
            exam_semester = get(row, 'terminkode_gjelder_i')
            exam_time = get(row, 'klokkeslett_fremmote_tid')
            exam_year = get(row, 'arstall_gjelder_i')
            handin_date = get(row, 'dato_innlevering')
            handin_time = get(row, 'klokkeslett_innlevering')
            handout_date = get(row, 'dato_uttak')
            handout_time = get(row, 'klokkeslett_uttak')
            type_code = get(row, 'vurderingsformkode')
            type_name = get(row, 'vurderingskombinasjon_vurdkombnavn_bokmal')

            if not type_code:
                logging.warning('Missing exam type for %s', course_code)
                continue

            yield {
                'course': courses[course_code],
                'exam_date': utils.parse_date(handin_date or exam_date),
                'exam_time': utils.parse_time(handin_time or exam_time),
                'combination': combination,
                'handout_date': utils.parse_date(handout_date),
                'handout_time': utils.parse_time(handout_time),
                'type': self.exam_type(type_code, type_name),
                'duration': duration
            }
示例#4
0
文件: xml.py 项目: torstehu/plan
    def scrape(self):
        prefix = ntnu.prefix(self.semester, template='{year}{letter}')
        url = 'http://www.ntnu.no/eksamen/plan/%s/dato.XML' % prefix

        courses = Course.objects.filter(semester=self.semester)
        courses = {c.code: c for c in courses}

        root = fetch.xml(url)
        if root is None:
            return

        for row in root.xpath('//dato/dato_row'):
            course_code = get(row, 'emnekode')
            course_version = get(row, 'versjonskode')
            status_code = get(row, 'vurdstatuskode')

            if status_code != 'ORD':
                continue
            elif not ntnu.valid_course_code(course_code):
                logging.warning("Invalid course code: %s", course_code)
                continue
            elif course_code not in courses:
                logging.debug("Unknown course %s.", course_code)
                continue
            elif not self.should_proccess_course(code):
                continue

            combination = get(row, 'vurdkombkode')
            duration = get(row, 'varighettimer')
            exam_date = get(row, 'dato_eksamen')
            exam_semester = get(row, 'terminkode_gjelder_i')
            exam_time = get(row, 'klokkeslett_fremmote_tid')
            exam_year = get(row, 'arstall_gjelder_i')
            handin_date = get(row, 'dato_innlevering')
            handin_time = get(row, 'klokkeslett_innlevering')
            handout_date = get(row, 'dato_uttak')
            handout_time = get(row, 'klokkeslett_uttak')
            type_code = get(row, 'vurderingsformkode')
            type_name = get(row, 'vurderingskombinasjon_vurdkombnavn_bokmal')

            if not type_code:
                logging.warning('Missing exam type for %s', course_code)
                continue

            yield {'course': courses[course_code],
                   'exam_date': utils.parse_date(handin_date or exam_date),
                   'exam_time': utils.parse_time(handin_time or exam_time),
                   'combination': combination,
                   'handout_date': utils.parse_date(handout_date),
                   'handout_time': utils.parse_time(handout_time),
                   'type': self.exam_type(type_code, type_name),
                   'duration': duration}
示例#5
0
    def scrape(self):
        for course in fetch_courses(self.semester):
            seen = set()
            for exam in course['exam']:
                if not exam.get('date'):
                    continue
                elif self.semester.type == Semester.FALL and exam[
                        'season'] != 'AUTUMN':
                    continue
                elif self.semester.type == Semester.SPRING and exam[
                        'season'] != 'SPRING':
                    continue

                date = utils.parse_date(exam['date'])
                if date in seen:
                    continue

                seen.add(date)
                yield {
                    'course':
                    Course.objects.get(code=course['courseCode'],
                                       version=course['courseVersion'],
                                       semester=self.semester),
                    'exam_date':
                    date,
                }
示例#6
0
    def scrape(self):

        for c in self.course_queryset():
            result = fetch_course_lectures(self.semester, c)

            if 'data' not in result or not result['data']:
                continue

            for methods in result['data'].values():
                for method in methods:
                    for sequence in method['eventsequences']:
                        current = None

                        for e in sequence['events']:
                            tmp = {
                                'day':
                                utils.parse_date(e['dtstart']).weekday(),
                                'start':
                                utils.parse_time(e['dtstart']),
                                'end':
                                utils.parse_time(e['dtend']),
                                'rooms': [(r['id'], r['roomname'], None)
                                          for r in e.get('room', [])],
                                'groups':
                                process_groups(e.get('studentgroups', [])),
                            }

                            if not current:
                                current = {
                                    'course':
                                    c,
                                    'type':
                                    method.get('teaching-method-name',
                                               'teaching-method'),
                                    'weeks': [],
                                    'lecturers': [],
                                }
                                current.update(tmp)

                            for key in tmp:
                                if current[key] != tmp[key]:

                                    logging.warning('Mismatch %s: %s',
                                                    self.display(obj), key)
                                    yield current
                                    current = None
                                    break
                            else:
                                current['weeks'].append(e['weeknr'])

                        if current:
                            yield current
示例#7
0
文件: web.py 项目: HelleIrina/plan
    def scrape(self):
        for course in fetch_courses(self.semester):
            seen = set()
            for exam in course['exam']:
                if not exam.get('date'):
                    continue
                elif self.semester.type == Semester.FALL and exam['season'] != 'AUTUMN':
                    continue
                elif self.semester.type == Semester.SPRING and exam['season'] != 'SPRING':
                    continue

                date = utils.parse_date(exam['date'])
                if date in seen:
                    continue

                seen.add(date)
                yield {
                    'course': Course.objects.get(
                        code=course['courseCode'],
                        version=course['courseVersion'],
                        semester=self.semester),
                    'exam_date': date,
                }