|
@@ -69,13 +69,6 @@ type HandleLatestExamLog struct {
|
|
|
|
|
|
// 导出学生最后一场考核成绩
|
|
|
func LatestExamExportExcel(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- isAdmin, err := IsAdmin(c, apictx)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- if !isAdmin {
|
|
|
- return nil, errors.New("没有权限")
|
|
|
- }
|
|
|
db := c.Param("scope")
|
|
|
if len(db) == 0 {
|
|
|
return nil, errors.New("scope不能为空")
|
|
@@ -85,6 +78,7 @@ func LatestExamExportExcel(c *gin.Context, apictx *ApiSession) (interface{}, err
|
|
|
flagIndex := -1
|
|
|
|
|
|
examTypes := []string{"理论", "实操"}
|
|
|
+ // examTypes := []string{"实操"}
|
|
|
|
|
|
for _, examType := range examTypes {
|
|
|
|
|
@@ -114,7 +108,7 @@ func LatestExamExportExcel(c *gin.Context, apictx *ApiSession) (interface{}, err
|
|
|
c.Header("Content-Disposition", "attachment; filename="+fileName)
|
|
|
c.Header("Content-Transfer-Encoding", "binary")
|
|
|
|
|
|
- err = f.Write(c.Writer)
|
|
|
+ err := f.Write(c.Writer)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -128,7 +122,6 @@ func getTotalLearnTime(apictx *ApiSession, db string, uid string) (int32, error)
|
|
|
// 定义聚合管道
|
|
|
pipeline := mongo.Pipeline{
|
|
|
{{Key: "$match", Value: bson.D{{Key: "uid", Value: uid}}}},
|
|
|
- {{Key: "$sort", Value: bson.D{{Key: "createTime", Value: -1}, {Key: "uid", Value: -1}}}},
|
|
|
{{Key: "$group", Value: bson.D{
|
|
|
{Key: "_id", Value: "$uid"},
|
|
|
{Key: "totalLearnTime", Value: bson.D{{Key: "$sum", Value: "$learnTime"}}},
|
|
@@ -148,7 +141,6 @@ func getTotalLearnTime(apictx *ApiSession, db string, uid string) (int32, error)
|
|
|
log.Error(err)
|
|
|
return 0, err
|
|
|
}
|
|
|
- fmt.Println(results)
|
|
|
if len(results) > 0 {
|
|
|
return results[0]["totalLearnTime"].(int32), err
|
|
|
}
|
|
@@ -161,11 +153,12 @@ func getHandleLatestExamLog(apictx *ApiSession, db string, examType string) ([]*
|
|
|
|
|
|
pipeline := mongo.Pipeline{
|
|
|
{{Key: "$match", Value: bson.D{{Key: "type", Value: examType}}}},
|
|
|
- {{Key: "$sort", Value: bson.D{{Key: "uid", Value: -1}}}},
|
|
|
+ {{Key: "$sort", Value: bson.D{{Key: "createTime", Value: -1}}}},
|
|
|
{{Key: "$group", Value: bson.D{
|
|
|
{Key: "_id", Value: "$uid"},
|
|
|
{Key: "latestExeamLog", Value: bson.D{{Key: "$first", Value: "$$ROOT"}}},
|
|
|
}}},
|
|
|
+ {{Key: "$sort", Value: bson.D{{Key: "_id", Value: -1}}}},
|
|
|
}
|
|
|
|
|
|
// 执行聚合管道
|