Example #1
0
def test1():
    district_subject_cell = qa.CellWithOrders(subject_avg_null_item,
                                              district_dimen_table,
                                              [district_where, exam_where],
                                              subject_item, subject_ids)

    district_subject_row = qa.ColSeriesCell(district_subject_cell,
                                            district_ids)

    district_sum_cell = qa.Cell(sum_avg_null_item, district_sum_table,
                                [district_where, exam_where])

    district_sum_row = qa.ColSeriesCell(district_sum_cell, district_ids)

    school_subject_cell = qa.CellWithOrders(subject_avg_rank_item,
                                            school_dimen_table,
                                            [school_where, exam_where],
                                            subject_item, subject_ids)
    school_subject_row = qa.ColSeriesCell(school_subject_cell, school_ids)

    school_sum_cell = qa.Cell(sum_avg_rank_item, school_sum_table,
                              [school_where, exam_where])
    school_sum_row = qa.ColSeriesCell(school_sum_cell, school_ids)

    first_row = [
        '类别', '语文', '排名', '数学', '英语', '排名', '物理', '排名', '化学', '排名', '总分', '排名'
    ]
    datarows = [[district_subject_row, district_sum_row],
                [school_subject_row, school_sum_row]]
    table_rows = qa.TableRows(first_row, district_school_names, *datarows)
    for table_row in table_rows.get_values():
        print(table_row)
Example #2
0
def test8_1():
    class_sum_avg_rank_cell = qa.Cell(
        sum_avg_rank_item, class_sum_table,
        [[school_where, class_where], exam_where])
    class_subject_avg_rank_cell = qa.CellWithOrders(
        subject_avg_rank_item, class_dimen_table,
        [[school_where, class_where], exam_where], "subjectId", subject_ids)
    class_sum_avg_rank_row = qa.ColSeriesCell(class_sum_avg_rank_cell,
                                              school_class_ids)
    class_subject_rank_row = qa.ColSeriesCell(class_subject_avg_rank_cell,
                                              school_class_ids)
    first_row = [
        '学校',
        '班级',
        '总分',
        '排名',
        '语文',
        '排名',
        '数学',
        '英语',
        '排名',
        '物理',
        '排名',
        '化学',
        '排名',
    ]
    datarows = [class_sum_avg_rank_row, class_subject_rank_row]
    table_rows = qa.TableRows(first_row, school_class_names, datarows)
    for table_row in table_rows.get_values():
        print(table_row)
Example #3
0
def test2():
    school_subject_cell = qa.CellWithOrders(subject_avg_item,
                                            school_dimen_table,
                                            [school_where, exam_where],
                                            subject_item, subject_ids)
    school_subject_row = qa.ColSeriesCell(school_subject_cell, school_ids)

    school_sum_cell = qa.Cell(sum_avg_five_item, school_sum_table,
                              [school_where, exam_where])
    school_sum_row = qa.ColSeriesCell(school_sum_cell, school_ids)

    datarows = qa.DataRows.combine_col_rows(school_sum_row, school_subject_row)
    for table_row in list_util.combine_values_by_col(school_names, datarows):
        print(table_row)
def get_district_subject_std_values(subject_name, table_code):
    wheres = [school_where, exam_where]
    if subject_name == "总分":
        stu_table = table_config.get_stu_sum_table(table_code)
        school_table = table_config.get_school_sum_table(table_code)
    else:
        stu_table = table_config.get_stu_dimen_table(table_code)
        school_table = table_config.get_school_dimen_table(table_code)

        subject_where.set_value(get_subject_id_by_name(subject_name))
        wheres.append(subject_where)

    subject_total = report_config.get_total(subject_name)

    xresult = []
    yresult = []

    school_subject_num_cell = qa.Cell("num_nz", school_table, wheres)
    school_subject_num_row = qa.RowSeriesCell(school_subject_num_cell, school_ids)

    school_subject_avg_cell = qa.Cell("ROUND(avg / %d, 2)" % subject_total, school_table, wheres)
    school_subject_avg_row = qa.RowSeriesCell(school_subject_avg_cell, school_ids)

    stu_subject_sum_cell = qa.Cell("sum", stu_table, wheres)
    stu_subject_sum_row = qa.ColSeriesCell(stu_subject_sum_cell, school_ids)

    for value in stu_subject_sum_row.get_values():
        yresult.append(round(np.std(value, ddof=1), 2))
    xresult = school_subject_avg_row.get_values()[0]
    num = school_subject_num_row.get_values()[0]
    return xresult, yresult, num
