1
0
Преглед на файлове

fix(front): 修复报告

Go преди 4 години
родител
ревизия
45f45a7e14

+ 8 - 8
front/project/www/components/Continue/index.js

@@ -6,35 +6,35 @@ import Button from '../Button';
 
 function Continue(props) {
   const { data = {}, onContinue, onRestart, onNext, onClose } = props;
-  const { date, paper = {}, userNumber, questionNumber } = data;
+  const { updateTime, paper = {}, userNumber, questionNumber } = data;
   return (
     <div className="continue">
       <div className="body">
         <div className="left">
           <div className="text">上次做题</div>
-          <div className="date">{date && formatDate(date)}</div>
+          <div className="date">{updateTime && formatDate(updateTime, 'YYYY-MM-DD HH:mm:ss')}</div>
         </div>
         <div className="center">
           <div className="text">{paper.title} {questionNumber > 0 ? userNumber * 100 / questionNumber : 0}%</div>
           <div className="list">
-            <Button radius theme="border" size="small" onClick={() => {
+            {userNumber < questionNumber && <Button radius theme="border" size="small" onClick={() => {
               onContinue();
             }}>
               <Assets name="ico_24_continue" svg />
               Continue
-            </Button>
-            <Button radius theme="border" size="small" onClick={() => {
+            </Button>}
+            {userNumber === questionNumber && <Button radius theme="border" size="small" onClick={() => {
               onRestart();
             }}>
               <Assets name="ico_24_restart" svg />
               Restart
-            </Button>
-            <Button radius theme="border" size="small" onClick={() => {
+            </Button>}
+            {userNumber < questionNumber && <Button radius theme="border" size="small" onClick={() => {
               onNext();
             }}>
               <Assets name="ico_24_next" svg />
               Next
-            </Button>
+            </Button>}
           </div>
         </div>
         <div className="right">

+ 9 - 3
front/project/www/routes/exercise/main/page.js

@@ -658,7 +658,12 @@ export default class extends Page {
   }
 
   clearExercise() {
-    My.clearLatestExercise();
+    My.clearLatestExercise()
+      .then(() => {
+        const { info } = this.props.user;
+        info.latestExercise = 0;
+        User.infoHandle(info);
+      });
     this.setState({ latest: null });
   }
 
@@ -675,13 +680,14 @@ export default class extends Page {
               this.clearExercise();
             }}
             onContinue={() => {
-              Question.continueLink('exercise', latest);
+              Question.continueLink('exercise', { id: latest.originId, report: latest });
             }}
             onRestart={() => {
               this.restart(latest);
+              Question.startLink('exercise', { id: latest.originId, report: latest });
             }}
             onNext={() => {
-              Question.continueLink('exercise', latest);
+              Question.continueLink('exercise', { id: latest.originId, report: latest });
             }}
           />
         )}

+ 2 - 2
front/project/www/routes/my/answer/page.js

@@ -285,7 +285,7 @@ export default class extends Page {
                   <div className="f-r t-2 t-s-12">{formatDate(item.createTime, 'YYYY-MM-DD HH:mm:ss')}</div>
                 </div>
                 <div className="desc">
-                  <OpenText>{item.content}</OpenText>
+                  <OpenText><div dangerouslySetInnerHTML={{ __html: item.content }} /></OpenText>
                 </div>
                 {item.answerStatus > 0 && (
                   <div>
@@ -295,7 +295,7 @@ export default class extends Page {
                 )}
                 {item.answerStatus > 0 && (
                   <div className="desc">
-                    <OpenText>{item.answerStatus === 2 ? '与题目内容无关,老师无法作出回答,敬请谅解。' : item.answer}</OpenText>
+                    <OpenText><div dangerouslySetInnerHTML={{ __html: item.answerStatus === 2 ? '与题目内容无关,老师无法作出回答,敬请谅解。' : item.answer }} /></OpenText>
                   </div>
                 )}
               </div>

+ 5 - 1
front/project/www/routes/my/error/page.js

@@ -18,6 +18,7 @@ import GIcon from '../../../components/Icon';
 import { TimeRange, QuestionType } from '../../../../Constant';
 import { My } from '../../../stores/my';
 import { Question } from '../../../stores/question';
+import { User } from '../../../stores/user';
 
 const QuestionTypeMap = getMap(QuestionType, 'value', 'label');
 
@@ -313,8 +314,11 @@ export default class extends Page {
   clearErrorReport() {
     My.clearLatestError()
       .then(() => {
-        this.setState({ latest: null });
+        const { info } = this.props.user;
+        info.latestError = 0;
+        User.infoHandle(info);
       });
+    this.setState({ latest: null });
   }
 
   renderView() {

+ 52 - 43
front/project/www/routes/my/report/page.js

@@ -228,7 +228,11 @@ export default class extends Page {
         title: '做题时间',
         fixSort: true,
         render: (text, record) => {
-          const time = formatDate(record.latestTime, 'YYYY-MM-DD HH:mm:ss');
+          const { reports } = record;
+          if (!reports) return null;
+          const report = reports[0];
+          if (!report) return null;
+          const time = formatDate(report.updateTime, 'YYYY-MM-DD HH:mm:ss');
           return (
             <div className="sub">
               <div className="t-2 t-s-12">{time.split(' ')[0]}</div>
@@ -356,11 +360,8 @@ export default class extends Page {
         key: 'title',
         title: '名称',
         fixSort: true,
-        render: (text, record) => {
-          const { reports } = record;
-          return reports.map((report, index) => {
-            return <div className="sub">{index === 0 && text}</div>;
-          });
+        render: (text) => {
+          return <div className="sub">{text}</div>;
         },
       },
       {
@@ -368,7 +369,11 @@ export default class extends Page {
         title: '做题时间',
         fixSort: true,
         render: (text, record) => {
-          const time = formatDate(record.latestTime, 'YYYY-MM-DD HH:mm:ss');
+          const { reports } = record;
+          if (!reports) return null;
+          const report = reports[0];
+          if (!report) return null;
+          const time = formatDate(report.updateTime, 'YYYY-MM-DD HH:mm:ss');
           return (
             <div className="sub">
               <div className="t-2 t-s-12">{time.split(' ')[0]}</div>
@@ -389,16 +394,17 @@ export default class extends Page {
         title: '完成度',
         render: (text, record) => {
           const { reports } = record;
-          return reports.map(report => {
-            return (
-              <div className="sub">
-                <div className="t-2 t-s-12">{formatPercent(report.userNumber, report.questionNumber, false)}</div>
-                <div className="t-6 t-s-12">
-                  {report.userNumber}/{report.questionNumber}
-                </div>
+          if (!reports) return null;
+          const report = reports[0];
+          if (!report) return null;
+          return (
+            <div className="sub">
+              <div className="t-2 t-s-12">{formatPercent(report.userNumber, report.questionNumber, false)}</div>
+              <div className="t-6 t-s-12">
+                {report.userNumber}/{report.questionNumber}
               </div>
-            );
-          });
+            </div>
+          );
         },
       },
       {
@@ -407,13 +413,14 @@ export default class extends Page {
         sort: true,
         render: (text, record) => {
           const { reports } = record;
-          return reports.map(report => {
-            return (
-              <div className="sub">
-                <div className="t-2 t-s-12">{formatPercent(report.userCorrect, report.userNumber, false)}</div>
-              </div>
-            );
-          });
+          if (!reports) return null;
+          const report = reports[0];
+          if (!report) return null;
+          return (
+            <div className="sub">
+              <div className="t-2 t-s-12">{formatPercent(report.userCorrect, report.userNumber, false)}</div>
+            </div>
+          );
         },
       },
       {
@@ -422,13 +429,14 @@ export default class extends Page {
         sort: true,
         render: (text, record) => {
           const { reports } = record;
-          return reports.map(report => {
-            return (
-              <div className="sub">
-                <div className="t-2 t-s-12">{formatSeconds(report.userTime / report.userNumber)}</div>
-              </div>
-            );
-          });
+          if (!reports) return null;
+          const report = reports[0];
+          if (!report) return null;
+          return (
+            <div className="sub">
+              <div className="t-2 t-s-12">{formatSeconds(report.userTime / report.userNumber)}</div>
+            </div>
+          );
         },
       },
       {
@@ -436,19 +444,20 @@ export default class extends Page {
         title: '报告',
         render: (text, record) => {
           const { reports } = record;
-          return reports.map(report => {
-            return (
-              <div className="sub">
-                <IconButton
-                  type="report"
-                  tip="report"
-                  onClick={() => {
-                    Question.reportLink({ report });
-                  }}
-                />
-              </div>
-            );
-          });
+          if (!reports) return null;
+          const report = reports[0];
+          if (!report) return null;
+          return (
+            <div className="sub">
+              <IconButton
+                type="report"
+                tip="report"
+                onClick={() => {
+                  Question.reportLink({ report });
+                }}
+              />
+            </div>
+          );
         },
       },
     ];

+ 2 - 2
front/project/www/routes/paper/process/page.js

@@ -202,11 +202,11 @@ export default class extends Page {
     return Question.finish(report.id)
       .then(() => {
         // 跳转到报告页
-        Question.reportLink({ report });
+        Question.reportLink({ report }, false);
         // this.setState({ scene: 'finish' });
       })
       .catch(() => {
-        Question.reportLink({ report });
+        Question.reportLink({ report }, false);
       });
   }
 

+ 7 - 8
front/project/www/routes/paper/report/page.js

@@ -860,7 +860,7 @@ export default class extends Page {
       </div>
       <div className="body gray">
         <div className="content t-c">
-          <Button size="lager" width={200} radius>
+          <Button size="lager" width={200} radius onClick={() => linkTo('/exercise?tab=sentence')}>
             继续做题
             </Button>
         </div>
@@ -983,11 +983,11 @@ export default class extends Page {
           <div className="detail-1">
             <div className="block">
               <div className="t1">平均用时</div>
-              <div dangerouslySetInnerHTML={{ __html: formatSeconds(info.userTime / info.userNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '<div class="s">$1</div><div class="t3">$2</div>') }} />
+              <div className="t2" dangerouslySetInnerHTML={{ __html: formatSeconds(info.userTime / info.userNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '$1<div class="t3">$2</div>') }} />
             </div>
             <div className="block all">
               <div className="t1">全站用户</div>
-              <div dangerouslySetInnerHTML={{ __html: formatSeconds(info.totalTime / info.totalNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '<div class="s">$1</div><div class="t3">$2</div>') }} />
+              <div className="t2" dangerouslySetInnerHTML={{ __html: formatSeconds(info.totalTime / info.totalNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '$1<div class="t3">$2</div>') }} />
             </div>
           </div>
           <LineChart
@@ -1013,8 +1013,7 @@ export default class extends Page {
             </div>
             <div className="block all">
               <div className="t1">全站用户</div>
-              <div className="t2">90</div>
-              <div className="t3">{formatPercent(info.totalCorrect, info.totalNumber, false)}</div>
+              <div className="t2">{formatPercent(info.totalCorrect, info.totalNumber, false)}</div>
             </div>
           </div>
           <BarChart
@@ -1037,7 +1036,7 @@ export default class extends Page {
           <div className="detail-1">
             <div className="block">
               <div className="t1">平均用时</div>
-              <div dangerouslySetInnerHTML={{ __html: formatSeconds(info.userTime / info.userNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '<div class="s">$1</div><div class="t3">$2</div>') }} />
+              <div className="t2" dangerouslySetInnerHTML={{ __html: formatSeconds(info.userTime / info.userNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '$1<div class="t3">$2</div>') }} />
             </div>
             <div className="block all">
               <div className="t1">正确率</div>
@@ -1078,7 +1077,7 @@ export default class extends Page {
       </div>
       <div className="body">
         <div className="content t-c">
-          <Button size="lager" width={200} radius>
+          <Button size="lager" width={200} radius onClick={() => linkTo('/exercise')}>
             继续做题
             </Button>
         </div>
@@ -1200,7 +1199,7 @@ export default class extends Page {
             <div className="detail-1">
               <div className="block">
                 <div className="t1">平均用时</div>
-                <div dangerouslySetInnerHTML={{ __html: formatSeconds(subjectDetail.info.userTime / subjectDetail.info.userNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '<div class="s">$1</div><div class="t3">$2</div>') }} />
+                <div className="t2" dangerouslySetInnerHTML={{ __html: formatSeconds(subjectDetail.info.userTime / subjectDetail.info.userNumber).replace(/([0-9]+)(m|min|h|hour|s)/g, '$1<div class="t3">$2</div>') }} />
               </div>
             </div>
             <LineChart

+ 24 - 8
front/project/www/stores/question.js

@@ -1,24 +1,40 @@
 import BaseStore from '@src/stores/base';
 
 export default class QuestionStore extends BaseStore {
-  startLink(type, item) {
-    openLink(`/paper/process/${type}/${item.id}`);
+  startLink(type, item, open = true) {
+    if (open) {
+      openLink(`/paper/process/${type}/${item.id}`);
+    } else {
+      linkTo(`/paper/process/${type}/${item.id}`);
+    }
   }
 
-  continueLink(type, item) {
+  continueLink(type, item, open = true) {
     // const w = window.open('about:blank');
     // w.location.href = `/paper/process/${type}/${item.id}?r=${item.report.id}`;
-    openLink(`/paper/process/${type}/${item.id}?r=${item.report.id}`);
+    if (open) {
+      openLink(`/paper/process/${type}/${item.id}?r=${item.report.id}`);
+    } else {
+      linkTo(`/paper/process/${type}/${item.id}?r=${item.report.id}`);
+    }
   }
 
-  reportLink(item) {
+  reportLink(item, open = true) {
     // const w = window.open('about:blank');
     // w.location.href = `/paper/report/${item.report.id}`;
-    openLink(`/paper/report/${item.report.id}`);
+    if (open) {
+      openLink(`/paper/report/${item.report.id}`);
+    } else {
+      linkTo(`/paper/report/${item.report.id}`);
+    }
   }
 
-  reportPrevLink(item) {
-    openLink(`/paper/report/${item.prevReport.id}`);
+  reportPrevLink(item, open = true) {
+    if (open) {
+      openLink(`/paper/report/${item.prevReport.id}`);
+    } else {
+      linkTo(`/paper/report/${item.prevReport.id}`);
+    }
   }
 
   searchStem({ keyword, questionTypes, module, structIds, place, difficult, order, direction }) {

+ 10 - 6
server/data/src/main/java/com/qxgmat/data/relation/mapping/QuestionNoRelationMapper.xml

@@ -83,7 +83,7 @@
       </foreach>
     </if>
     where
-    q.id &gt; 0
+    q.id &gt; 0 and qn.question_id &gt; 0
     <if test="keyword">
       and (qn.`title` = #{keyword, jdbcType=VARCHAR} or MATCH (q.`description`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE))
     </if>
@@ -110,7 +110,7 @@
     <include refid="Id_Column_List" />,
     MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) as `relation_score`
     from `question_no` qn
-    where
+    where qn.question_id &gt; 0 and
     MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE)
     <if test="module != null">
       and qn.`module` = #{module,jdbcType=VARCHAR}
@@ -130,7 +130,8 @@
     from `question_no` qn
     left join `question` q on q.`id` = qn.`question_id`
     where
-    qn.`module` = 'examination'
+    q.id &gt; 0 and qn.question_id &gt; 0
+    and qn.`module` = 'examination'
     <if test="structId != null">
       and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
     </if>
@@ -159,7 +160,8 @@
     from `question_no` qn
     left join `question` q on q.`id` = qn.`question_id`
     where
-    qn.`module` = 'examination'
+    q.id &gt; 0 and qn.question_id &gt; 0
+    and qn.`module` = 'examination'
     <if test="structId != null">
       and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
     </if>
@@ -186,7 +188,8 @@
       left join `exercise_paper` ep on find_in_set(qn.`id`, trim(TRAILING ']' from trim(LEADING '[' from eq.`question_no_ids`)))
       and ep.`id` = #{paperId,jdbcType=VARCHAR}
     </if>
-    where qn.`module` = "exercise" and q.`id` &gt; 0 and qn.`delete_time` = null
+    where q.`id` &gt; 0 and qn.`question_id` &gt; 0 and qn.`delete_time` = null
+    and qn.`module` = "exercise"
     <if test="paperId != null">
       and ep.`id` &gt; 0
     </if>
@@ -226,7 +229,8 @@
       left join `examination_paper` ep on find_in_set(qn.`id`, trim(TRAILING ']' from trim(LEADING '[' from eq.`question_no_ids`)))
       and ep.`id` = #{paperId,jdbcType=VARCHAR}
     </if>
-    where qn.`module` = "examination" and q.`id` &gt; 0 and qn.`delete_time` = null
+    where q.`id` &gt; 0 and qn.`question_id` &gt; 0 and qn.`delete_time` = null
+    and qn.`module` = "examination" and
     <if test="paperId != null">
       and ep.`id` &gt; 0
     </if>

+ 2 - 2
server/data/src/main/java/com/qxgmat/data/relation/mapping/UserReportRelationMapper.xml

@@ -133,8 +133,8 @@
     where
       `user_time` &lt; `time`
     and `user_number` = `question_number`
-    and `paper_origin` = #{paper_origin,jdbcType=VARCHAR}
-    and `origin_id` = #{origin_id,jdbcType=INTEGER}
+    and `paper_origin` = #{paperOrigin,jdbcType=VARCHAR}
+    and `origin_id` = #{originId,jdbcType=INTEGER}
   </select>
 
   <!--

+ 10 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/response/UserReportBaseDto.java

@@ -13,6 +13,8 @@ public class UserReportBaseDto {
 
     private Integer paperId;
 
+    private UserPaperBaseExtendDto paper;
+
     private String paperModule;
 
     private String paperOrigin;
@@ -118,4 +120,12 @@ public class UserReportBaseDto {
     public void setSetting(JSONObject setting) {
         this.setting = setting;
     }
+
+    public UserPaperBaseExtendDto getPaper() {
+        return paper;
+    }
+
+    public void setPaper(UserPaperBaseExtendDto paper) {
+        this.paper = paper;
+    }
 }

+ 8 - 2
server/gateway-api/src/main/java/com/qxgmat/service/extend/QuestionFlowService.java

@@ -289,7 +289,9 @@ public class QuestionFlowService {
             if (questionNoId == 0) return false;
             this.bindQuestionNo(question, questionNoId);
             // 设定最后一次练习记录
-            usersService.edit(User.builder().id(question.getUserId()).latestExercise(report.getId()).build());
+            if (PaperOrigin.ValueOf(report.getPaperOrigin()) == PaperOrigin.EXERCISE){
+                usersService.edit(User.builder().id(question.getUserId()).latestExercise(report.getId()).build());
+            }
             return true;
         });
         nextCallback.put(PaperModule.SENTENCE, (question, report, lastQuestion)->{
@@ -415,6 +417,10 @@ public class QuestionFlowService {
             this.statExaminationReport(report, questionList);
         });
 
+        finishAfterCallback.put(PaperOrigin.EXERCISE, (report)->{
+            // 重置最后一次练习记录
+            usersService.edit(User.builder().id(report.getUserId()).latestExercise(0).build());
+        });
         finishAfterCallback.put(PaperOrigin.ERROR, (report)->{
             // 设定最后一次错题记录
             usersService.edit(User.builder().id(report.getUserId()).latestError(report.getId()).build());
@@ -755,7 +761,7 @@ public class QuestionFlowService {
         userReportService.edit(userReport);
 
         FinishAfterReport finishAfterReportCallback = finishAfterCallback.get(PaperOrigin.ValueOf(userReport.getPaperOrigin()));
-        if(finishAfterCallback != null){
+        if(finishAfterReportCallback != null){
             finishAfterReportCallback.callback(userReport);
         }
         // 统计: 更新对应paper记录

+ 4 - 1
server/gateway-api/src/main/java/com/qxgmat/service/inline/QuestionNoService.java

@@ -146,6 +146,7 @@ public class QuestionNoService extends AbstractService {
         example.and(
                 example.createCriteria()
                         .andEqualTo("module", module.key)
+                        .andGreaterThan("questionId", 0)
                         .andCondition(String.format(formatSet, structId, "module_struct"))
         );
         example.orderBy("no").asc();
@@ -163,6 +164,7 @@ public class QuestionNoService extends AbstractService {
         example.and(
                 example.createCriteria()
                         .andEqualTo("module", module.key)
+                        .andGreaterThan("questionId", 0)
         );
         if (structIds != null){
             Example.Criteria criteria = example.createCriteria();
@@ -313,6 +315,7 @@ public class QuestionNoService extends AbstractService {
         Example example = new Example(QuestionNo.class);
         example.and(
                 example.createCriteria()
+                        .andGreaterThan("questionId", 0)
                 .andCondition(String.format(formatSet, structId, "module_struct"))
                 .andEqualTo("relationNumber", number)
                 .andNotIn("id", filterIds)
@@ -332,7 +335,7 @@ public class QuestionNoService extends AbstractService {
      * @return
      */
     public Boolean bindQuestion(Integer[] ids, Integer questionId){
-        if (ids.length == 0) return false;
+        if (ids == null || ids.length == 0) return false;
         Example example = new Example(QuestionNo.class);
         example.and(
                 example.createCriteria()