예제 #1
0
def test2():
    ids = []
    names = []
    start, end, step = [0, 150, 5]
    scopes = range(start, end, step)

    for index, scope in enumerate(scopes[0:-1]):
        ids.append([scope, scopes[index + 1]])
        names.append("(%d, %d]" % (scope, scopes[index + 1]))
    if scopes[-1] < end:
        ids.append([scopes[-1], end])
        names.append("(%d, %d]" % (scopes[-1], end))
    names[0] = "[%d, %d]" % (scopes[0], scopes[1])

    greater_equal_where = qa.Where("sum", symbol=">=")
    greater_where = qa.Where("sum", symbol=">")
    less_equal_where = qa.Where("sum", symbol="<=")

    cell1 = qa.Cell(
        "COUNT(*)", stu_dimen_table,
        [[greater_equal_where, less_equal_where], exam_where, subject_where])
    cell2 = qa.Cell(
        "COUNT(*)", stu_dimen_table,
        [[greater_where, less_equal_where], exam_where, subject_where])
    row1 = qa.RowSeriesCell(cell1, ids[0:1])
    row2 = qa.RowSeriesCell(cell2, ids[1:])
    table = qa.TableRows(["分数段", names], ['个数'], [row1, row2])
    for table_row in table.get_values():
        print(table_row)
def get_district_subject_distribution_values(subject_name, ids, table_code):
    distribution = report_config.get_distribution(subject_name)
    statistics_type = distribution[0]

    greater_where = qa.Where("sum", symbol=">")
    less_equal_where = qa.Where("sum", symbol="<=")

    basic_where = [exam_where]
    if subject_name == "总分":
        dimen_table = table_config.get_stu_sum_table(table_code)
        if statistics_type == report_config.COUNT:
            basic_where.append(qa.Where("count", value=distribution[2]))
    else:
        dimen_table = table_config.get_stu_dimen_table(table_code)
        subject_where.value = get_subject_id_by_name(subject_name)
        basic_where.append(subject_where)

    normal_cell = qa.Cell("COUNT(*)", dimen_table, [[greater_where, less_equal_where]] + basic_where)
    if statistics_type == report_config.ALL:
        greater_equal_where = qa.Where("sum", symbol=">=")
        extra_cell = qa.Cell("COUNT(*)", dimen_table, [[greater_equal_where, less_equal_where]] + basic_where)
        row1 = qa.RowSeriesCell(extra_cell, ids[0:1])
        row2 = qa.RowSeriesCell(normal_cell, ids[1:])
        return qa.DataRows.combine_col_rows(row1, row2)
    else:
        row = qa.RowSeriesCell(normal_cell, ids)
        return row.get_values()
예제 #3
0
def district_avg_rank_of_sum_subject(exam_where, subject_ids, district_ids, school_ids, district_names, school_names,
                                     type_code):
    district_where = qa.Where("district")
    school_where = qa.Where("school")
    dimen_table = QA_DISTRICT_DIMEN_TABLE
    sum_table = QA_DISTRICT_SUM_TABLE
    district_subject_values = rows_service.table_of_dimen_sum_values(AVG_NULL_ITEM, dimen_table, exam_where,
                                                                     district_where,
                                                                     district_ids, subject_ids)
    district_sum_values = rows_service.table_of_dimen_sum_values(AVG_NULL_ITEM, sum_table, exam_where, district_where,
                                                                 district_ids)
예제 #4
0
def get_dimen_description_by_exam(exam_id, subject_id):
    where_list = qa.CellWhere(qa.Where("examId", exam_id),
                              qa.Where("subjectId", subject_id))
    cell = qa.Cell(item_config.DIMEN_DESC_ITEMS, "qam_dimen_info", where_list)

    values = cell.get_row_values()
    values.reverse()
    for index, value in enumerate(values):
        if value is not None and value != '':
            result = values[index:]
            result.reverse()
            return result
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()
예제 #6
0
 def subject(value=""):
     return qa.Where("subjectId", value=value)
예제 #7
0
 def school(value=""):
     return qa.Where("schoolId", value=value)
예제 #8
0
 def district(value=""):
     return qa.Where("districtId", value=value)
예제 #9
0
 def exam(value=""):
     return qa.Where("examId", value=value)
JUNIOR_TABLE_EXTRA_TITLE = "(中考)"

REAL_CHART_EXTRA_TITLE = "实考",
JUNIOR_CHART_EXTRA_TITLE = "(参与中考)"