def get_class_subject_items_values(item, table_code, subject_id):
    table = table_config.get_class_dimen_table(table_code)
    subject_where.set_value(subject_id)

    line_cell = qa.Cell(item, table, [[school_where, class_where], subject_where, exam_where])
    line_row = qa.ColSeriesCell(line_cell, class_ids)
    return line_row.get_values()
Example #6
0
def test7():
    district_dimen_avg_cell = qa.Cell(
        dimen_avg_items, district_dimen_table,
        [district_where, exam_where, subject_where])
    district_dimen_avg_row = qa.ColSeriesCell(district_dimen_avg_cell,
                                              district_ids)

    school_dimen_avg_cell = qa.Cell(dimen_avg_items, school_dimen_table,
                                    [school_where, exam_where, subject_where])
    school_dimen_avg_row = qa.ColSeriesCell(school_dimen_avg_cell, school_ids)

    first_row = ['学校', dimen_names]
    datarows = [district_dimen_avg_row, school_dimen_avg_row]
    table_rows = qa.TableRows(first_row, district_school_names, *datarows)
    for table_row in table_rows.get_values():
        print(table_row)
def get_school_subject_items_rows(item, table_code, subject_id):
    table = table_config.get_school_dimen_table(table_code)
    subject_where.set_value(subject_id)
    varied_where = school_where

    line_cell = qa.Cell(item, table, [varied_where, subject_where, exam_where])
    line_row = qa.ColSeriesCell(line_cell, school_ids)
    return list_util.combine_values_by_col(school_names, line_row.get_values())
Example #8
0
def test8():
    school_rank_diff_cell = qa.Cell(dimen_avg_items, school_dimen_table,
                                    [exam_where, school_where, subject_where])
    school_rank_diff_row = qa.ColSeriesCell(school_rank_diff_cell, exam_ids)

    datarows = school_rank_diff_row.get_values()
    for table_row in list_util.combine_values_by_col(exam_names, datarows):
        print(table_row)
def get_school_subject_values(item, table_code):
    varied_where = school_where
    table = table_config.get_school_dimen_table(table_code)
    ids = school_ids

    subject_cell = qa.CellWithOrders(item, table, [varied_where, exam_where], "subjectId", subject_ids)
    subject_row = qa.ColSeriesCell(subject_cell, ids)
    return subject_row.get_values()
def get_district_sum_line_of_rows(item, table_code):
    if table_code == table_config.QA:
        table = table_config.QA_SCHOOL_LINE_TABLE
    elif table_code == table_config.QA_ZK:
        table = table_config.QA_ZK_SCHOOL_LINE_TABLE
    varied_where = school_where
    line_cell = qa.Cell(item, table, [varied_where, exam_where])
    line_row = qa.ColSeriesCell(line_cell, school_ids)
    return list_util.combine_values_by_col(school_names, line_row.get_values())
Example #11
0
def test4():
    school_subject_cell = qa.CellWithOrders(num_item, school_dimen_table,
                                            [school_where, exam_where],
                                            subject_item, subject_ids)
    school_subject_row = qa.ColSeriesCell(school_subject_cell, school_ids)

    datarows = school_subject_row.get_values()
    for table_row in list_util.combine_values_by_col(school_names, datarows):
        print(table_row)
Example #12
0
def test1():
    district_subject_cell = qa.CellWithOrders(subject_avg_item,
                                              district_dimen_table,
                                              [district_where, exam_where],
                                              subject_item, subject_ids)

    district_subject_row = qa.ColSeriesCell(district_subject_cell,
                                            district_ids)

    district_sum_cell = qa.Cell(sum_avg_five_item, district_sum_table,
                                [district_where, exam_where])

    district_sum_row = qa.ColSeriesCell(district_sum_cell, district_ids)

    datarows = qa.DataRows.combine_col_rows(district_sum_row,
                                            district_subject_row)
    for table_row in list_util.combine_values_by_col(district_names, datarows):
        print(table_row)
