正在显示
5 个修改的文件
包含
41 行增加
和
17 行删除
此 diff 太大无法显示。
| @@ -32,7 +32,7 @@ import QuestionApe from 'apes/QuestionApe'; | @@ -32,7 +32,7 @@ import QuestionApe from 'apes/QuestionApe'; | ||
| 32 | import UTF8 from 'utf-8'; | 32 | import UTF8 from 'utf-8'; |
| 33 | 33 | ||
| 34 | let loger = Loger.getLoger('McuClient'); | 34 | let loger = Loger.getLoger('McuClient'); |
| 35 | -let _sdkInfo = {"version": "v1.31.11.20170612", "author": "www.3mang.com"}; | 35 | +let _sdkInfo = {"version": "v1.31.8.20170613", "author": "www.3mang.com"}; |
| 36 | 36 | ||
| 37 | //APE | 37 | //APE |
| 38 | let _sass; | 38 | let _sass; |
| @@ -138,6 +138,7 @@ export default class MessageEntrance extends Emiter { | @@ -138,6 +138,7 @@ export default class MessageEntrance extends Emiter { | ||
| 138 | _doc_ape.on(DocApe.DOC_JOIN_CHANNEL_SUCCESS, this.docJoinChannelSuccess.bind(this)); | 138 | _doc_ape.on(DocApe.DOC_JOIN_CHANNEL_SUCCESS, this.docJoinChannelSuccess.bind(this)); |
| 139 | 139 | ||
| 140 | _questionApe=new QuestionApe(); | 140 | _questionApe=new QuestionApe(); |
| 141 | + _questionApe.on('*', (type, data) => this._emit(type, data)); | ||
| 141 | 142 | ||
| 142 | //公开外部调用的方法 | 143 | //公开外部调用的方法 |
| 143 | //class | 144 | //class |
| @@ -535,10 +535,10 @@ class Sass extends Emiter { | @@ -535,10 +535,10 @@ class Sass extends Emiter { | ||
| 535 | let question={}; | 535 | let question={}; |
| 536 | question.questionId=ret.id; | 536 | question.questionId=ret.id; |
| 537 | question.type=type; | 537 | question.type=type; |
| 538 | - question.content=content; | 538 | + question.content=_param.content||[]; |
| 539 | question.timeLimit=timeLimit; | 539 | question.timeLimit=timeLimit; |
| 540 | - question.correct=correct; | ||
| 541 | - question.options=options; | 540 | + question.correct=_param.correct||[]; |
| 541 | + question.options=_param.options||[]; | ||
| 542 | loger.log('创建答题数据->完成->',question); | 542 | loger.log('创建答题数据->完成->',question); |
| 543 | this._emit(Sass.SASS_CREAT_QUESTION_SUCCESS, question); | 543 | this._emit(Sass.SASS_CREAT_QUESTION_SUCCESS, question); |
| 544 | } else { | 544 | } else { |
| @@ -97,6 +97,10 @@ class QuestionApe extends Ape { | @@ -97,6 +97,10 @@ class QuestionApe extends Ape { | ||
| 97 | 97 | ||
| 98 | //删除 | 98 | //删除 |
| 99 | tableDelete(_param) { | 99 | tableDelete(_param) { |
| 100 | + if(!_param){ | ||
| 101 | + loger.warn('答题卡->删除数据失败->参数错误',_param); | ||
| 102 | + return; | ||
| 103 | + } | ||
| 100 | let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu']; | 104 | let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu']; |
| 101 | tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;// | 105 | tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;// |
| 102 | tableDeleteItemPdu.itemIdx = parseInt(_param.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样 | 106 | tableDeleteItemPdu.itemIdx = parseInt(_param.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样 |
| @@ -114,7 +118,7 @@ class QuestionApe extends Ape { | @@ -114,7 +118,7 @@ class QuestionApe extends Ape { | ||
| 114 | let adapterPdu = new pdu['RCAdapterPdu']; | 118 | let adapterPdu = new pdu['RCAdapterPdu']; |
| 115 | adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | 119 | adapterPdu.type = pdu.RCPDU_REG_ADAPTER; |
| 116 | adapterPdu.item.push(adapterItemPdu); | 120 | adapterPdu.item.push(adapterItemPdu); |
| 117 | - loger.log("答题卡删除数据->" + tableDeleteItemPdu.itemIdx); | 121 | + loger.log("发送答题卡删除数据->" + tableDeleteItemPdu.itemIdx); |
| 118 | this.sendUniform(adapterPdu, true); | 122 | this.sendUniform(adapterPdu, true); |
| 119 | } | 123 | } |
| 120 | 124 | ||
| @@ -135,11 +139,22 @@ class QuestionApe extends Ape { | @@ -135,11 +139,22 @@ class QuestionApe extends Ape { | ||
| 135 | loger.log("更新答题数据"); | 139 | loger.log("更新答题数据"); |
| 136 | if(GlobalConfig.isHost){ | 140 | if(GlobalConfig.isHost){ |
| 137 | //老师,只统计数据,不答题 | 141 | //老师,只统计数据,不答题 |
| 142 | + //先判断时间是否超时 | ||
| 143 | + let timeDistance=EngineUtils.creatTimestamp()-model.timestamp; | ||
| 144 | + loger.log("答题卡显示倒计时->timeDistance:"+timeDistance); | ||
| 145 | + timeDistance=model.timeLimit-timeDistance; | ||
| 146 | + if(timeDistance<=0){ | ||
| 147 | + //答题卡时间到,需要停止 | ||
| 148 | + loger.log("答题卡时间到->需要停止"); | ||
| 149 | + this.stopQuestion(model); | ||
| 150 | + }else { | ||
| 138 | this.getQuestionResult(model); | 151 | this.getQuestionResult(model); |
| 152 | + } | ||
| 153 | + | ||
| 139 | }else if(GlobalConfig.isNormal) { | 154 | }else if(GlobalConfig.isNormal) { |
| 140 | //学生->如果自己已经提交过答案就不需要再显示 | 155 | //学生->如果自己已经提交过答案就不需要再显示 |
| 141 | if(model.totalUserList.indexOf(GlobalConfig.userId)>=0){ | 156 | if(model.totalUserList.indexOf(GlobalConfig.userId)>=0){ |
| 142 | - loger.log("已经提交过答案->userId:"+GlobalConfig.userId); | 157 | + loger.log("已经提交过答案-不需要显示答题卡->userId:"+GlobalConfig.userId); |
| 143 | }else { | 158 | }else { |
| 144 | //显示答题卡数据 | 159 | //显示答题卡数据 |
| 145 | this._emit(MessageTypes.START_ANSWER_QUESTION,model); | 160 | this._emit(MessageTypes.START_ANSWER_QUESTION,model); |
| @@ -175,7 +190,7 @@ class QuestionApe extends Ape { | @@ -175,7 +190,7 @@ class QuestionApe extends Ape { | ||
| 175 | case 2: | 190 | case 2: |
| 176 | case 3: | 191 | case 3: |
| 177 | //停止答题 | 192 | //停止答题 |
| 178 | - loger.log("停止答题"); | 193 | + loger.log("停止答题->",itemDataInfo); |
| 179 | this._emit(MessageTypes.STOP_ANSWER_QUESTION,itemDataInfo); | 194 | this._emit(MessageTypes.STOP_ANSWER_QUESTION,itemDataInfo); |
| 180 | break; | 195 | break; |
| 181 | case 4: | 196 | case 4: |
| @@ -218,10 +233,10 @@ class QuestionApe extends Ape { | @@ -218,10 +233,10 @@ class QuestionApe extends Ape { | ||
| 218 | modelPdu.questionId= parseInt(_param.questionId)||0; | 233 | modelPdu.questionId= parseInt(_param.questionId)||0; |
| 219 | modelPdu.timeLimit= parseInt(_param.timeLimit)||1;//有效时间 | 234 | modelPdu.timeLimit= parseInt(_param.timeLimit)||1;//有效时间 |
| 220 | modelPdu.timestamp= parseInt(_param.timestamp)||EngineUtils.creatTimestamp();//创建的时间 | 235 | modelPdu.timestamp= parseInt(_param.timestamp)||EngineUtils.creatTimestamp();//创建的时间 |
| 221 | - modelPdu.content= _param.content||"";//题干 | ||
| 222 | - modelPdu.options= _param.options||"";//选项列表 | ||
| 223 | - modelPdu.answer= _param.answer||"";//用户选择的选项索引 | ||
| 224 | - modelPdu.correct= _param.correct||"";//正确答案索引 | 236 | + modelPdu.content= _param.content||[];//题干 |
| 237 | + modelPdu.options= _param.options||[];//选项列表 | ||
| 238 | + modelPdu.answer= _param.answer||[];//用户选择的选项索引 | ||
| 239 | + modelPdu.correct= _param.correct||[];//正确答案索引 | ||
| 225 | modelPdu.totalUserList=_param.totalUserList||[];//参加的人员userId列表 | 240 | modelPdu.totalUserList=_param.totalUserList||[];//参加的人员userId列表 |
| 226 | loger.log("答题卡->packPdu",modelPdu); | 241 | loger.log("答题卡->packPdu",modelPdu); |
| 227 | return modelPdu; | 242 | return modelPdu; |
| @@ -294,7 +309,13 @@ class QuestionApe extends Ape { | @@ -294,7 +309,13 @@ class QuestionApe extends Ape { | ||
| 294 | loger.warn("保存答题答案->参数错误",_param); | 309 | loger.warn("保存答题答案->参数错误",_param); |
| 295 | return; | 310 | return; |
| 296 | } | 311 | } |
| 297 | - | 312 | + //检查是否已经提交过答案 |
| 313 | + let questionItem=this.questionList[_param.itemIdx]; | ||
| 314 | + if(questionItem){ | ||
| 315 | + if(questionItem.totalUserList.indexOf(GlobalConfig.userId)>=0){ | ||
| 316 | + loger.warn("保存答题答案->已经提交过答案不能再次提交"); | ||
| 317 | + return; | ||
| 318 | + }else { | ||
| 298 | if(this._sass){ | 319 | if(this._sass){ |
| 299 | if(this.questionList[_param.itemIdx]){ | 320 | if(this.questionList[_param.itemIdx]){ |
| 300 | loger.log("保存答题答案->",_param); | 321 | loger.log("保存答题答案->",_param); |
| @@ -309,13 +330,15 @@ class QuestionApe extends Ape { | @@ -309,13 +330,15 @@ class QuestionApe extends Ape { | ||
| 309 | } | 330 | } |
| 310 | } | 331 | } |
| 311 | } | 332 | } |
| 333 | + } | ||
| 334 | + } | ||
| 312 | stopQuestion(_param){ | 335 | stopQuestion(_param){ |
| 313 | if(!_param){ | 336 | if(!_param){ |
| 314 | loger.warn("停止答题->参数错误",_param); | 337 | loger.warn("停止答题->参数错误",_param); |
| 315 | return; | 338 | return; |
| 316 | } | 339 | } |
| 317 | loger.log("停止答题->",_param); | 340 | loger.log("停止答题->",_param); |
| 318 | - this.tableDelete({itemIdx:ApeConsts.CONFERENCE_OBJ_QUESTION_ID}) | 341 | + this.tableDelete(_param); |
| 319 | } | 342 | } |
| 320 | //Sass 事件监听 | 343 | //Sass 事件监听 |
| 321 | _sassCreatQuestionSuccessHandler(_data){ | 344 | _sassCreatQuestionSuccessHandler(_data){ |
| @@ -380,7 +403,7 @@ class QuestionApe extends Ape { | @@ -380,7 +403,7 @@ class QuestionApe extends Ape { | ||
| 380 | resultObj.answers=[]; | 403 | resultObj.answers=[]; |
| 381 | 404 | ||
| 382 | //根据选项的个数,把选项分开 | 405 | //根据选项的个数,把选项分开 |
| 383 | - let options=JSON.parse(resultObj.options); | 406 | + let options=resultObj.options; |
| 384 | for(let i=0;i<options.length;i++){ | 407 | for(let i=0;i<options.length;i++){ |
| 385 | let optionObj=new Object(); | 408 | let optionObj=new Object(); |
| 386 | optionObj.percent=0;//百分比 选择的人数和总参与人数的比 | 409 | optionObj.percent=0;//百分比 选择的人数和总参与人数的比 |
| @@ -1007,9 +1007,9 @@ message RCQuestionDataModelPdu { | @@ -1007,9 +1007,9 @@ message RCQuestionDataModelPdu { | ||
| 1007 | optional uint32 timeLimit=6;//有效时间 | 1007 | optional uint32 timeLimit=6;//有效时间 |
| 1008 | optional string content=7;//题干 | 1008 | optional string content=7;//题干 |
| 1009 | optional uint32 timestamp=8;//创建的时间 | 1009 | optional uint32 timestamp=8;//创建的时间 |
| 1010 | - optional string options=9;//选项列表 | ||
| 1011 | - optional string answer=10;//用户选择的答案选项索引 | ||
| 1012 | - optional string correct=11;//正确答案索引 | 1010 | + repeated string options=9;//选项列表 |
| 1011 | + repeated uint32 answer=10;//用户选择的答案选项索引 | ||
| 1012 | + repeated uint32 correct=11;//正确答案索引 | ||
| 1013 | repeated string totalUserList=12;//参与的人员userId列表 | 1013 | repeated string totalUserList=12;//参与的人员userId列表 |
| 1014 | } | 1014 | } |
| 1015 | //end | 1015 | //end |
-
请 注册 或 登录 后发表评论