school_ids, school_names = report_config.get_school_info()
school_types = report_config.get_school_type()

district_ids, district_names = report_config.get_district_info()
subject_ids, subject_names = report_config.get_subject_info()

exam = report_config.exam
class_ids, class_names = report_config.get_class_ids()
grade_lev = report_config.exam.grade_lev
exam_id = report_config.exam.exam_id
exam_where = qa.Where("examId", exam_id)
district_where = qa.Where("districtId")
school_where = qa.Where("schoolId")
subject_where = qa.Where("subjectId")
class_where = qa.Where('classId')

district_len = len(district_ids)
school_len = len(school_ids)
class_len = len(class_ids)

all_exam_ids = qam_dao.get_exam_ids(exam)
all_exam_nicks = report_config.EXAM_NICKS_2

base_student = report_config.SPECIAL

예제 #11
0
JUNIOR_TABLE_EXTRA_TITLE = "(中考)"

REAL_CHART_EXTRA_TITLE = "实考",
JUNIOR_CHART_EXTRA_TITLE = "(参与中考)"

school_ids, school_names = report_config.get_school_info()
school_types = report_config.get_school_type()

district_ids, district_names = report_config.get_district_info()
subject_ids, subject_names = report_config.get_subject_info()

exam = report_config.exam
class_ids, class_names = report_config.get_class_ids()
grade_lev = report_config.exam.grade_lev
exam_id = report_config.exam.exam_id
exam_where = qa.Where("examId", exam_id)
district_where = qa.Where("districtId", 9)
school_where = qa.Where("schoolId", "002F2A5004B9421EBEC2AAD8A6CEB044")
subject_where = qa.Where("subjectId", 121)
class_where = qa.Where('classId', "0A036FDF66274D31B8DEC6F7E07A820F")

greater_where = qa.Where("sum", symbol=">")
less_equal_where = qa.Where("sum", symbol="<=")
greater_equal_where = qa.Where("sum", symbol=">=")
count_where = qa.Where("count")

district_len = len(district_ids)
school_len = len(school_ids)
class_len = len(class_ids)

all_exam_ids = qam_dao.get_exam_ids(exam)
예제 #12
0
    def __init__(self, exam_id):
        self.fixed_exam = qa.Where("examId", exam_id)

        self.varied_exam = qa.Where("examId")
        self.district = qa.Where("districtId")
        self.school = qa.Where("schoolId")
        self.subject = qa.Where("subjectId")
        self.class_t = qa.Where('classId')

        self.greater = qa.Where("sum", symbol=">")
        self.less_equal = qa.Where("sum", symbol="<=")
        self.greater_equal = qa.Where("sum", symbol=">=")
        self.count = qa.Where("count")

        self.font_exam = qa.Where("font.examId")
        self.behind_exam = qa.Where("behind.examId")
        self.font_school = qa.Where("font.schoolId")
        self.behind_school = qa.Where("behind.schoolId")
        self.font_subject = qa.Where("font.subjectId")
        self.behind_subject = qa.Where("behind.subjectId")
예제 #13
0
import numpy as np
import datetime

import refactoring.edu.domain.qa as qa
import refactoring.edu.dao.qam_dao as qam_dao
import refactoring.edu.util.list_util as list_util

exam_id = "8c4646637f44489c9ba9333e580fe9d0"
exam_where = qa.Where('examId', '8c4646637f44489c9ba9333e580fe9d0')
subject_where = qa.Where("subjectId", 121)
district_where = qa.Where('districtId', "9")
school_where = qa.Where('schoolId', "002F2A5004B9421EBEC2AAD8A6CEB044")
class_where = qa.Where('classId', "0A036FDF66274D31B8DEC6F7E07A820F")
font_exam_where = qa.Where("font.examId")
behind_exam_where = qa.Where("behind.examId")
font_school_where = qa.Where("font.schoolId",
                             "002F2A5004B9421EBEC2AAD8A6CEB044")
behind_school_where = qa.Where("behind.schoolId",
                               "002F2A5004B9421EBEC2AAD8A6CEB044")
font_subject_where = qa.Where("font.subjectId", 121)
behind_subject_where = qa.Where("behind.subjectId", 121)

grade_lev = 2

null_item = "''"
num_item = "num_nz"
subject_item = "subjectId"
subject_avg_item = 'round(avg, 2)'
subject_rank_item = 'rank'
exam_item = "examId"
subject_avg_null_item = [subject_avg_item, null_item]