def get_class_sum_subject_avg_rank_values():
    if base_student == report_config.SPECIAL:
        sum_table = table_config.QA_ZK_CLASS_SUM_TABLE
        dimen_table = table_config.QA_ZK_CLASS_DIMEN_TABLE
    elif base_student == report_config.CURRENT:
        sum_table = table_config.QA_CLASS_SUM_TABLE
        dimen_table = table_config.QA_CLASS_DIMEN_TABLE

    item = item_config.AVG_RANK_ITEM

    class_sum_cell = qa.Cell(item, sum_table,
                             [[school_where, class_where], exam_where])
    class_subject_cell = qa.CellWithOrders(item, dimen_table,
                                           [[school_where, class_where], exam_where], "subjectId", subject_ids)
    class_sum_row = qa.ColSeriesCell(class_sum_cell, class_ids)
    class_subject_row = qa.ColSeriesCell(class_subject_cell, class_ids)

    return qa.DataRows.combine_col_rows(class_sum_row, class_subject_row)
Example #14
0
def test6():
    district_exams_avg_cell = qa.CellWithOrders(
        subject_avg_item, district_dimen_table,
        [district_where, subject_where], exam_item, exam_ids)
    district_exams_avg_row = qa.ColSeriesCell(district_exams_avg_cell,
                                              district_ids)

    datarows = district_exams_avg_row.get_values()
    for table_row in list_util.combine_values_by_col(district_names, datarows):
        print(table_row)
Example #15
0
def test6():
    school_sum_line_cell = qa.Cell(line_items, school_line_table,
                                   [school_where, exam_where])
    school_sum_line_row = qa.ColSeriesCell(school_sum_line_cell, school_ids)

    first_row = ['学校', line_names]
    datarows = school_sum_line_row
    table_rows = qa.TableRows(first_row, school_names, datarows)
    for table_row in table_rows.get_values():
        print(table_row)
def get_subject_sum_values(item, type_code, district_code):
    if district_code == DISTRICT_CODE:
        dimen_table, sum_table = table_config.get_district_table(type_code)
        varied_where = district_where
        ids = district_ids
    elif district_code == SCHOOL_CODE:
        dimen_table, sum_table = table_config.get_school_table(type_code)
        varied_where = school_where
        ids = school_ids

    subject_cell = qa.CellWithOrders(item, dimen_table,
                                     [varied_where, exam_where], "subjectId",
                                     subject_ids)
    subject_row = qa.ColSeriesCell(subject_cell, ids)

    sum_cell = qa.Cell(item, sum_table, [varied_where, exam_where])
    sum_row = qa.ColSeriesCell(sum_cell, ids)
    return list_util.combine_values_by_col(sum_row.get_values(),
                                           subject_row.get_values())
def get_school_sum_values(item, table_code):
    subject_values = get_school_subject_values(item, table_code)

    varied_where = school_where
    table = table_config.get_school_sum_table(table_code)
    ids = school_ids

    sum_cell = qa.Cell(item, table, [varied_where, exam_where])
    sum_row = qa.ColSeriesCell(sum_cell, ids)
    return list_util.combine_values_by_col(sum_row.get_values(), subject_values)
Example #18
0
    def avg_rank_of_subject_sum_of_districts_schools(self):
        district_dimen_table = TableName.dimen(BaseStudent.NORMAL, District.DISTRICT, Subject.SUBJECT)
        exam_where = WhereFactory.exam(self.exam.exam_id)
        district_subject_cell = qa.CellWithOrders(Item.SUBJECT_AVG_NULL, district_dimen_table,
                                                  [WhereFactory.district(), exam_where],
                                                  Item.SUBJECT, subject_ids)

        district_subject_row = qa.ColSeriesCell(district_subject_cell, ReportController.district_ids)

        district_sum_table = TableName.dimen(BaseStudent.NORMAL, District.DISTRICT, Subject.SUM)
        district_sum_cell = qa.Cell(Item.get_sum_avg_null(self.sum_count), district_sum_table,
                                    [WhereFactory.district(), exam_where])

        district_sum_row = qa.ColSeriesCell(district_sum_cell, ReportController.district_ids)

        datarows = qa.DataRows.combine_col_rows(district_sum_row, district_subject_row)
        district_names = list_util.add_something_to_list("(实考)", ReportController.district_names)
        for table_row in list_util.combine_values_by_row(FirstRow.AVG_RANK_OF_SUM_SUBJECT,
                                                         list_util.combine_values_by_col(district_names, datarows)):
            print(table_row)
def get_district_subject_box_values(subject_name, table_code):
    wheres = [school_where, exam_where]
    if subject_name == "总分":
        stu_table = table_config.get_stu_sum_table(table_code)
    else:
        stu_table = table_config.get_stu_dimen_table(table_code)
        subject_where.set_value(get_subject_id_by_name(subject_name))
        wheres.append(subject_where)
    stu_subject_sum_cell = qa.Cell("sum", stu_table, wheres)
    stu_subject_sum_row = qa.ColSeriesCell(stu_subject_sum_cell, school_ids)
    return stu_subject_sum_row.get_values()
