<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qmth.teachcloud.report.business.mapper.CourseReportMapper">

    <select id="findCollegeCourseInfo"
            resultType="com.qmth.teachcloud.report.business.bean.result.inspectCourseExamTotal.CollegeCourseInfo">
        SELECT
            col.course_code AS courseCode,
            col.course_name AS courseName,
            col.reality_count AS colRealityCount,
            round( col.avg_score, 2 ) AS colAvgScore,
            round( col.min_score, 2 ) AS colMinScore,
            round( col.max_score, 2 ) AS colMaxScore,
            round( col.upper_quartile, 2 ) AS colUpperQuartile,
            round( col.median, 2 ) AS colMedian,
            round( col.lower_quartile, 2 ) AS colLowerQuartile,
            col.mode AS colMode,
            round( col.standard_deviation, 2 ) AS colStandardDeviation,
            round( relative_position, 2 ) AS colRelativePosition,
            round( pap.avg_score, 2 ) AS schAvgScore,
            round( pap.current_min_score, 2 ) AS schMinScore,
            round( pap.current_max_score, 2 ) AS schMaxScore,
            round( pap.current_upper_quartile, 2 ) AS schUpperQuartile,
            round( pap.current_median, 2 ) AS schMedian,
            round( pap.current_lower_quartile, 2 ) AS schLowerQuartile,
            pap.current_mode AS schMode,
            round( pap.current_standard_deviation, 2 ) AS schStandardDeviation
        FROM
            t_a_exam_course_college_inspect col
                INNER JOIN t_a_exam_course pap ON col.exam_id = pap.exam_id
                AND col.course_code = pap.course_code
                AND col.school_id = pap.school_id
            join t_b_exam_course tbec on tbec.exam_id = col.exam_id and
		        tbec.course_code = col.course_code
        WHERE
            col.exam_id = #{examId}
          AND col.college_id = #{collegeId}
          and tbec.publish_status = 'PUBLISH'
        ORDER BY
            col.course_code;
    </select>
    <select id="findExamTotalByExamId"
            resultType="com.qmth.teachcloud.report.business.bean.result.inspectCourseExamTotal.ExamBaseInfo">
        SELECT
            college_count AS collegeCount,
            course_count AS courseCount,
            public_course_count AS publicCourseCount,
            major_course_count AS majorCourseCount,
            total_course_times AS totalCourseTimes,
            reality_course_times AS realityCourseTimes,
            absent_course_times AS absentCourseTimes,
            total_count AS totalCount,
            reality_count AS realityCount,
            absent_count AS absentCount,
            exam_time AS examTime
        FROM
            t_a_exam_total
        WHERE
            exam_id = #{examId}
    </select>
    <select id="list1" resultType="java.util.Map">
        SELECT
	d.exam_student_id id,
	e.small_question_number num,
	t.score,
	e.full_score,
	f.inspect_college_id
FROM
	(
SELECT
	*
FROM
	t_b_answer a
WHERE
	a.exam_record_id IN ( SELECT id FROM t_b_exam_record b WHERE b.exam_student_id IN ( SELECT id FROM t_b_exam_student WHERE course_code = 1001 ) )
	) t
	JOIN t_b_exam_record d ON t.exam_record_id = d.id
	JOIN t_b_exam_student f ON d.exam_student_id = f.id
	JOIN t_b_paper_struct e ON d.paper_id = e.paper_id
	AND t.number_type = e.number_type
	AND t.main_number = e.big_question_number
	AND t.sub_number = e.small_question_number
    </select>
</mapper>