Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
e408194d
Commit
e408194d
authored
Jun 09, 2020
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ai-test' into dev
parents
6ba1d5b0
c20d33f9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
65 deletions
+57
-65
src/components/ai-test/exam/index.js
+32
-29
src/components/ai-test/index.js
+0
-18
src/components/ai-test/report/index.js
+3
-0
src/components/ai-test/scores/index.js
+3
-2
src/components/ai-test/scores/index.scss
+1
-0
src/components/ai-test/submit-answer/index.js
+18
-16
No files found.
src/components/ai-test/exam/index.js
View file @
e408194d
...
@@ -5,7 +5,13 @@ import { browser, getParam, http } from "@/utils"
...
@@ -5,7 +5,13 @@ import { browser, getParam, http } from "@/utils"
import
{
Toast
}
from
'antd-mobile'
import
{
Toast
}
from
'antd-mobile'
import
storage
from
'store2'
import
storage
from
'store2'
import
Navigation
from
"@components/ai-test/common/navigation"
import
Navigation
from
"@components/ai-test/common/navigation"
import
{
differenceInSeconds
,
differenceInMinutes
,
differenceInHours
,
differenceInDays
,
lightFormat
}
from
"date-fns"
;
import
{
differenceInSeconds
,
differenceInMinutes
,
differenceInHours
,
differenceInDays
,
differenceInMilliseconds
,
}
from
"date-fns"
;
import
{
isEmpty
}
from
'lodash'
import
{
isEmpty
}
from
'lodash'
import
{
connect
}
from
'react-redux'
import
{
connect
}
from
'react-redux'
import
{
matchPath
}
from
'react-router-dom'
import
{
matchPath
}
from
'react-router-dom'
...
@@ -35,8 +41,8 @@ class Exam extends Component {
...
@@ -35,8 +41,8 @@ class Exam extends Component {
if
(
user
.
hasError
)
{
if
(
user
.
hasError
)
{
return
history
.
push
(
'/passport'
)
return
history
.
push
(
'/passport'
)
}
}
if
(
this
.
store
.
get
(
'submitted'
))
{
if
(
this
.
store
.
session
.
get
(
'submitted'
))
{
this
.
store
.
remove
(
'submitted'
)
this
.
store
.
session
.
clearAll
(
)
this
.
props
.
history
.
replace
(
'/ai-test'
)
this
.
props
.
history
.
replace
(
'/ai-test'
)
}
}
this
.
unlisten
=
history
.
listen
((
location
)
=>
{
this
.
unlisten
=
history
.
listen
((
location
)
=>
{
...
@@ -49,6 +55,18 @@ class Exam extends Component {
...
@@ -49,6 +55,18 @@ class Exam extends Component {
this
.
unlisten
&&
this
.
unlisten
()
this
.
unlisten
&&
this
.
unlisten
()
})
})
this
.
getQuestions
()
this
.
getQuestions
()
document
.
addEventListener
(
'visibilitychange'
,
()
=>
{
if
(
document
.
visibilityState
===
'visible'
)
{
this
.
setState
(
state
=>
{
return
{
elapsed
:
state
.
elapsed
+
(
Date
.
now
()
-
this
.
store
.
session
.
get
(
'hiddenTimestamp'
))
/
10
,
}
})
}
else
{
this
.
store
.
session
.
set
(
'hiddenTimestamp'
,
Date
.
now
())
}
})
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
...
@@ -59,18 +77,18 @@ class Exam extends Component {
...
@@ -59,18 +77,18 @@ class Exam extends Component {
setCounter
=
()
=>
{
setCounter
=
()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
setState
(
state
=>
{
this
.
setState
(
state
=>
{
const
s
=
state
.
elapsed
+
1
const
fm
s
=
state
.
elapsed
+
1
return
{
return
{
time
:
{
time
:
{
d
:
Math
.
floor
(
s
/
(
60
*
6
0
*
24
)),
d
:
Math
.
floor
(
fms
/
(
60
*
60
*
10
0
*
24
)),
h
:
Math
.
floor
(
s
/
(
60
*
6
0
))
%
24
,
h
:
Math
.
floor
(
fms
/
(
60
*
60
*
10
0
))
%
24
,
m
:
Math
.
floor
(
s
/
60
)
%
60
,
m
:
Math
.
floor
(
fms
/
(
60
*
100
)
)
%
60
,
s
:
s
%
60
,
s
:
Math
.
floor
(
fms
/
100
)
%
60
,
},
},
elapsed
:
s
,
elapsed
:
fm
s
,
}
}
})
})
},
10
00
)
},
10
)
}
}
goBack
=
()
=>
{
goBack
=
()
=>
{
...
@@ -92,7 +110,7 @@ class Exam extends Component {
...
@@ -92,7 +110,7 @@ class Exam extends Component {
.
then
(
res
=>
{
.
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
.
data
const
{
code
,
msg
,
data
}
=
res
.
data
if
(
code
===
200
)
{
if
(
code
===
200
)
{
let
answer
=
this
.
store
.
get
(
'answer'
)
||
{}
let
answer
=
this
.
store
.
session
.
get
(
'answer'
)
||
{}
if
(
isEmpty
(
answer
))
{
if
(
isEmpty
(
answer
))
{
data
.
forEach
(
item
=>
{
data
.
forEach
(
item
=>
{
answer
[
item
.
id
]
=
0
answer
[
item
.
id
]
=
0
...
@@ -123,7 +141,7 @@ class Exam extends Component {
...
@@ -123,7 +141,7 @@ class Exam extends Component {
m
:
differenceInMinutes
(
now
,
createTime
)
%
60
,
m
:
differenceInMinutes
(
now
,
createTime
)
%
60
,
s
:
differenceInSeconds
(
now
,
createTime
)
%
60
,
s
:
differenceInSeconds
(
now
,
createTime
)
%
60
,
},
},
elapsed
:
differenceIn
Seconds
(
now
,
createTime
)
,
elapsed
:
differenceIn
Milliseconds
(
now
,
createTime
)
/
10
,
});
});
}
}
...
@@ -152,7 +170,7 @@ class Exam extends Component {
...
@@ -152,7 +170,7 @@ class Exam extends Component {
const
{
answer
,
time
,
recordId
,
elapsed
}
=
this
.
state
const
{
answer
,
time
,
recordId
,
elapsed
}
=
this
.
state
const
{
history
}
=
this
.
props
const
{
history
}
=
this
.
props
clearInterval
(
this
.
timer
)
clearInterval
(
this
.
timer
)
this
.
store
.
setAll
({
time
,
answer
,
recordId
,
elapsed
})
this
.
store
.
se
ssion
.
se
tAll
({
time
,
answer
,
recordId
,
elapsed
})
history
.
push
(
'/ai-test/submit'
)
history
.
push
(
'/ai-test/submit'
)
}
}
...
@@ -169,21 +187,7 @@ class Exam extends Component {
...
@@ -169,21 +187,7 @@ class Exam extends Component {
<
i
className
=
{
'iconfont iconzhong'
}
><
/i
>
<
i
className
=
{
'iconfont iconzhong'
}
><
/i
>
<
span
>
<
span
>
{
{
!!
time
.
d
&&
time
.
d
!!
time
.
d
&&
<>
{
time
.
d
}
天
<
/
>
}
{
!!
time
.
h
&&
<>
{
time
.
h
&&
time
.
h
.
toString
().
padStart
(
2
,
'0'
)}:
<
/
>
}
{
time
.
m
.
toString
().
padStart
(
2
,
'0'
)}:
{
time
.
s
.
toString
().
padStart
(
2
,
'0'
)}
<
/span
>
<
/div
>
{
/*
<div className="time">
<i className={'iconfont iconzhong'}></i>
<span>
{
!!time.d && time.d
}
}
{
{
!!
time
.
h
&&
<>
{
time
.
h
&&
time
.
h
.
toString
().
padStart
(
2
,
'0'
)}:
<
/
>
!!
time
.
h
&&
<>
{
time
.
h
&&
time
.
h
.
toString
().
padStart
(
2
,
'0'
)}:
<
/
>
...
@@ -192,7 +196,6 @@ class Exam extends Component {
...
@@ -192,7 +196,6 @@ class Exam extends Component {
{
time
.
s
.
toString
().
padStart
(
2
,
'0'
)}
{
time
.
s
.
toString
().
padStart
(
2
,
'0'
)}
<
/span
>
<
/span
>
<
/div
>
<
/div
>
*/
}
<
div
className
=
"count"
<
div
className
=
"count"
onClick
=
{
this
.
storeData
}
>
{
Object
.
values
(
answer
).
filter
(
item
=>
item
).
length
}
/{questions.length}</
div
>
onClick
=
{
this
.
storeData
}
>
{
Object
.
values
(
answer
).
filter
(
item
=>
item
).
length
}
/{questions.length}</
div
>
<
/header
>
<
/header
>
...
...
src/components/ai-test/index.js
View file @
e408194d
...
@@ -8,27 +8,9 @@ import Analysis from "@components/ai-test/analysis"
...
@@ -8,27 +8,9 @@ import Analysis from "@components/ai-test/analysis"
import
Assist
from
"@components/ai-test/assist"
import
Assist
from
"@components/ai-test/assist"
import
Help
from
'@components/ai-test/share'
import
Help
from
'@components/ai-test/share'
import
Report
from
'@components/ai-test/report'
import
Report
from
'@components/ai-test/report'
import
storage
from
'store2'
class
AiTest
extends
Component
{
class
AiTest
extends
Component
{
examStore
=
storage
.
namespace
(
'aiTestExam'
)
componentDidMount
()
{
window
.
addEventListener
(
'beforeunload'
,
this
.
handleBeforeUnload
)
}
componentWillUnmount
()
{
this
.
handleBeforeUnload
()
window
.
removeEventListener
(
'beforeunload'
,
this
.
handleBeforeUnload
)
}
handleBeforeUnload
=
()
=>
{
this
.
examStore
.
clearAll
()
}
render
()
{
render
()
{
const
{
match
}
=
this
.
props
const
{
match
}
=
this
.
props
return
(
return
(
...
...
src/components/ai-test/report/index.js
View file @
e408194d
...
@@ -45,6 +45,9 @@ class scoreReport extends Component {
...
@@ -45,6 +45,9 @@ class scoreReport extends Component {
let
_this
=
this
let
_this
=
this
var
canvas2
=
document
.
createElement
(
"canvas"
)
var
canvas2
=
document
.
createElement
(
"canvas"
)
let
_canvas
=
document
.
getElementsByClassName
(
'score-list'
)[
0
]
let
_canvas
=
document
.
getElementsByClassName
(
'score-list'
)[
0
]
if
(
!
_canvas
){
return
}
var
w
=
parseInt
(
window
.
getComputedStyle
(
_canvas
).
width
)
var
w
=
parseInt
(
window
.
getComputedStyle
(
_canvas
).
width
)
var
h
=
parseInt
(
window
.
getComputedStyle
(
_canvas
).
height
)
var
h
=
parseInt
(
window
.
getComputedStyle
(
_canvas
).
height
)
var
scale
=
window
.
devicePixelRatio
var
scale
=
window
.
devicePixelRatio
...
...
src/components/ai-test/scores/index.js
View file @
e408194d
...
@@ -278,7 +278,7 @@ class Scores extends Component {
...
@@ -278,7 +278,7 @@ class Scores extends Component {
}
}
<
/Tabs
>
<
/Tabs
>
{
{
!
isExpandRankList
?
rankList
.
length
>
10
&&
(
!
isExpandRankList
?
<
div
className
=
"expand"
onClick
=
{()
=>
{
<
div
className
=
"expand"
onClick
=
{()
=>
{
this
.
setState
({
this
.
setState
({
isExpandRankList
:
true
,
isExpandRankList
:
true
,
...
@@ -300,6 +300,7 @@ class Scores extends Component {
...
@@ -300,6 +300,7 @@ class Scores extends Component {
<
i
className
=
{
'iconfont iconiconfront-71'
}
><
/i
>
<
i
className
=
{
'iconfont iconiconfront-71'
}
><
/i
>
<
/span
>
<
/span
>
<
/div
>
<
/div
>
)
}
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -317,7 +318,7 @@ class Scores extends Component {
...
@@ -317,7 +318,7 @@ class Scores extends Component {
isShowRule
:
true
,
isShowRule
:
true
,
})
})
}}
>
开始测试
<
span
>
(今日可测试
{
pageState
.
daily_test_num
}
次)
<
/span></
button
>
}}
>
开始测试
<
span
>
(今日可测试
{
pageState
.
daily_test_num
}
次)
<
/span></
button
>
:
<
Link
to
=
{
'/ai-test/share'
}
>
:
<
Link
to
=
{
`/ai-test/share?shareCode=
${
pageState
.
code
}
`
}
>
<
button
className
=
{
'get-chance'
}
>
获取测试机会
<
span
>
(今日可测试
0
次)
<
/span></
button
>
<
button
className
=
{
'get-chance'
}
>
获取测试机会
<
span
>
(今日可测试
0
次)
<
/span></
button
>
<
/Link
>
<
/Link
>
:
<
button
className
=
{
'unavailable'
}
>
活动已结束
<
/button
>
:
<
button
className
=
{
'unavailable'
}
>
活动已结束
<
/button
>
...
...
src/components/ai-test/scores/index.scss
View file @
e408194d
...
@@ -296,6 +296,7 @@
...
@@ -296,6 +296,7 @@
padding
:
10px
;
padding
:
10px
;
color
:
#fff
;
color
:
#fff
;
font-size
:
0
;
font-size
:
0
;
z-index
:
100
;
button
{
button
{
width
:
100%
;
width
:
100%
;
...
...
src/components/ai-test/submit-answer/index.js
View file @
e408194d
...
@@ -15,20 +15,20 @@ class SubmitAnswer extends Component {
...
@@ -15,20 +15,20 @@ class SubmitAnswer extends Component {
timer
=
null
timer
=
null
state
=
{
state
=
{
time
:
this
.
store
.
get
(
'time'
)
||
{
d
:
0
,
h
:
0
,
m
:
0
,
s
:
0
},
time
:
this
.
store
.
session
.
get
(
'time'
)
||
{
d
:
0
,
h
:
0
,
m
:
0
,
s
:
0
},
answer
:
this
.
store
.
get
(
'answer'
),
answer
:
this
.
store
.
session
.
get
(
'answer'
),
recordId
:
this
.
store
.
get
(
'recordId'
),
recordId
:
this
.
store
.
session
.
get
(
'recordId'
),
analysis
:
[],
analysis
:
[],
results
:
[],
results
:
[],
elapsed
:
this
.
store
.
get
(
'elapsed'
),
elapsed
:
this
.
store
.
session
.
get
(
'elapsed'
),
}
}
componentDidMount
()
{
componentDidMount
()
{
if
(
isEmpty
(
this
.
state
.
answer
)
||
!
this
.
state
.
recordId
)
{
if
(
isEmpty
(
this
.
state
.
answer
)
||
!
this
.
state
.
recordId
)
{
this
.
props
.
history
.
replace
(
'/ai-test'
)
this
.
props
.
history
.
replace
(
'/ai-test'
)
this
.
store
.
remove
(
'submitted'
)
this
.
store
.
session
.
remove
(
'submitted'
)
}
}
if
(
this
.
store
.
get
(
'submitted'
))
{
if
(
this
.
store
.
session
.
get
(
'submitted'
))
{
this
.
getAnalysis
()
this
.
getAnalysis
()
}
else
{
}
else
{
this
.
setCounter
()
this
.
setCounter
()
...
@@ -43,18 +43,18 @@ class SubmitAnswer extends Component {
...
@@ -43,18 +43,18 @@ class SubmitAnswer extends Component {
setCounter
=
()
=>
{
setCounter
=
()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
setState
(
state
=>
{
this
.
setState
(
state
=>
{
const
s
=
state
.
elapsed
+
1
const
fm
s
=
state
.
elapsed
+
1
return
{
return
{
time
:
{
time
:
{
d
:
Math
.
floor
(
s
/
(
60
*
6
0
*
24
)),
d
:
Math
.
floor
(
fms
/
(
60
*
60
*
10
0
*
24
)),
h
:
Math
.
floor
(
s
/
(
60
*
6
0
))
%
24
,
h
:
Math
.
floor
(
fms
/
(
60
*
60
*
10
0
))
%
24
,
m
:
Math
.
floor
(
s
/
60
)
%
60
,
m
:
Math
.
floor
(
fms
/
(
60
*
100
)
)
%
60
,
s
:
s
%
60
,
s
:
Math
.
floor
(
fms
/
100
)
%
60
,
},
},
elapsed
:
s
,
elapsed
:
fm
s
,
}
}
})
})
},
10
00
)
},
10
)
}
}
...
@@ -62,12 +62,14 @@ class SubmitAnswer extends Component {
...
@@ -62,12 +62,14 @@ class SubmitAnswer extends Component {
const
{
answer
,
recordId
}
=
this
.
state
const
{
answer
,
recordId
}
=
this
.
state
http
.
post
(
`
${
API
.
home
}
/sys/submit_answer`
,
{
http
.
post
(
`
${
API
.
home
}
/sys/submit_answer`
,
{
answer
:
JSON
.
stringify
(
answer
),
answer
:
JSON
.
stringify
(
answer
),
cost_time
:
this
.
state
.
elapsed
*
10
00
,
cost_time
:
this
.
state
.
elapsed
*
10
,
record_id
:
recordId
,
record_id
:
recordId
,
}).
then
(
res
=>
{
}).
then
(
res
=>
{
const
{
code
,
msg
}
=
res
.
data
const
{
code
,
msg
}
=
res
.
data
if
(
code
===
200
)
{
if
(
code
===
200
)
{
this
.
store
.
set
(
'submitted'
,
true
)
this
.
store
.
session
.
set
(
'submitted'
,
true
)
this
.
store
.
session
.
set
(
'elapsed'
,
this
.
state
.
elapsed
)
this
.
store
.
session
.
set
(
'time'
,
this
.
state
.
time
)
clearInterval
(
this
.
timer
)
clearInterval
(
this
.
timer
)
this
.
props
.
history
.
push
(
'/ai-test/report'
)
this
.
props
.
history
.
push
(
'/ai-test/report'
)
}
else
{
}
else
{
...
@@ -100,7 +102,7 @@ class SubmitAnswer extends Component {
...
@@ -100,7 +102,7 @@ class SubmitAnswer extends Component {
<
div
className
=
"cost"
>
用时:
<
div
className
=
"cost"
>
用时:
<
span
>
<
span
>
{
{
!!
time
.
d
&&
time
.
d
!!
time
.
d
&&
<>
{
time
.
d
}
天
<
/
>
}
}
{
{
!!
time
.
h
&&
<>
{
time
.
h
&&
time
.
h
.
toString
().
padStart
(
2
,
'0'
)}:
<
/
>
!!
time
.
h
&&
<>
{
time
.
h
&&
time
.
h
.
toString
().
padStart
(
2
,
'0'
)}:
<
/
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment