ERECexperiment.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. <template>
  2. <div>
  3. <!-- <h1 class="txt-center">任务 4:情绪回忆任务(EREC)——情感信息的记忆</h1>
  4. <div style="width: 650px; margin: 20px auto; line-height: 2">
  5. <p style="text-align: left; text-indent: 2em">
  6. 您好,请尽可能多地回忆在实验2中出现过的相容词,并于一定时间内在屏幕中的输入框处逐个进行输入,每输入一个形容词时请按下回车键或点击白框空白处保存当前形容词,点击右上角×号可删除已输入形容词,当您回忆完成后,可点击保存进入下一个测试。
  7. </p>
  8. </div> -->
  9. <div class="desc_wrap">
  10. <div
  11. style="
  12. width: 70%;
  13. height: 100%;
  14. background: rgb(248, 248, 248);
  15. opacity: 1;
  16. border-radius: 12px;
  17. margin: 0 auto;
  18. "
  19. >
  20. <div class="left_part">
  21. <div id="left_top">
  22. <div>
  23. <div id="setting">
  24. <img src="../../assets/9551.png" alt="" />
  25. </div>
  26. <div id="text">
  27. <span>操作提示:</span>
  28. </div>
  29. </div>
  30. </div>
  31. <div style="margin: 100px auto; width: 80%; text-align: justify;text-justify: distribute-all-lines;">
  32. <p> 您好,请尽可能多地回忆在实验2中出现过的相容词,并于一定时间内在屏幕中的输入框处逐个进行输入,每输入一个形容词时请按下回车键或点击白框空白处保存当前形容词,点击右上角“x”号按钮可删除已输入形容词,当您回忆完成后,可点击保存进入下一个测试。</p>
  33. <!-- <p>{{subjectInfo.description}}</p> -->
  34. </div>
  35. </div>
  36. <div
  37. class="right_part"
  38. :style="{
  39. background:
  40. 'url(' + require('../../assets/page28.png') + ')',
  41. 'background-size': '100% 100%',
  42. }"
  43. >
  44. <div id="title">
  45. <span>任务四</span>
  46. </div>
  47. <div style="position: absolute; bottom: 30px; right: 38%">
  48. <el-button type="primary" class="start" @click="startTest(1)">开始测试</el-button>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div
  54. v-if="testFlag"
  55. :class="{ testMainDiv: !testState, activeTask: testState }"
  56. class="txt-center"
  57. >
  58. <div style="padding:20px;margin-left:93%;" @click.stop="screen()">
  59. <img src="../../assets/small-big.png" alt="" />
  60. </div>
  61. <p
  62. v-show="countDownShow1"
  63. class="imgBox1"
  64. >
  65. {{ countDownStr }}
  66. </p>
  67. <div class="tabbarbox" v-show="flag1">
  68. <p
  69. v-show="countDownShow"
  70. style="text-align: right; font-size: 25px; color: black"
  71. >
  72. 倒计时:{{ countDownTime }}
  73. </p>
  74. <div class="eltagbox">
  75. <div class="eltag">
  76. <el-tag
  77. :key="tag"
  78. v-for="tag in dynamicTags"
  79. closable
  80. :disable-transitions="false"
  81. @close="handleClose(tag)"
  82. >
  83. {{ tag }}
  84. </el-tag>
  85. <el-input
  86. class="input-new-tag"
  87. v-if="inputVisible"
  88. v-model="inputValue"
  89. ref="saveTagInput"
  90. size="small"
  91. @keyup.enter.native="handleInputConfirm"
  92. @blur="handleInputConfirm"
  93. style="width: 90px"
  94. >
  95. </el-input>
  96. <!-- <el-button
  97. v-else
  98. class="button-new-tag"
  99. size="small"
  100. @click="showInput"
  101. >+ 新增</el-button
  102. > -->
  103. </div>
  104. </div>
  105. <div class="submit">
  106. <el-button style=" width:100px;
  107. background: rgb(87, 172, 187);
  108. border: 2px solid rgb(255, 255, 255);
  109. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  110. opacity: 1;
  111. border-radius: 39px;
  112. color: #FFFFFF;
  113. border-radius: 10px;" @click="userClick">保存</el-button>
  114. </div>
  115. <div v-if="testResultDivShow" class="coginitiveTestResultDiv">
  116. <p v-if="testResultDivShow" class="testResultStr" style="margin-top: 5%">
  117. 超过0.5秒的比例:{{ pass05SecRate }}%
  118. </p>
  119. </div>
  120. </div>
  121. </div>
  122. <!-- <div style="text-align: center; padding-bottom: 2rem; display: block">
  123. <el-button
  124. class="scaleButton"
  125. v-if="button0Show"
  126. @click="startTest(1)"
  127. >开始任务四测试</el-button
  128. >
  129. <el-button
  130. class="scaleButton"
  131. v-if="button1Show"
  132. @click="nexttest"
  133. >进行下一个测试</el-button
  134. >
  135. </div> -->
  136. </div>
  137. </template>
  138. <script>
  139. import screenfull from 'screenfull';
  140. export default {
  141. data() {
  142. return {
  143. flag1:false,
  144. countDownStr: "马上开始!",
  145. countDownTime_begin: 6,
  146. countDownShow1:true,
  147. userId: "",
  148. testFlag: false,
  149. testState: false,
  150. button0Show: true,
  151. button1Show: false,
  152. countDownShow: false,
  153. countDownTime: 150, //倒计时
  154. dynamicTags: [],
  155. inputVisible: true,
  156. testResultDivShow:false,
  157. inputValue: "",
  158. timeOne: "",
  159. myInterval: "",
  160. wordlist: [
  161. {
  162. index: 1,
  163. currentword: "优秀",
  164. wordtype: "positive",
  165. },
  166. {
  167. index: 2,
  168. currentword: "高尚",
  169. wordtype: "positive",
  170. },
  171. {
  172. index: 3,
  173. currentword: "聪慧",
  174. wordtype: "positive",
  175. },
  176. {
  177. index: 4,
  178. currentword: "崇高",
  179. wordtype: "positive",
  180. },
  181. {
  182. index: 5,
  183. currentword: "聪明",
  184. wordtype: "positive",
  185. },
  186. {
  187. index: 6,
  188. currentword: "杰出",
  189. wordtype: "positive",
  190. },
  191. {
  192. index: 7,
  193. currentword: "伟大",
  194. wordtype: "positive",
  195. },
  196. {
  197. index: 8,
  198. currentword: "睿智",
  199. wordtype: "positive",
  200. },
  201. {
  202. index: 9,
  203. currentword: "乐观",
  204. wordtype: "positive",
  205. },
  206. {
  207. index: 10,
  208. currentword: "渊博",
  209. wordtype: "positive",
  210. },
  211. {
  212. index: 11,
  213. currentword: "卓越",
  214. wordtype: "positive",
  215. },
  216. {
  217. index: 12,
  218. currentword: "诚实",
  219. wordtype: "positive",
  220. },
  221. {
  222. index: 13,
  223. currentword: "爽朗",
  224. wordtype: "positive",
  225. },
  226. {
  227. index: 14,
  228. currentword: "热情",
  229. wordtype: "positive",
  230. },
  231. {
  232. index: 15,
  233. currentword: "自豪",
  234. wordtype: "positive",
  235. },
  236. {
  237. index: 16,
  238. currentword: "正直",
  239. wordtype: "positive",
  240. },
  241. {
  242. index: 17,
  243. currentword: "温暖",
  244. wordtype: "positive",
  245. },
  246. {
  247. index: 18,
  248. currentword: "勤快",
  249. wordtype: "positive",
  250. },
  251. {
  252. index: 19,
  253. currentword: "坚强",
  254. wordtype: "positive",
  255. },
  256. {
  257. index: 20,
  258. currentword: "勇敢",
  259. wordtype: "positive",
  260. },
  261. {
  262. index: 21,
  263. currentword: "勤奋",
  264. wordtype: "positive",
  265. },
  266. {
  267. index: 22,
  268. currentword: "爽快",
  269. wordtype: "positive",
  270. },
  271. {
  272. index: 23,
  273. currentword: "恬静",
  274. wordtype: "positive",
  275. },
  276. {
  277. index: 24,
  278. currentword: "机智",
  279. wordtype: "positive",
  280. },
  281. {
  282. index: 25,
  283. currentword: "有趣",
  284. wordtype: "positive",
  285. },
  286. {
  287. index: 26,
  288. currentword: "豪迈",
  289. wordtype: "positive",
  290. },
  291. {
  292. index: 27,
  293. currentword: "精干",
  294. wordtype: "positive",
  295. },
  296. {
  297. index: 28,
  298. currentword: "热切",
  299. wordtype: "positive",
  300. },
  301. {
  302. index: 29,
  303. currentword: "活泼",
  304. wordtype: "positive",
  305. },
  306. {
  307. index: 30,
  308. currentword: "认真",
  309. wordtype: "positive",
  310. },
  311. {
  312. index: 31,
  313. currentword: "下贱",
  314. wordtype: "negative",
  315. },
  316. {
  317. index: 32,
  318. currentword: "卑劣",
  319. wordtype: "negative",
  320. },
  321. {
  322. index: 33,
  323. currentword: "凶狠",
  324. wordtype: "negative",
  325. },
  326. {
  327. index: 34,
  328. currentword: "窝囊",
  329. wordtype: "negative",
  330. },
  331. {
  332. index: 35,
  333. currentword: "虚伪",
  334. wordtype: "negative",
  335. },
  336. {
  337. index: 36,
  338. currentword: "自私",
  339. wordtype: "negative",
  340. },
  341. {
  342. index: 37,
  343. currentword: "丑陋",
  344. wordtype: "negative",
  345. },
  346. {
  347. index: 38,
  348. currentword: "无能",
  349. wordtype: "negative",
  350. },
  351. {
  352. index: 39,
  353. currentword: "愚蠢",
  354. wordtype: "negative",
  355. },
  356. {
  357. index: 40,
  358. currentword: "暴躁",
  359. wordtype: "negative",
  360. },
  361. {
  362. index: 41,
  363. currentword: "刻薄",
  364. wordtype: "negative",
  365. },
  366. {
  367. index: 42,
  368. currentword: "猖狂",
  369. wordtype: "negative",
  370. },
  371. {
  372. index: 43,
  373. currentword: "残酷",
  374. wordtype: "negative",
  375. },
  376. {
  377. index: 44,
  378. currentword: "狠心",
  379. wordtype: "negative",
  380. },
  381. {
  382. index: 45,
  383. currentword: "悲观",
  384. wordtype: "negative",
  385. },
  386. {
  387. index: 46,
  388. currentword: "尖刻",
  389. wordtype: "negative",
  390. },
  391. {
  392. index: 47,
  393. currentword: "阴沉",
  394. wordtype: "negative",
  395. },
  396. {
  397. index: 48,
  398. currentword: "腐朽",
  399. wordtype: "negative",
  400. },
  401. {
  402. index: 49,
  403. currentword: "无情",
  404. wordtype: "negative",
  405. },
  406. {
  407. index: 50,
  408. currentword: "消极",
  409. wordtype: "negative",
  410. },
  411. {
  412. index: 51,
  413. currentword: "自卑",
  414. wordtype: "negative",
  415. },
  416. {
  417. index: 52,
  418. currentword: "蛮横",
  419. wordtype: "negative",
  420. },
  421. {
  422. index: 53,
  423. currentword: "呆滞",
  424. wordtype: "negative",
  425. },
  426. {
  427. index: 54,
  428. currentword: "焦躁",
  429. wordtype: "negative",
  430. },
  431. {
  432. index: 55,
  433. currentword: "懒惰",
  434. wordtype: "negative",
  435. },
  436. {
  437. index: 56,
  438. currentword: "阴暗",
  439. wordtype: "negative",
  440. },
  441. {
  442. index: 57,
  443. currentword: "危险",
  444. wordtype: "negative",
  445. },
  446. {
  447. index: 58,
  448. currentword: "粗鲁",
  449. wordtype: "negative",
  450. },
  451. {
  452. index: 59,
  453. currentword: "傲慢",
  454. wordtype: "negative",
  455. },
  456. {
  457. index: 60,
  458. currentword: "自负",
  459. wordtype: "negative",
  460. },
  461. ], //词语列表
  462. };
  463. },
  464. created() {
  465. // this.testlist()
  466. },
  467. destroyed() {
  468. clearInterval(this.myInterval);
  469. },
  470. methods: {
  471. countDown_begin() {
  472. // 测试时间倒计时
  473. this.myInterval = setInterval(() => {
  474. this.countDownTime_begin--;
  475. this.countDownStr = this.countDownTime_begin;
  476. if (this.countDownTime_begin == 0) {
  477. this.countDownShow1 = false;
  478. //计算测试结果
  479. this.flag1=true;
  480. this.countDownShow = true;
  481. // this.showTargetNow();
  482. // 清除定时器
  483. clearInterval(this.myInterval);
  484. this.countDown();
  485. this.countDownTime_begin = 5;
  486. }
  487. }, 1000);
  488. },
  489. screen() {
  490. // 如果不允许进入全屏,发出不允许提示
  491. // if (!screenfull.isEnabled) {
  492. // this.$message("您的浏览器不能全屏");
  493. // return false;
  494. // }
  495. screenfull.toggle();
  496. },
  497. exitFullscreen() {
  498. if (document.exitFullscreen) {
  499. document.exitFullscreen()
  500. } else if (document.msExitFullscreen) {
  501. document.msExitFullscreen()
  502. } else if (document.mozCancelFullScreen) {
  503. document.mozCancelFullScreen()
  504. } else if (document.webkitExitFullscreen) {
  505. document.webkitExitFullscreen()
  506. }
  507. },
  508. startTest(testType) {
  509. this.screen();
  510. if (
  511. sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f") == "" ||
  512. sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f") == null
  513. ) {
  514. this.$message.error("请先登录!");
  515. return;
  516. }
  517. if (testType == 0) {
  518. this.testTypeCode = 0;
  519. } else {
  520. this.testTypeCode = 1;
  521. }
  522. this.userId = sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f");
  523. if (this.testTypeCode == 1) {
  524. // this.userTestPicList = [];
  525. this.testFlag = true;
  526. this.testState = true;
  527. this.countDownShow = true;
  528. // this.showTargetNow();
  529. this.countDown_begin();
  530. }
  531. },
  532. // 定时器
  533. // showTargetNow() {
  534. // var time = 150000;
  535. // this.timeOne = setTimeout(() => {
  536. // this.testFlag = false;
  537. // this.testState = false;
  538. // this.button0Show = false;
  539. // this.button1Show = true;
  540. // }, time);
  541. // },
  542. handleClose(tag) {
  543. this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
  544. },
  545. // showInput() {
  546. // this.inputVisible = true;
  547. // this.$nextTick((_) => {
  548. // this.$refs.saveTagInput.$refs.input.focus();
  549. // });
  550. // },
  551. handleInputConfirm() {
  552. let inputValue = this.inputValue;
  553. if(this.dynamicTags.includes(inputValue)){
  554. // 限制弹出框弹出一次
  555. let doms = document.getElementsByClassName('el-message')[0]
  556. if(doms == undefined){undefined
  557. this.$message({
  558. message: "重复输入!",
  559. type: "warning",
  560. });
  561. }
  562. this.inputValue = "";
  563. }else{
  564. if (inputValue) {
  565. this.dynamicTags.push(inputValue);
  566. }
  567. console.log(this.dynamicTags);
  568. // this.inputVisible = false;
  569. this.inputValue = "";
  570. }
  571. },
  572. // 去除输入数组重复元素,不加入最后计算
  573. newData(data) {
  574. var nData = new Array();
  575. for (var i = 0; i < data.length; i++) {
  576. if (nData.indexOf(data[i]) == -1) {
  577. nData.push(data[i]);
  578. }
  579. }
  580. return nData;
  581. },
  582. userClick() {
  583. this.countDownShow == false;
  584. this.testFlag = false;
  585. this.testState = false;
  586. this.button0Show = false;
  587. // this.button1Show = true;
  588. this.dynamicTags = this.newData(this.dynamicTags);
  589. console.log(this.dynamicTags);
  590. this.compareWordlist();
  591. this.$message({
  592. message: "测试结束!",
  593. type: "success",
  594. });
  595. // this.nexttest();
  596. clearInterval(this.myInterval);
  597. },
  598. nexttest() {
  599. this.screen();
  600. this.$router.push("EMEMexperiment");
  601. },
  602. // 倒计时
  603. countDown() {
  604. this.myInterval = setInterval(() => {
  605. this.countDownTime--;
  606. if (this.countDownTime == 0) {
  607. this.countDownShow == false;
  608. this.testFlag = false;
  609. this.testState = false;
  610. this.button0Show = false;
  611. // this.button1Show = true;
  612. this.dynamicTags = this.newData(this.dynamicTags);
  613. this.compareWordlist();
  614. this.exitFullscreen();
  615. this.$message({
  616. message: "测试结束!",
  617. type: "success",
  618. });
  619. // this.nexttest();
  620. clearInterval(this.myInterval);
  621. }
  622. }, 1000);
  623. },
  624. //取数组交集
  625. // doIntersection(firstArray, secondArray) {
  626. // // The logic here is to create a hashmap with the elements of the firstArray as the keys.
  627. // // After that, you can use the hashmap's O(1) look up time to check if the element exists in the hash
  628. // // If it does exist, add that element to the new array.
  629. // var hashmap = {};
  630. // var intersectionArray = [];
  631. // firstArray.forEach(function (element) {
  632. // hashmap[element] = 1;
  633. // });
  634. // // Since we only want to push unique elements in our case... we can implement a counter to keep track of what we already added
  635. // secondArray.forEach(function (element) {
  636. // if (hashmap[element] === 1) {
  637. // intersectionArray.push(element);
  638. // hashmap[element]++;
  639. // }
  640. // });
  641. // return intersectionArray;
  642. // // Time complexity O(n), Space complexity O(n)
  643. // },
  644. // 取数组对象中词
  645. // testlist(){
  646. // const wordlistIds = this.wordlist.map(wordlists => wordlists.currentword);
  647. // console.log(wordlistIds);
  648. // },
  649. compareWordlist(){
  650. // 判断用户输入结果正确率
  651. var accuracy = 0;
  652. let arrInter = [...this.dynamicTags].filter(x => [...this.wordlist].some(y => y.currentword === x));
  653. console.log(arrInter.length );
  654. accuracy = ((arrInter.length/this.wordlist.length)*100).toFixed(2);
  655. console.log(accuracy);
  656. // 积极词语的正确率
  657. var accopp = 0;
  658. var newArr = this.wordlist.slice(0,30)
  659. console.log(newArr)
  660. let arropp = [...this.dynamicTags].filter(x => [...newArr].some(y => y.currentword === x));
  661. accopp = ((arropp.length/newArr.length)*100).toFixed(2);
  662. console.log(accopp);
  663. // 消极词语的正确率
  664. var accneg = 0;
  665. var newArrneg = this.wordlist.slice(30,60)
  666. console.log(newArrneg);
  667. let arrneg = [...this.dynamicTags].filter(x => [...newArrneg].some(y => y.currentword === x));
  668. accneg = ((arrneg.length/newArr.length)*100).toFixed(2);
  669. console.log(accneg);
  670. //跳转
  671. // this.$http.post(
  672. // (response) => {
  673. this.$router.push({
  674. name: "TestResult",
  675. params: {
  676. result: [
  677. {
  678. name: "总体正确率",
  679. value: accuracy + "%",
  680. },
  681. ],
  682. },
  683. });
  684. // }
  685. // )
  686. },
  687. },
  688. };
  689. </script>
  690. <style scoped>
  691. .testMainDiv {
  692. margin: 0 auto;
  693. margin-top: 10px;
  694. background: gray;
  695. background-size: cover;
  696. /* text-align:center; */
  697. width: 500px;
  698. height: 300px;
  699. /* object-fit:fill; */
  700. }
  701. .activeTask {
  702. background: url("../../assets/congnitiveAblitity/rememberAbilityTask.png")
  703. no-repeat center;
  704. background-size: cover;
  705. position: fixed;
  706. top: 0;
  707. left: 0;
  708. right: 0;
  709. bottom: 0;
  710. }
  711. .scaleButton {
  712. margin-top: 20px;
  713. margin-bottom: 20px;
  714. background-size: cover;
  715. background: rgb(87, 172, 187);
  716. border: 2px solid rgb(255, 255, 255);
  717. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  718. opacity: 1;
  719. border-radius: 39px;
  720. color: #FFFFFF;
  721. }
  722. .el-tag + .el-tag {
  723. margin-left: 10px;
  724. }
  725. /* .button-new-tag {
  726. margin-left: 10px;
  727. height: 32px;
  728. line-height: 30px;
  729. padding-top: 0;
  730. padding-bottom: 0;
  731. } */
  732. .input-new-tag {
  733. margin-top: 25px;
  734. width: 90px;
  735. margin-left: 10px;
  736. vertical-align: bottom;
  737. }
  738. .el-tag {
  739. margin-top: 25px;
  740. }
  741. .eltagbox {
  742. background-color: white;
  743. border-radius: 25px;
  744. width: 800px;
  745. height: 400px;
  746. box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  747. overflow: auto;
  748. opacity: 0.7;
  749. }
  750. .tabbarbox {
  751. position: absolute;
  752. top: 50%;
  753. left: 50%;
  754. transform: translate(-50%, -50%);
  755. }
  756. .submit {
  757. margin-top: 10px;
  758. }
  759. .imgBox1 {
  760. position:absolute;
  761. top:50%;
  762. left:50%;
  763. transform:translate(-50%,-50%);
  764. color:black;
  765. font-size:70px;
  766. text-align:center;
  767. line-height:100px;
  768. margin:0 auto;
  769. }
  770. </style>