def get_school_exam_values(item, table_code, subject_id):
    subject_where.set_value(subject_id)
    varied_where = school_where
    table = table_config.get_school_dimen_table(table_code)
    ids = school_ids

    start, end = qam_dao.get_subject_exam_start_end(exam, subject_id)
    exam_ids = all_exam_ids[start:end + 1]
    exam_cell = qa.CellWithOrders(item, table, [varied_where, subject_where], "examId", exam_ids)
    exam_row = qa.ColSeriesCell(exam_cell, ids)
    return exam_row.get_values()
Example #21
0
def test9():
    school_rank_diff_cell = qa.Cell(
        dimen_rank_diff_items, school_rank_diff_table,
        [[font_exam_where, behind_exam_where], font_school_where,
         behind_school_where, font_subject_where, behind_subject_where])
    school_rank_diff_row = qa.ColSeriesCell(school_rank_diff_cell,
                                            exam_diff_ids)

    datarows = school_rank_diff_row.get_values()
    for table_row in list_util.combine_values_by_col(exam_diff_names,
                                                     datarows):
        print(table_row)
def get_exam_subject_values(item, table_code, school_id, subject_id):
    subject_where.set_value(subject_id)
    school_where.set_value(school_id)
    varied_where = exam_where
    start, end = qam_dao.get_subject_exam_start_end(exam, subject_id)
    exam_ids = all_exam_ids[start:end + 1]

    table = table_config.get_school_dimen_table(table_code)
    ids = exam_ids

    exam_cell = qa.Cell(item, table, [varied_where, school_where, subject_where])
    exam_row = qa.ColSeriesCell(exam_cell, ids)
    return exam_row.get_values()
Example #23
0
def table_of_dimen_sum(item,
                       table,
                       exam_where,
                       varied_where,
                       ids,
                       subject_ids=None):
    if subject_ids is None:
        cell = qa.Cell(item, table, [varied_where, exam_where])
    else:
        cell = qa.CellWithOrders(item, table, [varied_where, exam_where],
                                 "subjectId", subject_ids)
    if cell is None:
        return []
    else:
        return qa.ColSeriesCell(cell, ids).get_values()
    def __init__(self, exam, gradation, where):
        self.exam = exam
        self.gradation = gradation
        self.where = where

        # self.exam = handler.Exam()
        # self.gradation = handler.Gradation()
        # self.where = handler.Where()

        self.cell_where = qa.CellWhere()
        self.cell_order = qa.CellOrder()

        self.cell = qa.Cell(where_list=self.cell_where)
        self.order_cell = qa.CellWithOrders(where_list=self.cell_where, order=self.cell_order)

        self.row_value = qa.RowSeriesCell()
        self.col_value = qa.ColSeriesCell()
def get_exam_rank_diff_values(item, table_code, school_id, subject_id):
    font_subject_where = qa.Where("font.subjectId", subject_id)
    behind_subject_where = qa.Where("behind.subjectId", subject_id)
    font_school_where = qa.Where("font.schoolId", school_id)
    behind_school_where = qa.Where("behind.schoolId", school_id)

    varied_where = [qa.Where("font.examId"), qa.Where("behind.examId")]
    start, end = qam_dao.get_subject_exam_start_end(exam, subject_id)
    exam_ids = all_exam_ids[start:end + 1]
    exam_diff_ids = get_rank_diff_exam_ids(exam_ids)

    table = table_config.get_school_dimen_table(table_code)
    table = ["%s AS font" % table, "%s AS behind" % table]
    ids = exam_diff_ids

    exam_cell = qa.Cell(item, table, [varied_where, font_school_where, behind_school_where, font_subject_where,
                                      behind_subject_where])
    exam_row = qa.ColSeriesCell(exam_cell, ids)
    return exam_row.get_values()
 def get_value(self):
     return qa.ColSeriesCell(self.get_cell(), self.ids).get_values()
Example #27
0
 def get_col_value(cell, ids):
     return qa.ColSeriesCell(cell, ids).get_values()
Example #28
0
def test4():
    stu_subject_sum_cell = qa.Cell("sum", "qa_stu_dimen",
                                   [school_where, exam_where, subject_where])
    stu_subject_sum_row = qa.ColSeriesCell(stu_subject_sum_cell, school_ids)
    print(school_names)
    print(stu_subject_sum_row.get_values())