数据采集系统开发流程-5

参与调查
-----------------
1.导航栏-->参与调查
2.EngageSurveyAction.findAllAvailableSurveys()方法
    public String findAllAvailableSurveys(){
        this.surveys = surveyService.findAllAvailableSurveys();
            public List<Survey> findAllAvailableSurveys(){
                String hql = "from Survey s where s.closed = ?" ;
                return surveyDao.findEntityByHQL(hql,false);
            }
        return "engageSurveyListPage" ;
    }
3.struts.xml
    <!-- EngageSurveyAction -->
    <action name="EngageSurveyAction_*" class="engageSurveyAction" method="{1}">
        <result name="engageSurveyListPage">/engageSurveyList.jsp</result>
    </action>
4.跳转到/.jsp

/**
 * 获得图片的url地址
 */
public String getImageUrl(String path){
    if(ValidateUtil.isValid(path)){
        String absPath = sc.getRealPath(path);
        File f = new File(absPath);
        if(f.exists()){
            // /lsn_surveypark001/upload/xxx.jpg
            return sc.getContextPath() + path ;
        }
    }
    return sc.getContextPath() + "/question.bmp"  ;
}

点击调查进行参与
-------------------------
1.参与调查视图页面-->点击调查
2.EngageSurveyAction.entry()方法
    public String entry(){
        sid
        //查询调查首页
        this.currPage = surveyService.getFirstPage(sid);
            public Page getFirstPage(Integer sid){
                String hql = "from Page p where p.survey.id = ? order by p.orderno asc";
                List<Page> list = pageDao.findEntityByHQL(sid);
                Page p = list.get(0);
                p.getQuestions().size();//初始化问题集合
                p.getSurvey().getTitle();//初始化调查对象
                return p ;
            }
        //查询当前调查存放到session中.
        sessionMap.put("current_survey",currPage.getSurvey());
        return "engageSurveyPage" ;
    }
3.struts.xml
4.跳转到/engageSurvey.jsp
    [类似于designSurvey.jsp]

最大页序和最小页序的处理方式
----------------------------------
1.
    class Survey ...{
        ...
        private float minOrderno ;
        private float maxOrderno ;
        //get/set
    }

    Survey.hbm.xml
    <property name="minOrderno" formula="(select min(p.orderno) from pages p where p.surveyid = id)" />
    <property name="maxOrderno" formula="(select min(p.orderno) from pages p where p.surveyid = id)" />


处理参与调查
---------------------
1.参与调查页面-->上一步/下一步/完成/退出
2.EngageSurveyAction.doEngageSurvey()
    public String doEngageSurvey(){
        String submitName = getSubmitName();
        if(上一步?){
            mergeParamsIntoSession();
            this.currPage = surveyService.getPrePage(currPid);
            return "engageSurveyPage" ;
        }
        else if(下一步?){
            mergeParamsIntoSession();
            this.currPage = surveyService.getNextPage(currPid);
            return "engageSurveyPage" ;
        }

        else if(完成?){
            mergeParamsIntoSession();
            //TODO答案入库
            clearSessionData();
            return "engageSurveyAction" ;
        }
        else if(退出?){
            clearSessionData();
            return "engageSurveyAction" ;
        }
    }


    public String entry(){
        ....
        //将存放所有参数的大map -->session中(用户保存答案和回显).
        sessionMap.put(ALL_PARAMS_MAP,new HashMap<Integer,Map<String,String[]>>());
    }

删除最后一个页面时,会出现无法将null赋值给基本类型的属性 for minOrderno来说.
-----------------------
1.每个调查至少有一个页面,删除时需要做判定.
2.
3.

//问题统计模型
class QuestionStatisticsModel{
    private Question q ;
    private int count ;
    private List<OptionStatisticsModel> osms = ...
}

//选项统计模型
class OptionStatisticsModel{
    private int optionIndex ;
    private String optionLabel ;
    private int count ;

    private int matrixRowIndex ;
    private String matrixRowLabel ;
    ...
}

统计回答问题的总人数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值