Blame view

ExerciseDoneResultMapper.xml 6.27 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?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.subsidy.mapper.ExerciseDoneResultMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.ExerciseDoneResultDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="member_id" property="memberId" />
        <result column="course_id" property="courseId" />
        <result column="right_counts" property="rightCounts" />
        <result column="total_counts" property="totalCounts" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, member_id, course_id, right_counts, total_counts
    </sql>

涂亚平 committed
25 26 27 28 29 30 31 32
    <select id="queryExerciseDoneResult" resultType="com.subsidy.vo.administer.GetMemberPapersVO">
        SELECT
            t.id,
            t.paper_id,
            right_counts,
            total_counts,
            score,
            result,
涂亚平 committed
33 34
            create_date,
            start_date
涂亚平 committed
35 36 37 38 39 40 41 42 43 44 45
        FROM
            exercise_done_result t
        WHERE
            t.delete_date is null
            and t.member_id = #{memberId}
            <if test="classId != null and classId !=''">
                AND t.class_id = #{classId}
            </if>
            <if test="paperId != null and paperId !=''">
                AND t.paper_id = #{paperId}
            </if>
涂亚平 committed
46
            order by t.score desc
涂亚平 committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    </select>

    <select id="getPaperDetail" resultType="com.subsidy.vo.administer.GetPaperDetailVO">
        SELECT
            t2.title,
            t.result,
            t.answer,
            t2.right_answer,
            t2.items,
            t2.detail
        FROM
            exercise_done_history t
            LEFT JOIN exercise_dict t2 ON t.exercise_id = t2.id
        WHERE
            t.delete_date is null
            and t2.delete_date is null
            and t.done_id = #{doneId}
            AND t.member_id = #{memberId}
    </select>

    <select id="getDoneDetail" parameterType="long" resultType="com.subsidy.vo.exercise.GetDoneDetailVO">
        SELECT
            right_counts,
            total_counts,
            result,
            create_date
        FROM
            exercise_done_result t
            where t.delete_date is null
            and t.id = #{id}
    </select>

    <select id="getMaxScore" resultType="com.subsidy.vo.done.GetMaxScoreVO">
        SELECT
            t.paper_id,
            t2.paper_name,
            max( t.score ) AS score
        FROM
            exercise_done_result t
            left join paper_dict t2 on t.paper_id = t2.id
        WHERE
涂亚平 committed
88 89
            t.delete_date is null
            and t.member_id = #{memberId}
涂亚平 committed
90 91 92 93 94 95 96
            AND t.class_id = #{classId}
        GROUP BY
            t.class_id,
            t.paper_id,
            t.member_id
    </select>

97 98
    <select id="getMaxScorePaper" resultType="com.subsidy.model.ExerciseDoneResultDO">
        SELECT
涂亚平 committed
99 100 101 102
            t2.right_counts,
            t2.total_counts,
            t2.result,
            t2.score
103
        FROM
涂亚平 committed
104 105 106 107 108 109 110 111 112
            (
            SELECT
                max( t.score ) AS score
            FROM
                exercise_done_result t
            WHERE
                t.delete_date IS NULL
                AND t.paper_id = #{paperId}
                AND t.member_id = #{memberId}
涂亚平 committed
113
                and t.class_id = #{classId}
涂亚平 committed
114 115
            ) t1
            LEFT JOIN exercise_done_result t2 ON t1.score = t2.score
116
        WHERE
涂亚平 committed
117 118
            t2.paper_id = #{paperId}
            AND t2.member_id = #{memberId}
119 120 121 122
    </select>

    <select id="testScoreInfo" resultType="com.subsidy.vo.done.TestScoreInfoVO">
        SELECT
涂亚平 committed
123 124 125
            t1.paper_id,
            t1.score,
            t1.result,
涂亚平 committed
126 127 128
            t2.cnt,
            t1.startDate,
            t1.endDate
129
        FROM
涂亚平 committed
130 131 132 133 134 135 136
            (
            SELECT
                t.paper_id,
                t.class_id,
                t.member_id,
                t.score,
            IF
涂亚平 committed
137 138 139
                ( ( t.score )>= 60, '合格', '不合格' ) AS result,
                t.start_date startDate,
                t.create_date as endDate
涂亚平 committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
            FROM
                exercise_done_result t
                LEFT JOIN paper_dict t2 ON t.paper_id = t2.id
            WHERE
                t.delete_date IS NULL
                AND t.member_id = #{memberId}
                AND t.paper_id = #{paperId}
                AND t.class_id = #{classId}
            ORDER BY
                t.create_date DESC
                LIMIT 1
            ) t1
            LEFT JOIN (
            SELECT
                t2.paper_id,
                t2.class_id,
                t2.member_id,
                count( 1 ) AS cnt
            FROM
                exercise_done_result t2
            WHERE
                t2.delete_date IS NULL
                AND t2.member_id = #{memberId}
                AND t2.paper_id = #{paperId}
                AND t2.class_id = #{classId}
            ) t2 ON t1.paper_id = t2.paper_id
            AND t1.member_id = t2.member_id
            AND t1.class_id = t2.class_id
168 169 170 171
    </select>

    <select id="getClassTestPassRate" parameterType="long" resultType="integer">
        SELECT
涂亚平 committed
172
	        IFNULL( sum( t11.result ), 0 )
173 174 175 176
        FROM
            (
            SELECT
            IF
涂亚平 committed
177
                ( sum( cnt ) = sum( result ), 1, 0 ) AS result
178 179 180 181 182 183 184 185 186 187 188 189 190 191
            FROM
                (
                SELECT
                    t.paper_id,
                    t.member_id,
                    max( t.score ) AS score,
                    1 AS cnt,
                IF
                    ( max( t.score )>= 60, '1', '0' ) AS result
                FROM
                    exercise_done_result t
                    LEFT JOIN paper_dict t2 ON t.paper_id = t2.id
                WHERE
                    t.delete_date IS NULL
涂亚平 committed
192
                    AND t.class_id = #{classId}
193 194 195 196 197
                GROUP BY
                    t.class_id,
                    t.paper_id,
                    t.member_id
                ) t10
涂亚平 committed
198 199
            GROUP BY
            t10.member_id
200 201
            ) t11
    </select>
涂亚平 committed
202
</mapper>