ExperimentValidated.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div>
  3. <h2>"{{ experimentFullName }}"</h2>
  4. <v-card>
  5. <v-card-title primary-title>
  6. <v-spacer />
  7. <div class="headline">Experiment validated for the scene "{{ sceneName }}"</div>
  8. <v-spacer />
  9. </v-card-title>
  10. <v-card-actions>
  11. <v-spacer />
  12. <!-- <v-btn flat exact to="/experiments/">
  13. <v-icon left>home</v-icon>
  14. Select another experiment
  15. </v-btn>
  16. <v-btn flat exact :to="`/experiments/${experimentName}`">
  17. <v-icon left>arrow_back</v-icon>
  18. Go back to scene selection
  19. </v-btn> -->
  20. <v-btn v-if="hasScenesLeft" flat exact :to="`/experiments/${experimentName}/${getRandomScene}`">
  21. <v-icon left>shuffle</v-icon>
  22. Continue with a random scene
  23. </v-btn>
  24. <div v-if="!hasScenesLeft" class="headline">You finished all the scenes, thanks for your contribution!</div>
  25. <v-spacer />
  26. </v-card-actions>
  27. </v-card>
  28. </div>
  29. </template>
  30. <script>
  31. import { mapState, mapGetters } from 'vuex'
  32. import getters from '@/store/getters'
  33. import Experiments from '@/router/experiments'
  34. import { getExperimentSceneList } from '@/config.utils'
  35. import { rand } from '@/functions'
  36. export default {
  37. name: 'ExperimentValidated',
  38. props: {
  39. experimentName: {
  40. type: String,
  41. required: true
  42. },
  43. sceneName: {
  44. type: String,
  45. required: true
  46. }
  47. },
  48. data() {
  49. return {
  50. experimentFullName: null,
  51. availableScenes: []
  52. }
  53. },
  54. computed: {
  55. ...mapGetters(['getAllExperimentProgress']),
  56. hasScenesLeft() {
  57. return this.availableScenes.length > 0
  58. },
  59. getRandomScene() {
  60. return this.availableScenes[rand(0, this.availableScenes.length - 1)]
  61. }
  62. },
  63. mounted() {
  64. const scenesList = getExperimentSceneList(this.experimentName)
  65. // load current user progression
  66. this.progression = this.getAllExperimentProgress()
  67. // Find the selected experiment full name
  68. this.experimentFullName = Experiments.find(x => x.name === this.experimentName).meta.fullName
  69. // Get a list of available and not already validated scenes for this experiment
  70. this.availableScenes = Object.keys(this.progression[this.experimentName])
  71. .filter(aScene =>
  72. scenesList.includes(aScene) &&
  73. this.progression[this.experimentName] &&
  74. !this.progression[this.experimentName][aScene].done)
  75. if (this.hasScenesLeft) {
  76. this.$router.push(`/experiments/${this.experimentName}/${this.getRandomScene}`)
  77. }
  78. }
  79. }
  80. </script>