eganwu 1 rok temu
rodzic
commit
516836b872

+ 5 - 0
src/custom/restcontroller/R.java

@@ -5826,6 +5826,11 @@ public class R {
         }
     }
 
+    public static class ID20240326133302 {
+        public static class v1 {
+        }
+    }
+
 }
 
 

+ 58 - 2
src/custom/restcontroller/webmanage/saletool/courseware/coursewaretesthead.java

@@ -149,6 +149,8 @@ public class coursewaretesthead extends Controller {
         UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, sat_courseware_testhead);
         updateSQL.setSiteid(siteid);
         updateSQL.setValue("status", status == 0 ? "新建" : "发布");
+        updateSQL.setValue("sendby", username);
+        updateSQL.setValue("senddate", getDateTime_Str());
         updateSQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadids.toArray());
         updateSQL.update();
 
@@ -560,10 +562,64 @@ public class coursewaretesthead extends Controller {
         querySQL2.setSiteid(siteid)
                 .setWhere("sat_courseware_testid", detailRow.getLong("sat_courseware_testid"));
 
-        Rows rows2=querySQL2.query();
+        Rows rows2 = querySQL2.query();
 
-        detailRow.put("testquestions",rows2);
+        detailRow.put("testquestions", rows2);
         return getSucReturnObject().setData(detailRow).toString();
     }
 
+    @API(title = "查询我的考试列表", apiversion = R.ID20240326133302.v1.class)
+    public String queryUserTestList() throws YosException {
+
+
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.title like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
+                where.append(" and(");
+                where.append("t2.status='").append(whereObject.getString("status")).append("' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("sat_courseware_classids") && !"".equals(whereObject.getString("sat_courseware_classids"))) {
+                JSONArray sat_courseware_classids = whereObject.getJSONArray("sat_courseware_classids");
+                if (sat_courseware_classids.size() > 0) {
+                    where.append(" and (1=2");
+                    for (Object obj : sat_courseware_classids) {
+                        JSONArray array = (JSONArray) obj;
+                        for (Object obj2 : array) {
+                            where.append(" or (");
+                            where.append("JSON_CONTAINS(t1.sat_courseware_classids,'" + obj2 + "')");
+                            where.append(")");
+                        }
+                    }
+                    where.append(")");
+                }
+            }
+        }
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_courseware_testhead"
+                        , "sat_courseware_testheadid", "title", "num")
+                .setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.inner, "sat_courseware_test", "t2", "t2.sat_courseware_testheadid=t1.sat_courseware_testheadid and t2.siteid=t1.siteid"
+                , "sat_courseware_testid", "status", "score", "answercount");
+        querySQL.setWhere(where.toString());
+        if (!userInfo.isSysAdministrator()) {
+            querySQL.setWhere("t2.userid", userid);
+        }
+
+        querySQL.setSiteid(siteid);
+        querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+
+        for (Row row : rows) {
+            row.put("answerinfo", row.getString("answercount") + "/" + row.getString("num"));
+            row.putIfAbsent("score", 0.0);
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
 }