⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attributehelper.java

📁 采用Eclispe开发平台
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            if (question_type.intValue() > 0)
            {
                sql.appendWhereCondition("q.QuestionType", "=", question_type);
            }

            if (exam_type.intValue() > 0)
            {
                sql.appendWhereCondition("q.ExamType", "=", exam_type);
            }

            if (question_content.length() > 0)
            {
                sql.appendWhereClause("q.Content LIKE '%" + question_content + "%'");
            }
        }
    }

    public static int setNumberOfSearchedQuestion(String attribute, DynaValidatorActionForm form, HttpSession session)
    {
        QuerySQLExecuter sql = new QuerySQLExecuter();

        sql.appendTableName("t_question", "q");

        sql.appendColumn("count(*) n");

        setSearchQuestionsCondition(form, sql);

        Object[] obj = sql.executeQuery();

        int rows = Integer.valueOf(((Hashtable) obj[0]).get("n").toString()).intValue();

        session.setAttribute(attribute, new Integer(rows));

        return rows;

    }

    public static void setCourseLogs(String attribute, Object course_id, HttpSession session)
    {

        QuerySQLExecuter sql = new QuerySQLExecuter();


        sql.setReturnClassName("t_course_history");
        sql.appendColumn("*");
        sql.appendTableName("t_course_history");
        sql.appendWhereCondition("CourseId", "=", course_id);

        Object[] courses = sql.executeQuery();

        session.setAttribute(attribute, courses);

    }

    public static int setPage(Object page_parameter, HttpSession session)
    {
        int page, old;

        try
        {
            page = Integer.valueOf(page_parameter.toString()).intValue();
        } catch (Exception e)
        {
            int total = Integer.valueOf(session.getAttribute("TotalPages").toString()).intValue();
            Object o = session.getAttribute("CurrentPage");
            if (o == null)
            {
                old = 1;
            } else
            {
                old = Integer.valueOf(o.toString()).intValue();
            }

            page = old;

            if (page_parameter != null)
            {
                if (page_parameter.equals("previous"))
                {
                    if (old > 1) page = old - 1;

                } else if (page_parameter.equals("next"))
                {
                    if (old < total) page = old + 1;
                } else if (page_parameter.equals("last"))
                {
                    page = total;
                } else
                {
                    page = 1;
                }
            }
        }

        session.setAttribute("CurrentPage", new Integer(page));
        return page;
    }

    public static Object[] setChoices(String attribute, Integer question_id, HttpSession session)
    {
        QuerySQLExecuter sql = new QuerySQLExecuter();

        sql.setReturnClassName("t_question_choice");
        sql.appendTableName("t_question_choice");

        sql.appendColumn("*");

        sql.appendWhereCondition("QuestionId", "=", question_id);
        sql.appendOrderByASC("ChoiceId");

        Object[] objs = sql.executeQuery();

        session.setAttribute(attribute, objs);

        return objs;
    }

    public static Object[] setPoints(String attribute, Integer question_id, HttpSession session)
    {
        QuerySQLExecuter sql = new QuerySQLExecuter();

        sql.setReturnClassName("t_question_point");
        sql.appendTableName("t_question_point");

        sql.appendColumn("*");

        sql.appendWhereCondition("QuestionId", "=", question_id);

        Object[] objs = sql.executeQuery();


        if (objs.length == 1 && ConstHelper.DefaultPoint.equals(((t_question_point) objs[0]).PointContent))
        {
            objs = new t_question_point[0];
        }

        session.setAttribute(attribute, objs);

        return objs;
    }

    public static t_question setQuestion(String attribute, Integer question_id, HttpSession session)
    {
        QuerySQLExecuter sql = new QuerySQLExecuter();

        sql.setReturnClassName("t_question");
        sql.appendTableName("t_question");

        sql.appendColumn("*");

        sql.appendWhereCondition("QuestionId", "=", question_id);

        Object[] objs = sql.executeQuery();

        if (objs.length > 0)
        {
            session.setAttribute(attribute, objs[0]);
        }

        return (t_question) objs[0];
    }

    public static void setAnswerSelection(String attribute, int number, HttpSession session)
    {
        ArrayList as = new ArrayList();

        for (int i = 0; i < number; i++)
        {
//            as.add(new LabelValueBean( String.valueOf ( (char)('A' + i)) , String.valueOf ( (char)('1' + i))));
            as.add(new LabelValueBean(String.valueOf(i + 1), String.valueOf(i + 1)));
        }

        session.setAttribute(attribute, as);

    }

    public static void setRightAnswer(String attribute, Object[] choices, HttpSession session)
    {
        for (int i = 0; i < choices.length; i++)
        {
            t_question_choice c = (t_question_choice) choices[i];

            if ("Y".equals(c.IsAnswer))
            {
                session.setAttribute(attribute, new Integer(i + 1));
                return;
            }
        }
    }

    public static Object[] setFiles(String attribute, Integer question_id, HttpSession session)
    {
        QuerySQLExecuter sql = new QuerySQLExecuter();

        sql.setReturnClassName("t_question_file");
        sql.appendTableName("t_question_file");

        sql.appendColumn("QuestionId");
        sql.appendColumn("FileId");
        sql.appendColumn("FileName");
        sql.appendColumn("FileType");
        sql.appendColumn("FileSize");

        sql.appendWhereCondition("QuestionId", "=", question_id);
//        sql.appendOrderByASC("ChoiceId");

        Object[] objs = sql.executeQuery();

        session.setAttribute(attribute, objs);

        return objs;
    }

    public static void setExamStat(Integer course_id, HttpSession session)
    {
        Object[] objs;
        Integer count;

        objs = UserSQLExecuter.executeQuery("select count(*) nCount from t_exam where CourseId=" + course_id);
        count = (Integer) ((Hashtable)objs[0]).get("nCount");
        session.setAttribute("TotalExams", count );

        objs = UserSQLExecuter.executeQuery("select count(*) nCount from t_exam where CourseId=" + course_id + " AND ExamType=1");
        count = (Integer) ((Hashtable)objs[0]).get("nCount");
        session.setAttribute("ExamExams", count );

        objs = UserSQLExecuter.executeQuery("select count(*) nCount from t_exam where CourseId=" + course_id + " AND ExamType=2");
        count = (Integer) ((Hashtable)objs[0]).get("nCount");
        session.setAttribute("HomeworkExams", count );

        objs = UserSQLExecuter.executeQuery("select count(*) nCount from t_exam where CourseId=" + course_id + " AND State=0");
        count = (Integer) ((Hashtable)objs[0]).get("nCount");
        session.setAttribute("CreatingExams", count );

        objs = UserSQLExecuter.executeQuery("select count(*) nCount from t_exam where CourseId=" + course_id + " AND State=1");
        count = (Integer) ((Hashtable)objs[0]).get("nCount");
        session.setAttribute("OpeningExams", count );

        objs = UserSQLExecuter.executeQuery("select count(*) nCount from t_exam where CourseId=" + course_id + " AND State=2");
        count = (Integer) ((Hashtable)objs[0]).get("nCount");
        session.setAttribute("ClosedExams", count );


    }
}

⌨️ 快捷键说明

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