def get_district_school_avg_rank(self, table_code): first_col = self.get_district_first_col(table_code) item = item_config.AVG_ITEM district_sum_avg = self.value.get_district_one_row( item, table_code, DISTRICT_CODE) school_sum_avg = self.value.get_district_one_row( item, table_code, SCHOOL_CODE) district_subject_avg = self.value.get_exam_subject( item, table_code, DISTRICT_CODE) school_subject_avg = self.value.get_exam_subject( item, table_code, SCHOOL_CODE) item = item_config.RANK_ITEM school_subject_rank = self.value.get_exam_subject( item, table_code, SCHOOL_CODE) school_sum_rank = self.value.get_district_one_row( item, table_code, SCHOOL_CODE) subject_len = len(self.gradation.subject_names) district_len = len(self.gradation.district_names) district_subject_avg_rank = list_util.cross_several_row( district_subject_avg, [[''] * subject_len] * district_len) school_subject_avg_rank = list_util.cross_several_row( school_subject_avg, school_subject_rank) district_value = list_util.combine_values_by_col( district_sum_avg, [''] * subject_len, district_subject_avg_rank, ) school_value = list_util.combine_values_by_col( school_sum_avg, school_sum_rank, school_subject_avg_rank) return list_util.combine_values_by_col(first_col, district_value + school_value)
def get_class_avg_rank(self, class_id): class_index = self.exam.get_class_index(class_id) school_index = self.exam.get_school_index(class_id[0]) table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE item = item_config.AVG_ITEM class_subject_avg = self.value.get_exam_subject(item, table_code, CLASS_CODE) class_sum_avg = self.value.get_district_one_row(item, table_code, CLASS_CODE) school_subject_avg = self.value.get_exam_subject(item, table_code, SCHOOL_CODE) school_sum_avg = self.value.get_district_one_row(item, table_code, SCHOOL_CODE) district_subject_avg = self.value.get_exam_subject(item, table_code, DISTRICT_CODE) district_sum_avg = self.value.get_district_one_row(item, table_code, DISTRICT_CODE) item = item_config.RANK_ITEM class_subject_rank = self.value.get_exam_subject(item, table_code, CLASS_CODE) class_sum_rank = self.value.get_district_one_row(item, table_code, CLASS_CODE) first_row = first_row_config.CLASS_AVG_OF_SUM_SUBJECT first_col = ['排名', '班级平均分', '学校平均分', '区平均分'] class_rank = list_util.combine_values_by_col(class_sum_rank[class_index:class_index + 1], class_subject_rank[class_index:class_index + 1]) class_avg = list_util.combine_values_by_col(class_sum_avg[class_index:class_index + 1], class_subject_avg[class_index:class_index + 1]) school_avg = list_util.combine_values_by_col(school_sum_avg[school_index:school_index + 1], school_subject_avg[school_index:school_index + 1]) district_avg = list_util.combine_values_by_col(district_sum_avg[0:1], district_subject_avg[0:1]) print(first_row) print_rows(list_util.combine_values_by_col(first_col, class_rank + class_avg + school_avg + district_avg))
def get_all_district_class_avg_rank(self): first_row = first_row_config.AVG_RANK_OF_SUM_SUBJECT_CLASS table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = self.exam.class_names item = item_config.AVG_ITEM class_subject_avg = self.value.get_exam_subject( item, table_code, CLASS_CODE) class_sum_avg = self.value.get_district_one_row( item, table_code, CLASS_CODE) item = item_config.RANK_ITEM class_subject_rank = self.value.get_exam_subject( item, table_code, CLASS_CODE) class_sum_rank = self.value.get_district_one_row( item, table_code, CLASS_CODE) class_sum = list_util.combine_values_by_col(class_sum_avg, class_sum_rank) class_subject = list_util.cross_several_row(class_subject_avg, class_subject_rank) rows = [first_row] rows += list_util.combine_values_by_col(first_col, class_sum, class_subject) excel_util.put_rows_to_sheet(self.wb, "各班级各科分数和排名", rows)
def get_subject_sum_rows(item, type_code, district_code): qa_values = get_subject_sum_values(item, table_config.QA, district_code) names = get_names(type_code, district_code) if type_code == report_config.SPECIAL: qa_zk_values = get_subject_sum_values(item, table_config.QA_ZK, district_code) return list_util.combine_values_by_col(names, qa_values + qa_zk_values) elif type_code == report_config.CURRENT: return list_util.combine_values_by_col(names, qa_values)
def get_school_avg_rank(self, table_code, school_id): first_col = self.get_school_first_col(school_id, table_code) item = item_config.AVG_ITEM district_sum_avg = self.value.get_district_one_row(item, table_code, DISTRICT_CODE) school_sum_avg = self.value.get_district_one_row(item, table_code, SCHOOL_CODE) district_subject_avg = self.value.get_exam_subject(item, table_code, DISTRICT_CODE) school_subject_avg = self.value.get_exam_subject(item, table_code, SCHOOL_CODE) district_value = list_util.combine_values_by_col(district_sum_avg, district_subject_avg) school_value = list_util.combine_values_by_col(school_sum_avg, school_subject_avg) school_index = self.exam.get_school_index(school_id) print_rows( list_util.combine_values_by_col(first_col, district_value + school_value[school_index:school_index + 1]))
def get_school_subject_exams_avg_rank(self, school_id, subject_id): school_index = self.exam.get_school_index(school_id) school_type = self.exam.school_types[school_index] district_index = self.gradation.get_district_index(school_type) first_row = self.exam.get_exam_nicks(subject_id) first_row.insert(0, "考试") table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = ['排名', '区平均分', '同类学校平均分', '校平均分'] item = item_config.RANK_ITEM school_rank = self.value.get_subject_exam(item, table_code, SCHOOL_CODE, subject_id) item = item_config.AVG_ITEM district_avg = self.value.get_subject_exam(item, table_code, DISTRICT_CODE, subject_id) school_avg = self.value.get_subject_exam(item, table_code, SCHOOL_CODE, subject_id) values = school_rank[school_index:school_index + 1] + district_avg[0:1] + \ district_avg[district_index:district_index + 1] + school_avg[school_index:school_index + 1] print(first_row) print_rows(list_util.combine_values_by_col(first_col, values))
def get_class_subject_dimen_ratio(self, class_id, subject_id): index = self.gradation.get_subject_index(subject_id) class_index = self.exam.get_class_index(class_id) school_index = self.exam.get_school_index(class_id[0]) table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_row = self.exam_subject_dimen_description[index] dimen_len = len(first_row) first_row.insert(0, "学校") first_col = ['班级', '学校', '区'] item = item_config.DIMEN_RATIO_ITEMS[:dimen_len] district_dimen_ratio = self.value.get_exam_dimen( item, table_code, DISTRICT_CODE, subject_id) school_dimen_ratio = self.value.get_exam_dimen(item, table_code, SCHOOL_CODE, subject_id) class_dimen_ratio = self.value.get_exam_dimen(item, table_code, CLASS_CODE, subject_id) values = class_dimen_ratio[ class_index:class_index + 1] + district_dimen_ratio[ 0:1] + school_dimen_ratio[school_index:school_index + 1] print(first_row) print_rows(list_util.combine_values_by_col(first_col, values))
def get_value(self): where = CellWhere(self.o_varied_where, self.fixed_where) cell = CellFactory.get_cell(self.select, where) greater_value = super(AllDistributionValue, self).get_value() greater_equal_value = ValueFactory.get_row_value(cell, self.o_ids)[0] return list_util.combine_values_by_col([greater_equal_value], [greater_value])[0]
def get_school_sum_rows(item, table_code, first_col_exra=None): sum_values = get_school_sum_values(item, table_code) if first_col_exra is None: first_col = school_names else: first_col = list_util.add_something_to_list(first_col_exra, school_names) return list_util.combine_values_by_col(first_col, sum_values)
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_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())
def get_school_num(self, table_code, school_id): first_col = self.get_school_first_col(school_id, table_code) item = item_config.NUM_ITEM district_subject_num = self.value.get_exam_subject(item, table_code, DISTRICT_CODE) school_subject_num = self.value.get_exam_subject(item, table_code, SCHOOL_CODE) school_index = self.exam.get_school_index(school_id) print_rows(list_util.combine_values_by_col(first_col, district_subject_num + school_subject_num[ school_index:school_index + 1]))
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)
def get_district_num(self, table_code): first_col = self.get_district_first_col(table_code) item = item_config.NUM_ITEM district_subject_num = self.value.get_exam_subject( item, table_code, DISTRICT_CODE) school_subject_num = self.value.get_exam_subject( item, table_code, SCHOOL_CODE) return list_util.combine_values_by_col( first_col, district_subject_num + school_subject_num)
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())
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)
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)
def get_all_district_line(self): first_row = first_row_config.LINE_OF_25_60_85 print(first_row) table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = self.exam.school_names item = item_config.LINE_25_60_85_ITEMS school_sum_line = self.value.get_exam_school_line(item, table_code) print_rows(list_util.combine_values_by_col(first_col, school_sum_line))
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_all_school_line(self, school_id): first_row = first_row_config.LINE_OF_25_60_85 print(first_row) table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE item = item_config.LINE_25_60_85_ITEMS school_sum_line = self.value.get_exam_school_line(item, table_code) index = self.exam.get_school_index(school_id) first_col = self.exam.school_names print_rows(list_util.combine_values_by_col(first_col[index:index + 1], school_sum_line[index:index + 1]))
def get_all_district_line(self): first_row = first_row_config.LINE_OF_25_60_85 rows = [first_row] table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = self.exam.school_names item = item_config.LINE_25_60_85_ITEMS school_sum_line = self.value.get_exam_school_line(item, table_code) rows += list_util.combine_values_by_col(first_col, school_sum_line) excel_util.put_rows_to_sheet(self.wb, "各校前25%、60%、85%人数", rows)
def get_values(self): self.first_row = list_util.to_a_list(self.first_row) result = [self.first_row] if isinstance(self.first_col[0], list): result.extend( list_util.combine_values_by_col( self.first_col, DataRows.get_values(*self.data_rows))) else: for index, data_row in enumerate( DataRows.get_values(*self.data_rows)): data_row.insert(0, self.first_col[index]) result.append(data_row) return result
def get_school_exam_subject_dimen_avg(self, school_id, subject_id): index = self.gradation.get_subject_index(subject_id) first_row = self.exam_subject_dimen_description[index] dimen_len = len(first_row) first_row.insert(0, "考试") table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = self.exam.get_exam_nicks(subject_id) item = item_config.DIMEN_AVG_ITEMS[:dimen_len] school_dimen_rank = self.value.get_subject_dimen(item, table_code, SCHOOL_CODE, school_id, subject_id) print(first_row) print_rows(list_util.combine_values_by_col(first_col, school_dimen_rank))
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_all_district_dimen_avg(self, subject_id): index = self.gradation.get_subject_index(subject_id) first_row = self.exam_subject_dimen_description[index] dimen_len = len(first_row) first_row.insert(0, "学校") print(first_row) table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = self.exam.school_names + self.gradation.district_names item = item_config.DIMEN_AVG_ITEMS[:dimen_len] district_dimen_avg = self.value.get_exam_dimen(item, table_code, DISTRICT_CODE, subject_id) school_dimen_avg = self.value.get_exam_dimen(item, table_code, SCHOOL_CODE, subject_id) print_rows(list_util.combine_values_by_col(first_col, district_dimen_avg + school_dimen_avg))
def get_school_exam_subject_dimen_rank_diff(self, school_id, subject_id): index = self.gradation.get_subject_index(subject_id) school_index = self.exam.get_school_index(school_id) first_row = self.exam_subject_dimen_description[index] dimen_len = len(first_row) first_row.insert(0, "知识块(排名变化)") table_code = QA_CODE if self.exam.base_student == handler.Exam.SPECIAL: table_code = QA_ZK_CODE first_col = self.exam.get_subject_exam_diff_names(subject_id) item = item_config.DIMEN_RANK_DIFF_ITEMS[:dimen_len] school_dimen_rank_diff = self.value.get_dimen_diff(item, table_code, school_id, subject_id) print(first_row) print_rows(list_util.combine_values_by_col(first_col, school_dimen_rank_diff))
def school_exam_dimen_avg_table(subject_id, index): subject_where.set_value(subject_id) dimen_description = qam_dao.get_dimen_description_by_exam(exam_where, subject_where) dimen_length = len(dimen_description) dimen_item = item_config.DIMEN_AVG_ITEMS[0:dimen_length] if base_student == report_config.SPECIAL: table_code = table_config.QA_ZK elif base_student == report_config.CURRENT: table_code = table_config.QA school_values = get_exam_subject_values(dimen_item, table_code, school_ids[index], subject_id) start, end = qam_dao.get_subject_exam_start_end(exam, subject_id) exam_nicks = all_exam_nicks[start:end + 1] result = list_util.combine_values_by_col(exam_nicks, school_values) dimen_description.insert(0, "知识块(平均分)") result.insert(0, dimen_description) return result
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_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 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)