@ -67,10 +67,11 @@ public class AssesmentService {
/ * *
/ * *
* 创建考核
* 创建考核
*
* @return
* @return
* /
* /
@Transactional
@Transactional
public HashMap < String , Object > addAssesment ( Assesment assesment , List < Integer > studentIds ) {
public HashMap < String , Object > addAssesment ( Assesment assesment , List < Integer > studentIds ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
//转换时间格式
//转换时间格式
@ -91,10 +92,10 @@ public class AssesmentService {
//得到考核id
//得到考核id
Integer assesmentId = assesment . getId ( ) ;
Integer assesmentId = assesment . getId ( ) ;
String name = assesment . getAssesmentName ( ) ;
String name = assesment . getAssesmentName ( ) ;
Integer number = mapper . getByAssesmentName ( name ) ;
Integer number = mapper . getByAssesmentName ( name ) ;
if ( number ! = null & & number > 0 ) {
if ( number ! = null & & number > 0 ) {
name + = ( number + 1 ) ;
name + = ( number + 1 ) ;
assesment . setAssesmentName ( name ) ;
assesment . setAssesmentName ( name ) ;
}
}
@ -143,14 +144,14 @@ public class AssesmentService {
* /
* /
public HashMap < String , Object > queryGetById ( Integer id ) {
public HashMap < String , Object > queryGetById ( Integer id ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < > ( ) ;
HashMap < String , Object > obj = new HashMap < > ( ) ;
try {
try {
//考核信息
//考核信息
Assesment assesment = mapper . queryGetById ( id ) ;
Assesment assesment = mapper . queryGetById ( id ) ;
//之前选中的学生
//之前选中的学生
List < Student > students = mapper . queryStudent ( id ) ;
List < Student > students = mapper . queryStudent ( id ) ;
obj . put ( "assesment" , assesment ) ;
obj . put ( "assesment" , assesment ) ;
obj . put ( "students" , students ) ;
obj . put ( "students" , students ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
@ -166,6 +167,7 @@ public class AssesmentService {
/ * *
/ * *
* 修改考核管理
* 修改考核管理
*
* @return
* @return
* /
* /
@Transactional
@Transactional
@ -215,10 +217,10 @@ public class AssesmentService {
Integer pointNumber = mapper . queryPointNumber ( assesment . getExperimentId ( ) ) ;
Integer pointNumber = mapper . queryPointNumber ( assesment . getExperimentId ( ) ) ;
assesment . setAssessmentNumber ( pointNumber ) ;
assesment . setAssessmentNumber ( pointNumber ) ;
String name = assesment . getAssesmentName ( ) ;
String name = assesment . getAssesmentName ( ) ;
Integer number = mapper . getByAssesmentName ( name ) ;
Integer number = mapper . getByAssesmentName ( name ) ;
if ( number ! = null & & number > 0 ) {
if ( number ! = null & & number > 0 ) {
name + = ( number + 1 ) ;
name + = ( number + 1 ) ;
assesment . setAssesmentName ( name ) ;
assesment . setAssesmentName ( name ) ;
}
}
@ -229,7 +231,7 @@ public class AssesmentService {
logger . error ( e . getMessage ( ) ) ;
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Update Failed" ) ;
resp . put ( "retvalue" , "Update Failed" ) ;
throw new RuntimeException ( ) ;
throw new RuntimeException ( ) ;
}
}
return resp ;
return resp ;
}
}
@ -267,6 +269,7 @@ public class AssesmentService {
/ * *
/ * *
* 修改考核状态
* 修改考核状态
*
* @return
* @return
* /
* /
public HashMap < String , Object > updateState ( Assesment assesment ) {
public HashMap < String , Object > updateState ( Assesment assesment ) {
@ -315,13 +318,14 @@ public class AssesmentService {
/ * *
/ * *
* 查询实验班级一级栏目
* 查询实验班级一级栏目
*
* @param staffId : 教师id
* @param staffId : 教师id
* @return
* @return
* /
* /
public HashMap < String , Object > queryCretionTime ( Integer staffId , Integer schoolId ) {
public HashMap < String , Object > queryCretionTime ( Integer staffId , Integer schoolId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
resp . put ( "retvalue" , mapper . queryCreationTime ( staffId , schoolId ) ) ;
resp . put ( "retvalue" , mapper . queryCreationTime ( staffId , schoolId ) ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
logger . error ( e . getMessage ( ) ) ;
@ -339,10 +343,10 @@ public class AssesmentService {
* @param cretionTime
* @param cretionTime
* @return
* @return
* /
* /
public HashMap < String , Object > queryCretionTime ( String cretionTime , Integer staffId , Integer schoolId ) {
public HashMap < String , Object > queryCretionTime ( String cretionTime , Integer staffId , Integer schoolId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
resp . put ( "retvalue" , mapper . queryExperimentalClass ( cretionTime , staffId , schoolId ) ) ;
resp . put ( "retvalue" , mapper . queryExperimentalClass ( cretionTime , staffId , schoolId ) ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
logger . error ( e . getMessage ( ) ) ;
@ -356,6 +360,7 @@ public class AssesmentService {
/ * *
/ * *
* 考核信息展示
* 考核信息展示
*
* @param assesmentId
* @param assesmentId
* @return
* @return
* /
* /
@ -382,12 +387,12 @@ public class AssesmentService {
* /
* /
public HashMap < String , Object > getByclass ( Integer assesmentId ) {
public HashMap < String , Object > getByclass ( Integer assesmentId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < String , Object > ( ) ;
try {
try {
List < ExperimentalClass > experimentalClasses = mapper . queryExperimental ( assesmentId ) ;
List < ExperimentalClass > experimentalClasses = mapper . queryExperimental ( assesmentId ) ;
List < SutdentClass > classes = mapper . queryClass ( assesmentId ) ;
List < SutdentClass > classes = mapper . queryClass ( assesmentId ) ;
obj . put ( "xperimentalClass" , experimentalClasses ) ;
obj . put ( "xperimentalClass" , experimentalClasses ) ;
obj . put ( "class" , classes ) ;
obj . put ( "class" , classes ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
@ -404,59 +409,63 @@ public class AssesmentService {
/ * *
/ * *
* 成绩概况
* 成绩概况
* /
* /
public HashMap < String , Object > queryScore ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
public HashMap < String , Object > queryScore ( Integer assesmentId , Integer experimentalClassId , Integer classId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
Score score = new Score ( ) ;
Score score ;
List < Student > students = null ;
int size = 0 ;
int size = 0 ;
try {
try {
List < Integer > scores = mapper . queryScore ( assesmentId , experimentalClassId , classId ) ;
if ( scores . size ( ) > 0 ) {
if ( experimentalClassId ! = null ) {
size = scores . size ( ) ;
students = mapper . getByExperimentalClassId ( experimentalClassId ) ;
//最低分
} else if ( classId ! = null ) {
score . setMin ( scores . get ( 0 ) ) ;
students = mapper . getByclassId ( classId ) ;
//最高分
}
score . setMax ( scores . get ( size - 1 ) ) ;
//判分点数量
//考核人数
Integer pointNumber = mapper . getAssesmentNumber ( assesmentId ) ;
score . setPeopleSize ( size ) ;
if ( StringUtils . isEmpty ( pointNumber ) ) {
//中位数
pointNumber = 0 ;
double median = 0 . 0 ;
}
if ( size % 2 = = 1 ) {
if ( ! students . isEmpty ( ) & & students . size ( ) > 0 ) {
median = scores . get ( ( size - 1 ) / 2 ) ;
List < Integer > scores = mapper . queryScore ( assesmentId , students ) ;
score = new Score ( ) ;
if ( ! scores . isEmpty ( ) & & scores . size ( ) > 0 ) {
size = scores . size ( ) ;
score . setMin ( scores . get ( 0 ) ) ; //最低分
score . setMax ( scores . get ( size - 1 ) ) ; //最高分
score . setPeopleSize ( size ) ; //考核人数
double median = 0 . 0 ; //中位数
if ( size % 2 = = 1 ) {
median = scores . get ( ( size - 1 ) / 2 ) ;
} else {
median = ( scores . get ( ( size / 2 - 1 ) ) + scores . get ( size / 2 ) + 0 . 0 ) / 2 ;
}
score . setMedian ( median ) ;
int avg = 0 ; //平均分
for ( int i = 0 ; i < scores . size ( ) ; i + + ) {
avg + = scores . get ( i ) ;
}
score . setAvg ( avg * 1 . 0 / size ) ;
} else {
} else {
median = ( scores . get ( ( size / 2 - 1 ) ) + scores . get ( size / 2 ) + 0 . 0 ) / 2 ;
score . setMin ( 0 ) ; //最低分
}
score . setMax ( 0 ) ; //最高分
score . setMedian ( median ) ;
score . setPeopleSize ( size ) ; //考核人数
//平均分
score . setMedian ( 0 ) ; //中位数
int avg = 0 ;
score . setAvg ( 0 ) ; //平均分
for ( int i = 0 ; i < scores . size ( ) ; i + + ) {
avg + = scores . get ( i ) ;
}
}
score . setAvg ( avg * 1 . 0 / size ) ;
} else {
//最低分
score . setMin ( 0 ) ;
//最高分
score . setMax ( 0 ) ;
//考核人数
score . setPeopleSize ( size ) ;
//中位数
score . setMedian ( 0 ) ;
//平均分
score . setAvg ( 0 ) ;
}
Integer pointNumber = mapper . getAssesmentNumber ( assesmentId ) ;
if ( StringUtils . isEmpty ( pointNumber ) ) {
score . setPointNumber ( 0 ) ;
} else {
score . setPointNumber ( pointNumber ) ;
score . setPointNumber ( pointNumber ) ;
//错误率
//错误率
Integer classError = mapper . queryRight ( assesmentId , experimentalClassId , classId ) ;
Integer classError = mapper . queryRight ( assesmentId , experimentalClassId , classId ) ;
if ( StringUtils . isEmpty ( classError ) | | size = = 0 ) {
if ( StringUtils . isEmpty ( classError ) | | size = = 0 ) {
score . setError ( 0 ) ;
score . setError ( 0 ) ;
} else {
} else {
double error = ( classError * 1 . 0 / ( size * pointNumber ) ) * 100 ;
double error = ( classError * 1 . 0 / ( size * pointNumber ) ) * 100 ;
score . setError ( error ) ;
score . setError ( error ) ;
}
}
} else {
score = new Score ( 0 . 0 , 0 . 0 , 0 , 0 , 0 , pointNumber , 0 . 0 ) ;
}
}
resp . put ( "retvalue" , score ) ;
resp . put ( "retvalue" , score ) ;
@ -607,6 +616,7 @@ public class AssesmentService {
/ * *
/ * *
* 开启考核
* 开启考核
*
* @param courseId
* @param courseId
* @return
* @return
* /
* /