Пример #1
0
def main():
    qs.api_logging.config(__file__)
    sem1 = json.load(open(sem1_file))
    sem2 = json.load(open(sem2_file))

    all_student_ids = list(set(sem1.keys() + sem2.keys()))

    # for cache
    qs.get_sections(semester_id=cycle_3_semester_id)

    for student_id in all_student_ids:
        sem1_section_ids = sem1[student_id]
        sem2_section_ids = sem2[student_id].keys()

        sem1_sections = [qs.get_section(i) for i in sem1_section_ids]
        sem2_matched = [qs.match_section_by_name(i['sectionName']) for i in sem1_sections]
        sem2_matched_ids = [i['id'] for i in sem2_matched if i]

        print sem2_section_ids
        print sem2_matched_ids
        print
        print
Пример #2
0
def main():
    qs.api_logging.config(__file__)

    source_sections = qs.get_sections(semester_id=source_semester)
    bad = good = 0
    mismatches = []
    for section in source_sections:
        match = qs.match_section_by_dict(section)
        if not match:
            bad += 1
            mismatches.append(section['id'])
        else:
            qs.api_logging.info('Match: {} in {} --> {}'.format(
                section['id'], source_semester, match['id']), {
                    'source': section,
                    'match': match,
                },
                                cc_print=False)
            good += 1
    print 'bad: {}\ngood: {}'.format(bad, good)
    print mismatches
Пример #3
0
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python

import qs
import json

cycle_3_semester_id = 15993
input_filename = '/Users/Rick/Dropbox/code/QuickSchools/modules/sa/report cards sem 2.json'
output_filename = '/Users/Rick/Dropbox/code/QuickSchools/modules/sa/report cards sem 2 filtered.json'

# for caching
qs.get_sections(semester_id=cycle_3_semester_id)


def main():
    new_data = {}
    old_data = json.load(open(input_filename))
    for student_id, section_data in old_data.iteritems():
        new_student_sections = {}
        for section_id, vals in section_data.iteritems():
            section_name = qs.get_section(section_id)['sectionName']
            filtered = filter_vals(vals)
            if filtered:
                new_student_sections[section_name] = filtered
                new_student_sections[section_name][
                    'semester 2 id'] = section_id
        new_data[student_id] = new_student_sections
    json.dump(new_data, open(output_filename, 'w'), indent=4)


def filter_vals(vals):
    valid = ['s-marks-1', 's-marks-2', 's-letter-grade-1', 's-letter-grade-2']
Пример #4
0
def main():
    data_migration.create_file("download")
    qs.api_logging.config(__file__, log_filename=data_migration.get_filename())
    data_migration.check(compare_date=start_date)

    valid_assignments = {}
    grade_download_count = assignment_download_count = 0

    # ========================================
    # = Download assignments in each section =
    # ========================================
    sections = qs.get_sections(semester_id=source_semester, critical=True)
    for section in tqdm(sections, desc='GET', leave=True):
        section_id = section['id']
        if not valid_section(section_id): continue

        # get assignments
        assignments = qs.get_assignments(section_id)
        if not assignments: continue
        assignment_download_count += len(assignments)

        # ======================================
        # = Download grades in each assignment =
        # ======================================
        valid_assignments[section_id] = []
        for assignment in assignments:
            valid = valid_assignment(assignment, section)
            if valid != True:
                qs.api_logging.info("Invalid assignment", assignment)
                continue

            # get grades
            grades = qs.get_grades(section_id, assignment['id'])

            if not grades: continue
            grade_download_count += len(grades)

            # save grade data for upload later
            valid_assignments[section_id].append({
                'name':
                assignment['name'],
                'date':
                assignment['date'],
                'totalMarksPossible':
                assignment['totalMarksPossible'],
                'columnCategoryId':
                assignment['categoryId'],
                'grades':
                grades,
                'sectionId':
                section_id,
                'assignmentId':
                assignment['id']
            })

        if not valid_assignments[section_id]:
            del valid_assignments[section_id]

    # ======================================
    # = Output data and complete execution =
    # ======================================
    data_migration.save(valid_assignments)
    qs.api_logging.info(
        "downloaded {} assignments and {} grades from semester {} "
        "between {} and {}, spanning {} sections. {} total errors."
        "".format(assignment_download_count,
                  grade_download_count, source_semester, start_date, end_date,
                  len(qs.get_sections()), qs.get_error_count()), {},
        cc_print=True)
Пример #5
0
def main():
    qs.api_logging.basicConfig(__file__)
    for semester_id in tqdm(SEMESTER_IDS):
        semester = [i for i in qs.get_semesters() if i['id'] == semester_id][0]
        quarter = quarter_from_name(semester['semesterName'])
        year = semester['yearName']

        # {section_id: [student_id1, student_id2]}
        csv_enrollment = {}
        for row in [i for i in csv if i['School Year'] == year]:
            section_id = row['Q{} SectionID'.format(quarter)]
            if not section_id in csv_enrollment:
                csv_enrollment[section_id] = []
            csv_enrollment[section_id].append(row['Student ID'])

        # [{Course Name: blah, 'To Enroll': [], 'To Unenroll': []}]
        diffs = []
        sections_by_id = {
            i['id']: i
            for i in qs.get_sections(semester_id=semester_id)
        }
        for section_id, enrollment in csv_enrollment.iteritems():
            online_enrollment = [
                i['smsStudentStubId']
                for i in qs.get_section_enrollment(section_id)
            ]
            missing_from_online = [
                i for i in enrollment if i not in online_enrollment
            ]
            missing_from_csv = [
                i for i in online_enrollment if i not in enrollment
            ]
            if missing_from_csv or missing_from_online:
                section = sections_by_id[section_id]
                diffs.append({
                    'Course Name':
                    section['sectionName'],
                    'Course Code':
                    section['sectionCode'],
                    'Course Grade Level':
                    section['className'],
                    'Course Teacher(s)':
                    [i['fullName'] for i in section['teachers']],
                    'Course ID':
                    section_id,
                    'Students to Enroll':
                    qs.student_ids_to_names(missing_from_online),
                    'Students to Unenroll':
                    qs.student_ids_to_names(missing_from_csv),
                })
        output = output_filename(year, quarter)
        csv_tools.rows_to_csv(diffs,
                              output,
                              keys=[
                                  'Course Name',
                                  'Course Code',
                                  'Course Grade Level',
                                  'Course Teacher(s)',
                                  'Course ID',
                                  'Students to Enroll',
                                  'Students to Unenroll',
                              ])
        print "Finished semester: " + output