package com.ssj.dao.sys.opentest;

import com.ssj.bean.sys.opentest.OpenTestModuleResult;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Mount Liu
 * @date 2020/2/11
 */
@Repository
public interface OpenTestModuleResultDao extends JpaRepository<OpenTestModuleResult, String> {

    List<OpenTestModuleResult> findByResultIdOrderByModuleSort(String resultId);

    @Query(nativeQuery = true, value = "select ROUND(avg(accuracy_rate),2) from tb_test_module_result where name=?1 and subject=?2 and grade=?3 and version=?4 and is_delete=0")
    Double findAvgAccuracyRate(String name, String subject, String grade, String version);

    @Query(nativeQuery = true, value = "select ROUND(avg(accuracy_rate),2) from tb_test_module_result where name=?1 and subject=?2 and grade=?3 and is_delete=0")
    Double findAvgAccuracyRate(String name, String subject, String grade);
}
