Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hw_online_005
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
hw_online_005
Commits
1cc6ce4c
Commit
1cc6ce4c
authored
Jun 01, 2020
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 学情展示 提供数据
parent
46168354
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
397 additions
and
39 deletions
+397
-39
RankStatistics.test.ts
src/app/play/RankStatistics.test.ts
+47
-0
RankStatistics.ts
src/app/play/RankStatistics.ts
+56
-0
play.component.ts
src/app/play/play.component.ts
+294
-39
1.jpeg
src/assets/play/head_old/1.jpeg
+0
-0
1.png
src/assets/play/head_old/1.png
+0
-0
2.png
src/assets/play/head_old/2.png
+0
-0
3.png
src/assets/play/head_old/3.png
+0
-0
4.png
src/assets/play/head_old/4.png
+0
-0
5.png
src/assets/play/head_old/5.png
+0
-0
6.png
src/assets/play/head_old/6.png
+0
-0
7.png
src/assets/play/head_old/7.png
+0
-0
8.png
src/assets/play/head_old/8.png
+0
-0
9.png
src/assets/play/head_old/9.png
+0
-0
No files found.
src/app/play/RankStatistics.test.ts
0 → 100644
View file @
1cc6ce4c
// import {RankStatisticsManager} from './RankStatistics';
//
// describe('RankStatistics', () => {
// const sm = new RankStatisticsManager();
//
// test('列表中已经含有某用户数据,则更新数据。', () => {
// let testList = [{ uuid: '1', number: 1 }];
// let data = { uuid: '1', number: 2 };
//
// sm.rankDataList = testList;
// sm.addRankDataToList(data);
//
// expect(testList.length).toEqual(1);
// expect(testList[0].uuid).toEqual('1');
// expect(testList[0].number).toEqual(2);
// });
//
// test('列表中没有某用户的数据,则插入新数据。', () => {
// let testList = [{ uuid: '1', number: 1 }];
// let data = { uuid: '2', number: 2 };
//
// sm.rankDataList = testList;
// sm.addRankDataToList(data);
//
// expect(testList.length).toEqual(2);
// });
//
// test('数组中的数据先按照rightNum降序排列,再按照duration升序排列。', () => {
// let testList = [
// { uuid: '1', rightNum: 1, duration: 7 },
// { uuid: '2', rightNum: 1, duration: 5 },
// { uuid: '3', rightNum: 1, duration: 9 },
// { uuid: '4', rightNum: 3, duration: 9 }];
// let data =
// { uuid: '5', rightNum: 2, duration: 7 };
//
// sm.rankDataList = testList;
// sm.addRankDataToList(data);
//
// expect(testList[0].uuid).toEqual('4');
// expect(testList[1].uuid).toEqual('5');
// expect(testList[2].uuid).toEqual('2');
// expect(testList[3].uuid).toEqual('1');
// expect(testList[4].uuid).toEqual('3');
// });
//
// });
src/app/play/RankStatistics.ts
0 → 100644
View file @
1cc6ce4c
export
class
RankStatisticsManager
{
MESSAGE_RANK
=
'
hw-gameRank
'
;
_rankDataList
=
[];
// set rankDataList(arr) {
// this._rankDataList = arr;
// }
//
get
rankDataList
()
{
return
this
.
_rankDataList
;
}
addRankDataToList
(
data
)
{
for
(
let
i
=
0
;
i
<
this
.
_rankDataList
.
length
;
++
i
)
{
if
(
this
.
_rankDataList
[
i
].
uuid
==
data
.
uuid
)
{
this
.
_rankDataList
.
splice
(
i
,
1
);
break
;
}
}
this
.
_rankDataList
.
push
(
data
);
this
.
_rankDataList
.
sort
((
a
,
b
)
=>
{
if
(
a
.
rightNum
===
b
.
rightNum
)
{
return
a
.
duration
-
b
.
duration
;
}
else
{
return
b
.
rightNum
-
a
.
rightNum
;
}
});
}
getOneRankData
(
uuid
)
{
console
.
log
(
'
getOneRankData uuid:
'
,
uuid
);
console
.
log
(
'
this._rankDataList:
'
,
this
.
_rankDataList
);
for
(
let
i
=
0
;
i
<
this
.
_rankDataList
.
length
;
i
++
)
{
console
.
log
(
'
---- uuid:
'
,
this
.
_rankDataList
[
i
].
uuid
);
if
(
this
.
_rankDataList
[
i
].
uuid
==
uuid
)
{
return
this
.
_rankDataList
[
i
];
}
}
}
sendRankDataEvent
(
otherData
=
null
)
{
const
data
=
{
rankData
:
this
.
_rankDataList
};
if
(
otherData
)
{
for
(
const
key
in
otherData
)
{
data
[
key
]
=
otherData
[
key
];
}
}
(
<
any
>
window
).
courseware
.
sendEvent
(
this
.
MESSAGE_RANK
,
data
);
}
}
src/app/play/play.component.ts
View file @
1cc6ce4c
...
...
@@ -12,6 +12,8 @@ import {Subject} from 'rxjs';
import
{
debounceTime
}
from
'
rxjs/operators
'
;
import
TWEEN
from
'
@tweenjs/tween.js
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
RankStatisticsManager
}
from
'
./RankStatistics
'
;
...
...
@@ -153,11 +155,21 @@ export class PlayComponent implements OnInit, OnDestroy {
drawIcon
;
MESSAGE_START
=
'
hw-gameStart
'
;
statisticsManager
=
new
RankStatisticsManager
();
startDate
;
wrongArr
;
totalDuration
;
curWrongRoleArr
@
HostListener
(
'
window:resize
'
,
[
'
$event
'
])
onResize
(
event
)
{
this
.
winResizeEventStream
.
next
();
}
constructor
(
private
http
:
HttpClient
)
{}
ngOnInit
()
{
...
...
@@ -316,10 +328,16 @@ export class PlayComponent implements OnInit, OnDestroy {
c
.
onEvent
(
'
startGame
'
,
(
data
,
next
)
=>
{
c
.
onEvent
(
this
.
MESSAGE_START
,
(
data
,
next
)
=>
{
console
.
log
(
'
data:
'
,
data
);
if
(
this
.
startFlag
)
{
next
();
return
;
}
// const roleData = this.roleData;
// const roleIndex = this.roleIndex;
// const wordArr = this.wordArr;
...
...
@@ -341,6 +359,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
curWordIndex
=
this
.
roleIndex
;
this
.
startDate
=
new
Date
();
this
.
wrongArr
.
push
(
this
.
roleIndex
+
1
);
this
.
initCurWrongRoleArr
();
this
.
initRole
(
roleData
);
...
...
@@ -360,12 +382,17 @@ export class PlayComponent implements OnInit, OnDestroy {
});
c
.
onEvent
(
'
newRound
'
,
(
data
,
next
)
=>
{
console
.
log
(
'
data:
'
,
data
);
console
.
log
(
'
newRound
data:
'
,
data
);
// const roleData = this.roleData;
// const roleIndex = this.roleIndex;
// const wordArr = this.wordArr;
// const date = new Date().getTime();
const
{
roleData
,
roleIndex
,
wordArr
,
gameResultArr
}
=
data
;
this
.
roleData
=
roleData
;
...
...
@@ -383,6 +410,13 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
curWordIndex
=
this
.
roleIndex
;
this
.
startDate
=
new
Date
();
this
.
wrongArr
.
push
(
this
.
roleIndex
+
1
);
this
.
initCurWrongRoleArr
();
if
(
!
this
.
teachFlag
)
{
this
.
timeEnd
();
...
...
@@ -412,53 +446,63 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
this
.
teachFlag
)
{
this
.
addTeacherPageData
(
data
);
this
.
deleteOnWrongRoleArr
(
data
.
user
.
uuid
);
this
.
addStuRightRankData
(
data
);
this
.
statisticsManager
.
sendRankDataEvent
();
}
next
();
});
// c.onEvent('score_data', (data, next) => {
// console.log('data');
//
// this.addTeacherPageData(data);
// next();
// });
this
.
addScreenshotListener
();
// if (this.teachFlag) {
// c.onEvent('score_data', (data, next) => {
// console.log('data');
//
// this.addTeacherPageData(data);
// next();
// });
//
//
// } else {
//
// c.onEvent('start', (data, next) => {
// console.log('data');
//
// this.coverPageArr.length = 0;
//
// next();
// });
//
// }
}
sendServerEvent
(
key
,
data
)
{
console
.
log
(
'
send event key:
'
,
key
);
console
.
log
(
'
send event data:
'
,
data
);
//
console.log('send event key: ', key);
//
console.log('send event data: ', data);
const
c
=
(
<
any
>
window
).
courseware
;
c
.
sendEvent
(
key
,
data
);
}
addScreenshotListener
()
{
// 添加截图监听
const
c
=
(
<
any
>
window
).
courseware
;
const
uploadUrl
=
c
.
uploadUrl
();
c
.
onEvent
(
'
screenshot
'
,
(
data
,
next
)
=>
{
// canvas转图片
const
src
=
this
.
canvas
.
nativeElement
.
toDataURL
(
"
image/png
"
);
const
arr
=
src
.
split
(
'
,
'
),
mime
=
arr
[
0
].
match
(
/:
(
.*
?)
;/
)[
1
],
bstr
=
atob
(
arr
[
1
]);
let
n
=
bstr
.
length
;
const
u8arr
=
new
Uint8Array
(
n
);
while
(
n
--
)
{
u8arr
[
n
]
=
bstr
.
charCodeAt
(
n
);
}
const
obj
=
new
Blob
([
u8arr
],
{
type
:
mime
});
const
fd
=
new
FormData
();
fd
.
append
(
"
file
"
,
obj
,
"
cw_cover.png
"
);
// 上传截图
this
.
http
.
post
(
uploadUrl
,
fd
).
subscribe
((
res
)
=>
{
// 存储服务器的截图url
if
(
res
[
'
url
'
])
{
c
.
sendEvent
(
'
screenshot
'
,
{
url
:
res
[
'
url
'
]});
}
});
next
();
});
}
syncAllUser
(
allUserData
)
{
...
...
@@ -497,6 +541,28 @@ export class PlayComponent implements OnInit, OnDestroy {
initCurWrongRoleArr
()
{
if
(
!
this
.
teachFlag
)
{
return
;
}
console
.
log
(
'
this.roleData - 1:
'
,
this
.
roleData
)
this
.
curWrongRoleArr
=
this
.
roleData
.
concat
();
this
.
curWrongRoleArr
.
splice
(
this
.
roleIndex
,
1
);
console
.
log
(
'
this.roleData - 2:
'
,
this
.
roleData
)
}
deleteOnWrongRoleArr
(
uuid
)
{
for
(
let
i
=
0
;
i
<
this
.
curWrongRoleArr
.
length
;
i
++
)
{
if
(
this
.
curWrongRoleArr
[
i
].
uuid
==
uuid
)
{
this
.
curWrongRoleArr
.
splice
(
i
,
1
);
return
;
}
}
}
updateItem
(
item
)
{
if
(
item
)
{
...
...
@@ -860,6 +926,9 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.mapScale = sx;
// this.mapScale = sy;
this
.
wrongArr
=
[];
this
.
totalDuration
=
0
;
this
.
renderArr
=
[];
...
...
@@ -942,6 +1011,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
console
.
log
(
'
type:
'
,
typeof
teacherData
.
aspect
)
teacherData
.
aspect
=
JSON
.
parse
(
teacherData
.
aspect
);
const
{
roleData
,
roleIndex
,
wordArr
,
gameResultArr
}
=
teacherData
.
aspect
;
...
...
@@ -964,6 +1035,17 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
curWordIndex
=
this
.
roleIndex
;
this
.
startDate
=
new
Date
();
this
.
wrongArr
.
push
(
this
.
roleIndex
+
1
);
this
.
initCurWrongRoleArr
();
const
{
rankData
}
=
teacherData
.
aspect
;
this
.
sendServerEvent
(
this
.
MESSAGE_START
,
{
startData
:
{
quesNum
:
this
.
roleArr
.
length
},
roleData
,
roleIndex
,
wordArr
,
gameResultArr
,
rankData
,
start
:
true
});
console
.
log
(
'
check Game end 1, index:
'
,
this
.
roleIndex
);
console
.
log
(
'
check Game end 1, length:
'
,
this
.
roleArr
.
length
);
if
(
this
.
roleIndex
>=
this
.
roleArr
.
length
)
{
console
.
log
(
'
game end
'
);
this
.
gameEnd
();
...
...
@@ -1180,12 +1262,55 @@ export class PlayComponent implements OnInit, OnDestroy {
});
const
pageListNum
=
5
;
this
.
totalTeacherPage
=
Math
.
ceil
(
this
.
scoreDataArr
.
length
/
pageListNum
);
this
.
refreshTeacherPage
();
console
.
log
(
'
this.scoreDataArr.length:
'
,
this
.
scoreDataArr
.
length
);
// console.log('this.scoreDataArr.length:', this.scoreDataArr.length);
}
addStuRightRankData
(
rightData
)
{
console
.
log
(
'
in addStuRightRankData :
'
,
rightData
);
// const duration = new Date().getTime() - this.startDate.getTime();
this
.
setRankDataDefaultValue
(
rightData
);
let
rankData
=
this
.
statisticsManager
.
getOneRankData
(
rightData
.
uuid
);
if
(
!
rankData
)
{
console
.
log
(
'
!rankData 1:
'
,
rightData
);
rankData
=
{};
rankData
.
duration
=
0
;
rankData
.
wrongArr
=
[];
}
else
{
console
.
log
(
'
has rankData 1:
'
,
rankData
);
}
// console.log('rankData.wrongArr : ', rankData.wrongArr);
console
.
log
(
'
rankData.duration:
'
,
rankData
.
duration
);
rankData
.
duration
+=
rightData
.
duration
;
console
.
log
(
'
rankData.duration:
'
,
rankData
.
duration
);
rankData
.
progressStr
=
rightData
.
progressStr
;
rankData
.
uuid
=
rightData
.
user
.
uuid
;
rankData
.
name
=
rightData
.
user
.
nick_name
;
rankData
.
wrongNum
=
rankData
.
wrongArr
.
length
;
rankData
.
rightNum
=
this
.
roleIndex
+
1
-
rankData
.
wrongNum
;
// console.log('this.roleIndex : ', this.roleIndex );
// console.log('rightData.wrongNum : ', rightData.wrongNum );
//
// console.log('need send 1---- rankData: ', rankData);
console
.
log
(
'
1~~rankData:
'
,
rankData
);
this
.
checkDataIsFinish
(
rankData
);
this
.
statisticsManager
.
addRankDataToList
(
rankData
);
}
refreshTeacherPage
()
{
...
...
@@ -2443,6 +2568,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
wordArr
=
this
.
wordArr
.
concat
(
tmpArr
);
}
console
.
log
(
'
check Game end 2, index:
'
,
this
.
roleIndex
);
console
.
log
(
'
check Game end 2, length:
'
,
this
.
roleArr
.
length
);
if
(
this
.
roleIndex
>=
this
.
roleArr
.
length
)
{
console
.
log
(
'
game end
'
);
...
...
@@ -2584,18 +2712,27 @@ export class PlayComponent implements OnInit, OnDestroy {
if
(
this
.
guessLabel
.
text
.
length
==
0
)
{
return
;
}
if
(
data
.
word
==
this
.
guessLabel
.
text
)
{
// console.log(" right ");
this
.
guessWordBg
.
img
=
this
.
images
.
get
(
'
text_guess_right
'
);
this
.
sendServerEvent
(
'
answerRight
'
,
{
user
:
this
.
user
});
this
.
sendStuRightData
();
this
.
guessWordBg
.
img
=
this
.
images
.
get
(
'
text_guess_right
'
);
this
.
playAudio
(
'
right
'
);
}
else
{
// console.log(" wrong ");
// this.sendStuWrongData();
this
.
guessWordBg
.
img
=
this
.
images
.
get
(
'
text_guess_wrong
'
);
this
.
playAudio
(
'
wrong
'
);
}
this
.
guessWordBg
.
alpha
=
1
;
this
.
guessWordBg
.
light
.
alpha
=
0
;
...
...
@@ -2606,6 +2743,39 @@ export class PlayComponent implements OnInit, OnDestroy {
}
sendStuRightData
()
{
const
duration
=
new
Date
().
getTime
()
-
this
.
startDate
.
getTime
();
// this.totalDuration += duration;
//
// const wrongId = this.roleIndex + 1;
// const wIndex = this.wrongArr.indexOf(wrongId);
// if (wIndex != -1) {
// this.wrongArr.splice(wIndex);
// }
const
sendData
=
{
user
:
this
.
user
,
duration
,
progressStr
:
(
this
.
roleIndex
+
1
)
+
'
/
'
+
this
.
roleArr
.
length
,
}
this
.
sendServerEvent
(
'
answerRight
'
,
sendData
);
}
sendStuWrongData
()
{
// const duration = new Date().getTime() - this.startDate.getTime();
// this.totalDuration += duration;
//
// const sendData = {
// user: this.user,
// wrongArr: this.wrongArr,
// duration: this.totalDuration
// }
// this.sendServerEvent('answerWrong', sendData);
}
guessCancleBtnClick
()
{
const
arr
=
this
.
guessWordArr
;
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
...
...
@@ -2627,7 +2797,8 @@ export class PlayComponent implements OnInit, OnDestroy {
const
date
=
new
Date
().
getTime
();
this
.
sendServerEvent
(
'
startGame
'
,
{
roleData
,
roleIndex
,
wordArr
,
gameResultArr
,
date
,
start
:
true
});
this
.
sendServerEvent
(
this
.
MESSAGE_START
,
{
startData
:
{
quesNum
:
this
.
roleArr
.
length
},
roleData
,
roleIndex
,
wordArr
,
gameResultArr
,
date
,
start
:
true
});
this
.
canTouch
=
false
;
}
...
...
@@ -2640,7 +2811,91 @@ export class PlayComponent implements OnInit, OnDestroy {
const
gameResultArr
=
this
.
gameResultArr
;
const
date
=
new
Date
().
getTime
();
this
.
sendServerEvent
(
'
newRound
'
,
{
roleData
,
roleIndex
,
wordArr
,
gameResultArr
,
date
,
start
:
true
});
console
.
log
(
'
gameResultArr:
'
,
gameResultArr
);
const
newRoundData
=
{
roleData
,
roleIndex
,
wordArr
,
gameResultArr
,
date
,
start
:
true
};
this
.
sendOtherRoleData
(
newRoundData
);
}
sendOtherRoleData
(
newRoundData
)
{
const
roundDuration
=
this
.
wordArr
[
this
.
curWordIndex
].
time
*
1000
;
for
(
let
i
=
0
;
i
<
this
.
curWrongRoleArr
.
length
;
i
++
)
{
const
wrongRoleData
=
this
.
curWrongRoleArr
[
i
];
this
.
setRankDataDefaultValue
(
wrongRoleData
);
let
rankData
=
this
.
statisticsManager
.
getOneRankData
(
wrongRoleData
.
uuid
);
if
(
!
rankData
)
{
console
.
log
(
'
!rankData 2 :
'
,
wrongRoleData
);
rankData
=
{};
rankData
.
duration
=
0
;
rankData
.
wrongArr
=
[];
}
else
{
console
.
log
(
'
has rankData 2 :
'
,
wrongRoleData
);
}
// console.log('rankData.wrongArr : ', rankData.wrongArr);
rankData
.
uuid
=
wrongRoleData
.
uuid
;
rankData
.
name
=
wrongRoleData
.
nick_name
;
console
.
log
(
'
rankData.duration:
'
,
rankData
.
duration
);
rankData
.
duration
+=
roundDuration
;
console
.
log
(
'
rankData.duration:
'
,
rankData
.
duration
);
rankData
.
wrongArr
.
push
(
this
.
roleIndex
+
1
);
rankData
.
wrongNum
=
rankData
.
wrongArr
.
length
;
rankData
.
rightNum
=
this
.
roleIndex
+
1
-
rankData
.
wrongNum
;
rankData
.
progressStr
=
(
this
.
roleIndex
+
1
)
+
'
/
'
+
this
.
roleArr
.
length
;
// console.log('need send 2 ---- rankData: ', rankData);
//
// console.log('this.roleIndex : ', this.roleIndex );
// console.log('rightData.wrongNum : ', rankData.wrongNum );
//
console
.
log
(
'
~~rankData:
'
,
rankData
);
this
.
checkDataIsFinish
(
rankData
);
this
.
statisticsManager
.
addRankDataToList
(
rankData
);
}
const
rightData
=
{
user
:
this
.
roleData
[
this
.
roleIndex
],
duration
:
roundDuration
,
progressStr
:
(
this
.
roleIndex
+
1
)
+
'
/
'
+
this
.
roleArr
.
length
}
this
.
addStuRightRankData
(
rightData
)
newRoundData
[
'
rankData
'
]
=
this
.
statisticsManager
.
rankDataList
;
this
.
statisticsManager
.
sendRankDataEvent
(
newRoundData
);
this
.
sendServerEvent
(
'
newRound
'
,
newRoundData
);
}
setRankDataDefaultValue
(
data
)
{
if
(
data
.
user
)
{
data
.
uuid
=
data
.
user
.
uuid
;
data
.
nick_name
=
data
.
user
.
nick_name
;
}
if
(
!
data
.
duration
)
{
data
.
duration
=
0
;
}
if
(
!
data
.
wrongArr
)
{
data
.
wrongArr
=
[];
}
}
checkDataIsFinish
(
rankData
)
{
const
{
rightNum
,
wrongNum
}
=
rankData
;
if
(
rightNum
+
wrongNum
>=
this
.
roleData
.
length
)
{
rankData
.
finish
=
true
;
}
}
...
...
@@ -2772,7 +3027,7 @@ export class PlayComponent implements OnInit, OnDestroy {
getPetal
()
{
console
.
log
(
'
in getPetal
'
);
//
console.log('in getPetal');
const
petal
=
new
MySprite
();
const
id
=
Math
.
ceil
(
Math
.
random
()
*
3
);
...
...
src/assets/play/head_old/1.jpeg
0 → 100644
View file @
1cc6ce4c
49.4 KB
src/assets/play/head_old/1.png
0 → 100644
View file @
1cc6ce4c
10.8 KB
src/assets/play/head_old/2.png
0 → 100644
View file @
1cc6ce4c
9.54 KB
src/assets/play/head_old/3.png
0 → 100644
View file @
1cc6ce4c
9.52 KB
src/assets/play/head_old/4.png
0 → 100644
View file @
1cc6ce4c
16 KB
src/assets/play/head_old/5.png
0 → 100644
View file @
1cc6ce4c
10.7 KB
src/assets/play/head_old/6.png
0 → 100644
View file @
1cc6ce4c
11.3 KB
src/assets/play/head_old/7.png
0 → 100644
View file @
1cc6ce4c
9.26 KB
src/assets/play/head_old/8.png
0 → 100644
View file @
1cc6ce4c
12.4 KB
src/assets/play/head_old/9.png
0 → 100644
View file @
1cc6ce4c
12.8 KB
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