Browse Source

use of configuration to store calibration scene information

Jérôme BUISINE 10 months ago
parent
commit
c0b7740395

+ 16 - 0
experimentConfig.default.js

@@ -49,6 +49,8 @@ export const experiments = {
         y: 4
       }
     },
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     scenesConfig: {},
     availableScenes: {
       whitelist: [
@@ -100,6 +102,8 @@ export const experiments = {
     mixins: [mixins.ExperimentBaseAreSameImages],
     defaultConfig: {},
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: null,
       blacklist: null
@@ -109,6 +113,8 @@ export const experiments = {
     mixins: [mixins.ExperimentBaseAreSameImages],
     defaultConfig: {},
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: null,
       blacklist: null
@@ -118,6 +124,8 @@ export const experiments = {
     mixins: [mixins.ExperimentBaseAreSameImages, mixins.ExperimentBaseExtracts],
     defaultConfig: {},
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: null,
       blacklist: null
@@ -127,6 +135,8 @@ export const experiments = {
     mixins: [mixins.ExperimentBase],
     defaultConfig: {},
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: ['Appart1opt02', 'EchecsBas'],
       blacklist: null
@@ -143,6 +153,8 @@ export const experiments = {
       }
     },
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: ['Appart1opt02', 'EchecsBas'],
       blacklist: null
@@ -159,6 +171,8 @@ export const experiments = {
       }
     },
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: null,
       blacklist: null
@@ -170,6 +184,8 @@ export const experiments = {
       lockConfig: true
     },
     scenesConfig: {},
+    calibrationScene: '50_shades_of_grey',
+    showCalibrationEvery: 5,
     availableScenes: {
       whitelist: ['50_shades_of_grey'],
       blacklist: null

+ 24 - 0
src/config.utils.js

@@ -72,3 +72,27 @@ export const getExperimentSceneList = experimentName => {
 
   return configuredScenesList
 }
+
+/**
+ * Read config to get calibration scene for a given experiment.
+ *
+ * @param {Object} experimentName The selected experiment
+ * @returns {String} The calibration scene name
+ */
+export const getCalibrationScene = experimentName => {
+  const config = getConfigObject(experimentName)
+
+  return config[experimentName].calibrationScene
+}
+
+/**
+ * Read config to get calibration expected frequency for a given experiment.
+ *
+ * @param {Object} experimentName The selected experiment
+ * @returns {Number} The frequency expected
+ */
+export const getCalibrationFrequency = experimentName => {
+  const config = getConfigObject(experimentName)
+
+  return Number(config[experimentName].showCalibrationEvery)
+}

+ 0 - 2
src/mixins/ExperimentBaseExtracts.vue

@@ -118,8 +118,6 @@ export default {
       const qualityIndex = this.qualities.indexOf(quality)
       let action, newQuality
 
-      console.log(qualityIndex)
-
       if (event.button === 0) action = 'needMore' // Left click
       if (event.button === 2) action = 'needLess' // Right click
 

+ 7 - 4
src/views/ExperimentValidated.vue

@@ -46,7 +46,7 @@
 import Loader from '@/components/Loader.vue'
 import { mapActions, mapGetters } from 'vuex'
 import Experiments from '@/router/experiments'
-import { getExperimentSceneList } from '@/config.utils'
+import { getExperimentSceneList, getCalibrationScene, getCalibrationFrequency } from '@/config.utils'
 import { rand } from '@/functions'
 import Newsletter from '@/components/ExperimentsComponents/Newsletter.vue'
 
@@ -70,7 +70,6 @@ export default {
     return {
       experimentFullName: null,
       availableScenes: [],
-      showCalibrationEvery: 5,
       loaded: false,
       loadingMessage: 'Chargement...'
     }
@@ -87,6 +86,10 @@ export default {
     }
   },
   async mounted() {
+    // get information about calibration scene
+    let calibrationScene = getCalibrationScene(this.experimentName)
+    let calibrationSceneFreq = getCalibrationFrequency(this.experimentName)
+
     // reload scene list to update
     await this.loadScenesList
 
@@ -110,8 +113,8 @@ export default {
       let nScenes = Number(window.sessionStorage.getItem('sin3d-nb-scenes'))
       window.sessionStorage.setItem('sin3d-nb-scenes', nScenes + 1)
 
-      if (nScenes % this.showCalibrationEvery === 0) {
-        this.$router.push(`/experiments/${this.experimentName}/50_shades_of_grey`)
+      if (nScenes % calibrationSceneFreq === 0) {
+        this.$router.push(`/experiments/${this.experimentName}/${calibrationScene}`)
       }
       else if (this.hasScenesLeft) {
         this.$router.push(`/experiments/${this.experimentName}/${this.getRandomScene}`)

+ 5 - 1
src/views/Experiments/MatchExtractsWithReference.vue

@@ -276,6 +276,7 @@
 <script>
 import { mapGetters } from 'vuex'
 
+import { getCalibrationScene } from '@/config.utils'
 import ExperimentBlock from '@/components/ExperimentBlock.vue'
 import ExperimentBaseExtracts from '@/mixins/ExperimentBaseExtracts'
 import ExtractConfiguration from '@/components/ExperimentsComponents/ExtractConfiguration.vue'
@@ -309,6 +310,9 @@ export default {
     ...mapGetters(['getHostURI', 'getAllExperimentProgress'])
   },
   async mounted() {
+    // load calibration for this experiment
+    let calibrationScene = getCalibrationScene(this.experimentName)
+
     // Load config for this scene to local state
     this.loadConfig()
 
@@ -345,7 +349,7 @@ export default {
     window.addEventListener('resize', this.checkWindow)
 
     // check if calibration is already done
-    if (this.sceneName === '50_shades_of_grey') {
+    if (this.sceneName === calibrationScene) {
       // load current user progression
       this.progression = this.getAllExperimentProgress()
       let done = this.progression[this.experimentName][this.sceneName].done

+ 9 - 4
src/views/SelectExperimentScene.vue

@@ -69,7 +69,7 @@ import Loader from '@/components/Loader.vue'
 import { mapGetters, mapActions } from 'vuex'
 import Experiments from '@/router/experiments'
 import { API_ROUTES, shuffleArray } from '@/functions'
-import { getExperimentSceneList } from '@/config.utils'
+import { getExperimentSceneList, getCalibrationScene, getCalibrationFrequency } from '@/config.utils'
 
 export default {
   name: 'SelectExperimentScene',
@@ -105,6 +105,10 @@ export default {
     }
   },
   async mounted() {
+    // get information from calibration scene
+    let calibrationScene = getCalibrationScene(this.experimentName)
+    let calibrationSceneFreq = getCalibrationFrequency(this.experimentName)
+
     // reload scene list to update
     await this.loadScenesList
 
@@ -155,15 +159,16 @@ export default {
 
     // here push in session (if not already there) current user advancement
     if (window.sessionStorage.getItem('sin3d-nb-scenes') === null) {
-      window.sessionStorage.setItem('sin3d-nb-scenes', 0)
+      window.sessionStorage.setItem('sin3d-nb-scenes', 1)
+      this.$router.push(`/experiments/${this.experimentName}/${calibrationScene}`)
     }
 
     // check if necessary to show calibration before new scenes
     if (window.sessionStorage.getItem('sin3d-nb-scenes') !== null) {
       let nScenes = Number(window.sessionStorage.getItem('sin3d-nb-scenes'))
 
-      if (nScenes % this.showCalibrationEvery === 0)
-        this.$router.push(`/experiments/${this.experimentName}/50_shades_of_grey`)
+      if (nScenes % calibrationSceneFreq === 0)
+        this.$router.push(`/experiments/${this.experimentName}/${calibrationScene}`)
     }
 
     // for the experiment user is redirect to current working on