正在显示
4 个修改的文件
包含
30 行增加
和
20 行删除
此 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.36.4.20170620", "author": "www.3mang.com"}; | 35 | +let _sdkInfo = {"version": "v1.36.7.20170620", "author": "www.3mang.com"}; |
| 36 | 36 | ||
| 37 | //APE | 37 | //APE |
| 38 | let _sass; | 38 | let _sass; |
| @@ -37,7 +37,7 @@ class EngineUtils{ | @@ -37,7 +37,7 @@ class EngineUtils{ | ||
| 37 | 37 | ||
| 38 | //生成时间戳毫秒 | 38 | //生成时间戳毫秒 |
| 39 | static creatTimestamp(){ | 39 | static creatTimestamp(){ |
| 40 | - let time = parseInt(new Date().getTime()/1000);//精确到毫秒 | 40 | + let time = parseInt(new Date().getTime()/1000);//精确到秒 |
| 41 | return time; | 41 | return time; |
| 42 | } | 42 | } |
| 43 | //生成时间戳 string | 43 | //生成时间戳 string |
| @@ -61,9 +61,16 @@ class QuestionApe extends Ape { | @@ -61,9 +61,16 @@ class QuestionApe extends Ape { | ||
| 61 | for(let key in this.questionList){ | 61 | for(let key in this.questionList){ |
| 62 | let question=this.questionList[key]; | 62 | let question=this.questionList[key]; |
| 63 | if(question){ | 63 | if(question){ |
| 64 | - let timestamp=parseInt(question.timeLimit-(new Date().getTime()*0.001-question.timestamp-GlobalConfig.serverAndLoacTimeDistanc)); | ||
| 65 | - loger.log("question->type:"+question.type,"倒计时:"+timestamp); | ||
| 66 | - this._emit(MessageTypes.UPDATE_QUESTION_TIME,{type:question.type,itemIdx:question.itemIdx,timestamp:timestamp}); | 64 | + let currentTime=EngineUtils.creatTimestamp()-GlobalConfig.serverAndLoacTimeDistanc;//将当的时间减去服务器时间差 |
| 65 | + | ||
| 66 | + let timestamp=parseInt(question.timeLimit-(currentTime-question.timestamp)); | ||
| 67 | + if(timestamp>=0){ | ||
| 68 | + loger.log("question->type:"+question.type,"倒计时:"+timestamp); | ||
| 69 | + this._emit(MessageTypes.UPDATE_QUESTION_TIME,{type:question.type,itemIdx:question.itemIdx,timestamp:timestamp}); | ||
| 70 | + }else { | ||
| 71 | + this.stopQuestion({itemIdx:question.itemIdx}); | ||
| 72 | + } | ||
| 73 | + | ||
| 67 | } | 74 | } |
| 68 | } | 75 | } |
| 69 | if( this.questionTimer&&Object.keys(this.questionList).length<1){ | 76 | if( this.questionTimer&&Object.keys(this.questionList).length<1){ |
| @@ -163,19 +170,19 @@ class QuestionApe extends Ape { | @@ -163,19 +170,19 @@ class QuestionApe extends Ape { | ||
| 163 | //停止答题 | 170 | //停止答题 |
| 164 | loger.log("更新答题数据"); | 171 | loger.log("更新答题数据"); |
| 165 | if(GlobalConfig.isHost){ | 172 | if(GlobalConfig.isHost){ |
| 166 | - //老师,只统计数据,不答题 | ||
| 167 | - //先判断时间是否超时 | ||
| 168 | - let timeDistance=EngineUtils.creatTimestamp()-model.timestamp; | ||
| 169 | - loger.log("答题卡显示倒计时->timeDistance:"+timeDistance); | ||
| 170 | - timeDistance=model.timeLimit-timeDistance; | ||
| 171 | - if(timeDistance<=0){ | ||
| 172 | - //答题卡时间到,需要停止 | ||
| 173 | - loger.log("答题卡时间到->需要停止"); | ||
| 174 | - this.stopQuestion(model); | ||
| 175 | - }else { | ||
| 176 | - this.getQuestionResult(model); | ||
| 177 | - } | ||
| 178 | - | 173 | + ////老师,只统计数据,不答题 |
| 174 | + ////先判断时间是否超时 | ||
| 175 | + //let timeDistance=EngineUtils.creatTimestamp()-model.timestamp; | ||
| 176 | + //loger.log("答题卡显示倒计时->timeDistance:"+timeDistance); | ||
| 177 | + //timeDistance=model.timeLimit-timeDistance; | ||
| 178 | + //if(timeDistance<=0){ | ||
| 179 | + // //答题卡时间到,需要停止 | ||
| 180 | + // loger.log("答题卡时间到->需要停止"); | ||
| 181 | + // this.stopQuestion(model); | ||
| 182 | + //}else { | ||
| 183 | + // this.getQuestionResult(model); | ||
| 184 | + //} | ||
| 185 | + this.getQuestionResult(model); | ||
| 179 | }else if(GlobalConfig.isNormal) { | 186 | }else if(GlobalConfig.isNormal) { |
| 180 | //学生->如果自己已经提交过答案就不需要再显示 | 187 | //学生->如果自己已经提交过答案就不需要再显示 |
| 181 | if(model.totalUserList.indexOf(GlobalConfig.userId)>=0){ | 188 | if(model.totalUserList.indexOf(GlobalConfig.userId)>=0){ |
| @@ -258,7 +265,7 @@ class QuestionApe extends Ape { | @@ -258,7 +265,7 @@ class QuestionApe extends Ape { | ||
| 258 | modelPdu.type = parseInt(_param.type)||0; | 265 | modelPdu.type = parseInt(_param.type)||0; |
| 259 | modelPdu.questionId= parseInt(_param.questionId)||0; | 266 | modelPdu.questionId= parseInt(_param.questionId)||0; |
| 260 | modelPdu.timeLimit= parseInt(_param.timeLimit)||1;//有效时间 | 267 | modelPdu.timeLimit= parseInt(_param.timeLimit)||1;//有效时间 |
| 261 | - modelPdu.timestamp= parseInt(_param.timestamp)||EngineUtils.creatTimestamp();//创建的时间 | 268 | + modelPdu.timestamp= parseInt(_param.timestamp)||parseInt(EngineUtils.creatTimestamp()- GlobalConfig.serverAndLoacTimeDistanc);;//创建的时间(秒) |
| 262 | modelPdu.content= _param.content||[];//题干 | 269 | modelPdu.content= _param.content||[];//题干 |
| 263 | modelPdu.options= _param.options||[];//选项列表 | 270 | modelPdu.options= _param.options||[];//选项列表 |
| 264 | modelPdu.answer= _param.answer||[];//用户选择的选项索引 | 271 | modelPdu.answer= _param.answer||[];//用户选择的选项索引 |
| @@ -376,8 +383,11 @@ class QuestionApe extends Ape { | @@ -376,8 +383,11 @@ class QuestionApe extends Ape { | ||
| 376 | _sassCreatQuestionSuccessHandler(_data){ | 383 | _sassCreatQuestionSuccessHandler(_data){ |
| 377 | //loger.log("创建答题卡成功",_data); | 384 | //loger.log("创建答题卡成功",_data); |
| 378 | if(_data){ | 385 | if(_data){ |
| 386 | + //获取当前对方系统时间,再减去服务器时间差 | ||
| 387 | + let timestamp=parseInt(EngineUtils.creatTimestamp()- GlobalConfig.serverAndLoacTimeDistanc);//创建答题卡的时间(秒) | ||
| 379 | let questionItem=_data; | 388 | let questionItem=_data; |
| 380 | - questionItem.itemIdx=parseInt(EngineUtils.creatTimestamp()- GlobalConfig.serverAndLoacTimeDistanc); | 389 | + questionItem.itemIdx=timestamp; |
| 390 | + questionItem.timestamp=timestamp; | ||
| 381 | this.sendUpdaterTable(questionItem); | 391 | this.sendUpdaterTable(questionItem); |
| 382 | } | 392 | } |
| 383 | 393 |
-
请 注册 或 登录 后发表评论