Parcourir la source

Updated mixin

rigwild il y a 4 ans
Parent
commit
35d2624d1f

+ 0 - 22
src/mixins/ExperimentBaseAreSameImages.vue

@@ -8,7 +8,6 @@
 import ExperimentBase from '@/mixins/ExperimentBase'
 
 import { mapGetters } from 'vuex'
-import { rand } from '@/functions'
 import { EXPERIMENT as experimentMsgId } from '@/../config.messagesId'
 
 export default {
@@ -42,27 +41,6 @@ export default {
       return { image1, image2 }
     },
 
-    // Get a test with random qualities
-    getRandomTest() {
-      return this.getTest(
-        this.qualities[rand(0, this.qualities.length - 1)],
-        this.qualities[rand(0, this.qualities.length - 1)]
-      )
-    },
-
-    // Get a test with random qualities
-    getReferenceTest() {
-      // Randomly choose which is the reference image (0 = left, 1 = right)
-      const isReferenceLeft = rand(0, 1) === 0
-      // Randomly choose a quality for the other image
-      const randomQuality = this.qualities[rand(0, this.qualities.length - 1)]
-
-      const res = [this.qualities[this.qualities.length - 1], randomQuality]
-      this.referenceImagePosition = isReferenceLeft ? 'left' : 'right'
-      const table = isReferenceLeft ? res : res.reverse()
-      return this.getTest(table[0], table[1])
-    },
-
     /** An action was triggered, load a new test and save progression
      * @param {Boolean} areTheSame Are the images the same
      * @param {Function} getTestFn Function to be called to get the next tests

+ 10 - 1
src/views/Experiments/AreSameImagesRandom.vue

@@ -59,6 +59,7 @@
 <script>
 import ExperimentBlock from '@/components/ExperimentBlock.vue'
 import ExperimentBaseAreTheSame from '@/mixins/ExperimentBaseAreSameImages'
+import { rand } from '@/functions'
 
 export default {
   name: 'AreSameImagesRandom',
@@ -94,6 +95,14 @@ export default {
   },
 
   methods: {
+    // Get a test with random qualities
+    getRandomTest() {
+      return this.getTest(
+        this.qualities[rand(0, this.qualities.length - 1)],
+        this.qualities[rand(0, this.qualities.length - 1)]
+      )
+    },
+
     // generate next action and save data
     async nextAction(same) {
       let additionalData = {
@@ -101,7 +110,7 @@ export default {
         maxStepCount: this.maxTestCount
       }
 
-      this.areTheSameAction(same, this.getReferenceTest, additionalData)
+      this.areTheSameAction(same, this.getRandomTest, additionalData)
     }
   }
 }

+ 14 - 0
src/views/Experiments/AreSameImagesReference.vue

@@ -59,6 +59,7 @@
 <script>
 import ExperimentBlock from '@/components/ExperimentBlock.vue'
 import ExperimentBaseAreSameImages from '@/mixins/ExperimentBaseAreSameImages'
+import { rand } from '@/functions'
 
 export default {
   name: 'AreSameImagesReference',
@@ -95,6 +96,19 @@ export default {
   },
 
   methods: {
+    // Get a test with random qualities
+    getReferenceTest() {
+      // Randomly choose which is the reference image (0 = left, 1 = right)
+      const isReferenceLeft = rand(0, 1) === 0
+      // Randomly choose a quality for the other image
+      const randomQuality = this.qualities[rand(0, this.qualities.length - 1)]
+
+      const res = [this.qualities[this.qualities.length - 1], randomQuality]
+      this.referenceImagePosition = isReferenceLeft ? 'left' : 'right'
+      const table = isReferenceLeft ? res : res.reverse()
+      return this.getTest(table[0], table[1])
+    },
+
     // generate next action and save data
     async nextAction(same) {
       let additionalData = {