@ -75,10 +75,17 @@ public class ExamService {
}
}
public List < Map < String , Object > > questions ( JwtUser teacher , String type , String taskKey , String keyword ) {
public List < Map < String , Object > > questions ( JwtUser teacher , String type , String taskKey , String keyword ) {
return questions ( teacher , type , taskKey , keyword , null ) ;
}
public List < Map < String , Object > > questions ( JwtUser teacher , String type , String taskKey , String keyword , String scope ) {
requireTeacher ( teacher ) ;
requireTeacher ( teacher ) ;
StringBuilder sql = new StringBuilder ( "select q.*,t.project_name,t.task_name from exam_question q left join training_task t on t.task_key=q.task_key where (q.source_type='PLATFORM' or (q.source_type='TEACHER' and q.teacher_id=?))" ) ;
// scope=school 供"添加试题"使用:本校题库全部题目(平台题+本校教师题);
// 默认只看平台题和自己出的题,题库管理页维持本人范围。
boolean schoolWide = "school" . equalsIgnoreCase ( scope ) & & teacher . getSchoolId ( ) ! = null ;
StringBuilder sql = new StringBuilder ( "select q.*,t.project_name,t.task_name from exam_question q left join training_task t on t.task_key=q.task_key where (q.source_type='PLATFORM' or (q.source_type='TEACHER' and " + ( schoolWide ? "q.school_id=?" : "q.teacher_id=?" ) + "))" ) ;
List < Object > args = new ArrayList < > ( ) ;
List < Object > args = new ArrayList < > ( ) ;
args . add ( teacher . getUserId ( ) ) ;
args . add ( schoolWide ? teacher . getSchoolId ( ) : teacher. getUserId ( ) ) ;
if ( StringUtils . isNotBlank ( type ) ) { validateType ( type ) ; sql . append ( " and q.question_type=?" ) ; args . add ( type ) ; }
if ( StringUtils . isNotBlank ( type ) ) { validateType ( type ) ; sql . append ( " and q.question_type=?" ) ; args . add ( type ) ; }
if ( StringUtils . isNotBlank ( taskKey ) ) { sql . append ( " and q.task_key=?" ) ; args . add ( taskKey ) ; }
if ( StringUtils . isNotBlank ( taskKey ) ) { sql . append ( " and q.task_key=?" ) ; args . add ( taskKey ) ; }
if ( StringUtils . isNotBlank ( keyword ) ) { sql . append ( " and q.stem like ?" ) ; args . add ( "%" + keyword . trim ( ) + "%" ) ; }
if ( StringUtils . isNotBlank ( keyword ) ) { sql . append ( " and q.stem like ?" ) ; args . add ( "%" + keyword . trim ( ) + "%" ) ; }