examaction.java

来自「培训考试系统代码」· Java 代码 · 共 1,685 行 · 第 1/5 页

JAVA
1,685
字号
               req.setAttribute("EXAM-CLASS",rs2);
               req.setAttribute("EXAM-PAPEROFCLASS",rs3);
           }
           else
           {
               aplcoms.preparedQuery("");
               aplcoms.setString(1 ,examId);
               rs1 = aplcoms.csCommonQuery("SQL_Agt_ExamQueryDetail" ,"1" ,"-1").getResultSet();
               rs1 = new ResUtil(rs1);

               //获取参加的工号
               aplcoms.preparedQuery("");
               aplcoms.setString(1 ,examId);
               rs2 = aplcoms.csCommonQuery("SQL_Agt_ExamPartStaffNo" ,"1" ,"-1").getResultSet();

               //获取参加的组号
               aplcoms.preparedQuery("");
               aplcoms.setString(1 ,examId);
               rs3 = aplcoms.csCommonQuery("SQL_Agt_ExamPartGroup" ,"1" ,"-1").getResultSet();
               req.setAttribute("EXAM-PARTSTAFFNO",rs2);
               req.setAttribute("EXAM-PARTGROUP",rs3);
           }


           //把参数值传到页面去
           if(rs1 == null)
           {
               req.setAttribute("errorId",ErrorCode.EXAM_QUERY_ERROR);
               return (mapping.findForward("error"));
           }
           req.setAttribute("EXAM-DETAIL",rs1);

           if(3 == ((ExamForm)form).getScope() && "exammodify".equalsIgnoreCase(directName))
           {
              return (mapping.findForward("exammodifybyclass"));
           }

           //定向
           return (mapping.findForward(directName));
       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }


    /**
     * 获取考试的结果信息
     */
    private ActionForward getStatInfo(ActionMapping mapping,
           ActionForm form, HttpServletRequest req,
           HttpServletResponse res)
    {
       //从ExamForm中获取考试的ID号,一维数组的第一个
       String[] examIds = ((ExamForm)form).getExamIds();
       String examId = examIds[0];

       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //获取考试的统计信息
           //总参加人数
           //总分数
           //及格分数

           //最高分数
           //最低分数

           //有分数的总人数
           //及格人数
           //不及格人数
           //及格率

           //未被评阅的答卷数

           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

           //根据试卷ID号,从数据库中获取试卷的详细信息
           aplcoms.preparedSP();
           aplcoms.setString(1 ,examId);
           SysDataSet ds1 = aplcoms.csCommonSP("P_Agt_ExamGetStatInfo");
           SysRecord  rc1 = ds1.getParamSet() ;

           //把统计值传到页面去
           req.setAttribute("staffCount",rc1.getString(0));
           req.setAttribute("totalScore",rc1.getString(1));
           req.setAttribute("passScore",rc1.getString(2));
           req.setAttribute("maxScore",rc1.getString(3));
           req.setAttribute("minScore",rc1.getString(4));
           req.setAttribute("haveScoreCount",rc1.getString(5));
           req.setAttribute("passCount",rc1.getString(6));
           req.setAttribute("noPassCount",rc1.getString(7));
           req.setAttribute("noScoreCount",rc1.getString(8));
           req.setAttribute("examName",rc1.getString(9));
           //定向
           return (mapping.findForward("examstatinfo"));
       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }

   /**
     * 查询考试成绩操作
     */
    private ActionForward queryScore(ActionMapping mapping,
           ActionForm form, HttpServletRequest req,
           HttpServletResponse res)
    {

       //从ExamForm中获取查询条件;
       String titleTerm = ((ExamForm)form).getTitleTerm();
       String staffNoTerm = req.getParameter("staffNoTerm");
       String groupNoTerm = req.getParameter("groupNoTerm");
       String startTimeTerm = ((ExamForm)form).getStartTimeTerm();
       String endTimeTerm = ((ExamForm)form).getEndTimeTerm();

       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

            //根据查询条件,
            aplcoms.preparedSP();
            aplcoms.setString(1 ,titleTerm);
            aplcoms.setString(2 ,staffNoTerm);
            aplcoms.setString(3 ,groupNoTerm);
            aplcoms.setString(4 ,startTimeTerm);
            aplcoms.setString(5 ,endTimeTerm);

            SysResultSet rs1 = aplcoms.csCommonSP("P_Agt_ExamScoreQuery").getResultSet();
            rs1.next();

      //String sql_e="SELECT DISTINCT A.ExamID,A.Title,to_char(B.EXAMTIME,'yyyy-mm-dd hh24:mi'),EXAMSCORE,B.STAFFNO,B.IsPass,B.PaperId,B.RecordId,c.staffname,d.organame from T_AGT_EXAM A,T_AGT_EXAMRECORD B,t_pub_staff c,t_pub_orga d where A.ExamID=B.examId and B.STATUS=1 and B.staffno=c.staffno and c.orgaid=d.orgaid";
            aplcoms.preparedQuery(rs1.getString(1));
            //aplcoms.preparedQuery(rs1.getString(1));
            SysResultSet rs2  = aplcoms.csCommonQuery("SELFSQL","1","-1").getResultSet();
            rs2.sort(0,true);

            //把结果集存放到session中
            req.getSession().setAttribute("SCORE-QUERY-RESULTSET",rs2);


            //根据查询条件,进行统计
            aplcoms.preparedSP();
            aplcoms.setString(1 ,titleTerm);
            aplcoms.setString(2 ,staffNoTerm);
            aplcoms.setString(3 ,groupNoTerm);
            aplcoms.setString(4 ,startTimeTerm);
            aplcoms.setString(5 ,endTimeTerm);
            SysResultSet rs3 = aplcoms.csCommonSP("P_Agt_ExamScoreStat").getResultSet();
            rs3.next();

            aplcoms.preparedQuery(rs3.getString(1));
            SysResultSet rs4  = aplcoms.csCommonQuery("SELFSQL","1","-1").getResultSet();
            rs4.next();
            //把查询条件传送到页面
            //req.setAttribute(参数名称,参数值);
            int maxScore = 0;
            int minScore = 0;

            if(rs4.getString(0) != null)
            {
                maxScore = rs4.getInt(0);
            }
            if(rs4.getString(1) != null)
            {
                minScore = rs4.getInt(1);
            }

            req.getSession().setAttribute("maxScore",String.valueOf(maxScore));
            req.getSession().setAttribute("minScore",String.valueOf(minScore));

            int aveScore = 0;
            if( rs4.getInt(3) != 0)
            {
               aveScore = rs4.getInt(2)/ rs4.getInt(3);
            }
            req.getSession().setAttribute("aveScore",String.valueOf(aveScore));
            req.getSession().setAttribute("partCount",rs4.getString(4));

            //定向到列表显示页面
            return (mapping.findForward("scorelist"));

       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }

   /**
     * 获取查询条件
     */
    private ActionForward getScoreCondition(ActionMapping mapping,
           ActionForm form, HttpServletRequest req,
           HttpServletResponse res)
    {
       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

           //查询
           aplcoms.preparedQuery("");
           SysResultSet rs1 = aplcoms.csCommonQuery("SQL_Agt_GetGroup" ,"1" ,"-1").getResultSet();

           //把结果集存放到session中
           req.setAttribute("GET-GROUP-RESULTSET",rs1);

           //查询
           aplcoms.preparedQuery("");
           SysResultSet rs2 = aplcoms.csCommonQuery("SQL_Agt_GetExam" ,"1" ,"-1").getResultSet();

           //把结果集存放到session中
           req.setAttribute("GET-EXAM-RESULTSET",rs2);

           //定向
           return (mapping.findForward("examscoreinput"));
       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }

    /**
      * 按组别进行成绩汇总
      *  time:2004-05-28
      *  @author huangyuyuan
      *
      */
     private ActionForward getScoreAnalyse(ActionMapping mapping,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?