Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
422 changes: 387 additions & 35 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'"
},
"dependencies": {
"@adapttive/vue-markdown": "^4.0.2",
"axios": "^1.7.4",
"bootstrap-vue": "^2.23.1",
"bowser": "^2.11.0",
Expand All @@ -23,7 +24,6 @@
"msr": "^1.3.4",
"vue": "^2.7.16",
"vue-i18n": "^8.28.2",
"@adapttive/vue-markdown": "^4.0.2",
"vue-multiselect": "^2.1.9",
"vue-router": "^3.6.5",
"vue-slider-component": "^3.2.24",
Expand All @@ -33,6 +33,7 @@
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/eslint-parser": "^7.24.1",
"@intlify/vue-i18n-loader": "^3.3.0",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-plugin-e2e-cypress": "^5.0.8",
Expand All @@ -42,9 +43,9 @@
"@vue/cli-plugin-vuex": "~5.0.8",
"@vue/cli-service": "^5.0.8",
"@vue/test-utils": "^1.0.3",
"@babel/eslint-parser": "^7.24.1",
"eslint": "^7.32.0",
"@vue/vue2-jest": "^27.0.0",
"cypress": "^13.7.2",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^7.20.0",
"vue-cli-plugin-i18n": "^2.3.2",
"vue-template-compiler": "^2.7.16"
Expand Down
164 changes: 84 additions & 80 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,16 @@ export default {
_.map(eachActivityList, (itemObj) => {
const newObj = { ...itemObj };
if (itemObj['@type'] === 'reproschema:Response') {
if (itemObj.value instanceof Blob) {
if (itemObj.value instanceof Blob && itemObj.mimeType == "audio/wav") {
const keyStrings = (itemObj.isAbout.split('/'));
const rId = itemObj['@id'].split('uuid:')[1];
jszip.folder(fileName).file(`${keyStrings[keyStrings.length-1]}-${rId}.wav`, itemObj.value);
newObj.value = `${keyStrings[keyStrings.length-1]}-${rId}.wav`;
jszip.folder(fileName).file(`${keyStrings[keyStrings.length-1]}-${rId}.wav`, itemObj.value); //changed from wav
newObj.value = `${keyStrings[keyStrings.length-1]}-${rId}.wav`; //changed from wav
} else if (itemObj.value instanceof Blob && itemObj.mimeType == "video/mp4") {
const keyStrings = (itemObj.isAbout.split('/'));
const rId = itemObj['@id'].split('uuid:')[1];
jszip.folder(fileName).file(`${keyStrings[keyStrings.length-1]}-${rId}.mp4`, itemObj.value); //changed from wav
newObj.value = `${keyStrings[keyStrings.length-1]}-${rId}.mp4`; //changed from wav
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for handling audio/wav and video/mp4 blobs is duplicated. This can be refactored to be more DRY by extracting the common parts. Also, it's a good practice to use === for strict equality checks.

            if (itemObj.value instanceof Blob && (itemObj.mimeType === "audio/wav" || itemObj.mimeType === "video/mp4")) {
              const keyStrings = (itemObj.isAbout.split('/'));
              const rId = itemObj['@id'].split('uuid:')[1];
              const extension = itemObj.mimeType === "audio/wav" ? "wav" : "mp4";
              const filename = `${keyStrings[keyStrings.length - 1]}-${rId}.${extension}`;
              jszip.folder(fileName).file(filename, itemObj.value);
              newObj.value = filename;
            }

}
activityData.push(newObj);
Expand Down Expand Up @@ -552,81 +557,6 @@ export default {
});
},
},
watch: {
$route() {
if (this.$route.params.id !== undefined) {
this.$store.dispatch('setActivityIndex', this.$route.params.id);
}
},
visibilityConditions: {
handler(newC) {
if (!_.isEmpty(newC)) {
this.setVisbility();
}
},
deep: true,
},
},
created() {
const url = this.$route.query.url;
if (url) {
this.protocolUrl = url;
}
this.$store.dispatch('getBaseSchema', url).then(() => this.getPrefLabel());
// this.$store.dispatch('getBaseSchema', url);
},
mounted() {
new EmailDecoder('[data-email]');
this.clientSpecs = JSON.stringify(Bowser.parse(window.navigator.userAgent));
this.browserType = Bowser.parse(window.navigator.userAgent).browser.name;
if (config.checkMediaPermission) {
this.checkPermission();
}
if (this.$route.query.lang) {
this.selected_language = this.$route.query.lang;
i18n.locale = this.selected_language;
} else this.selected_language = 'en';

if (this.$route.query.uid) {
// console.log(407, this.$route.query.uid);
this.$store.dispatch('saveParticipantId', this.$route.query.uid);
} else if (config.generateRandomUid) {
this.$store.dispatch('saveParticipantId', uuidv4());
}
if (this.$route.params.id) {
this.$store.dispatch('setActivityIndex', this.$route.params.id);
}
axios.get('https://raw.githubusercontent.com/ReproNim/reproschema-library/master/resources/languages.json').then((resp) => {
this.langMap = resp.data;
});
this.$store.dispatch('setParticipantUUID', uuidv4()); // set participant UUID for the current user
if (this.$route.query.expiry_time) {
this.$store.dispatch('setExpiryMinutes', this.$route.query.expiry_time);
}
if (this.$route.query.auth_token) {
this.$store.dispatch('setAuthToken', this.$route.query.auth_token);
}
if (!_.isEmpty(this.$route.query)) {
this.$store.dispatch('setQueryParameters', this.$route.query);
}

// const formData = new FormData();
// const TOKEN = this.$store.getters.getAuthToken;
// if (TOKEN) {
// formData.append('file', null);
// formData.append('auth_token', `${TOKEN}`);
// axios.post(`${config.backendServer}/submit`, formData, {
// 'Content-Type': 'multipart/form-data',
// }).then((res) => {
// // console.log('SUCCESS!!', res.status);
// })
// .catch((e) => {
// if (e.response.status === 403) {
// this.invalidToken = true;
// }
// });
// }
},
computed: {
accessDeniedPath() {
let path = require('./assets/403-Access-Forbidden-HTML-Template.gif');
Expand Down Expand Up @@ -704,6 +634,7 @@ export default {
if (!_.isEmpty(this.$store.state.schema)) {
const order = _.map(this.$store.state.schema['http://schema.repronim.org/order'][0]['@list'],
u => u['@id']);
console.log(order)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This console.log appears to be for debugging and should be removed before merging.

return order;
}
return [];
Expand Down Expand Up @@ -817,6 +748,81 @@ export default {
return this.$store.getters.getParticipantId;
},
},
mounted() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The component options (mounted, watch, created) are not in the standard order recommended by the Vue style guide. For better maintainability and consistency, they should be reordered. The recommended order is generally name, components, props, data, computed, watch, lifecycle hooks (created, mounted, etc.), then methods. In this case, created should come before mounted.

new EmailDecoder('[data-email]');
this.clientSpecs = JSON.stringify(Bowser.parse(window.navigator.userAgent));
this.browserType = Bowser.parse(window.navigator.userAgent).browser.name;
if (config.checkMediaPermission) {
this.checkPermission();
}
if (this.$route.query.lang) {
this.selected_language = this.$route.query.lang;
i18n.locale = this.selected_language;
} else this.selected_language = 'en';

if (this.$route.query.uid) {
// console.log(407, this.$route.query.uid);
this.$store.dispatch('saveParticipantId', this.$route.query.uid);
} else if (config.generateRandomUid) {
this.$store.dispatch('saveParticipantId', uuidv4());
}
if (this.$route.params.id) {
this.$store.dispatch('setActivityIndex', this.$route.params.id);
}
axios.get('https://raw.githubusercontent.com/ReproNim/reproschema-library/master/resources/languages.json').then((resp) => {
this.langMap = resp.data;
});
this.$store.dispatch('setParticipantUUID', uuidv4()); // set participant UUID for the current user
if (this.$route.query.expiry_time) {
this.$store.dispatch('setExpiryMinutes', this.$route.query.expiry_time);
}
if (this.$route.query.auth_token) {
this.$store.dispatch('setAuthToken', this.$route.query.auth_token);
}
if (!_.isEmpty(this.$route.query)) {
this.$store.dispatch('setQueryParameters', this.$route.query);
}

// const formData = new FormData();
// const TOKEN = this.$store.getters.getAuthToken;
// if (TOKEN) {
// formData.append('file', null);
// formData.append('auth_token', `${TOKEN}`);
// axios.post(`${config.backendServer}/submit`, formData, {
// 'Content-Type': 'multipart/form-data',
// }).then((res) => {
// // console.log('SUCCESS!!', res.status);
// })
// .catch((e) => {
// if (e.response.status === 403) {
// this.invalidToken = true;
// }
// });
// }
},
watch: {
$route() {
if (this.$route.params.id !== undefined) {
this.$store.dispatch('setActivityIndex', this.$route.params.id);
}
},
visibilityConditions: {
handler(newC) {
if (!_.isEmpty(newC)) {
this.setVisbility();
}
},
deep: true,
},
},
created() {
const url = this.$route.query.url;
if (url) {
this.protocolUrl = url;
}
this.$store.dispatch('getBaseSchema', url).then(() => this.getPrefLabel());
// this.$store.dispatch('getBaseSchema', url);
}
};
</script>

Expand Down Expand Up @@ -943,5 +949,3 @@ export default {


</style>


91 changes: 42 additions & 49 deletions src/components/InputSelector/InputSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,66 +23,59 @@
</div>

<div v-else-if="inputType === 'audioCheck'">
<AudioRecord
<MediaRecord
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"/>
</div>

<!-- If type is audioRecord -->
<div v-else-if="inputType === 'audioRecord'">
<AudioRecord
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"/>
</div>

<div v-else-if="inputType === 'audioPassageRecord'">
<AudioRecord
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"/>
:init="init"
:audio="true"
:visualizer="true"
v-on:valueChanged="sendData"/>
</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The v-else-if blocks for audioCheck and audioVideoCheck are identical. You can combine them into a single block to reduce code duplication.

    <div v-else-if="inputType === 'audioCheck' || inputType === 'audioVideoCheck'">
      <MediaRecord
        :constraints="valueConstraints"
        :selected_language="selected_language"
        :init="init"
        :audio="true"
        :visualizer="true"
        v-on:valueChanged="sendData"/>
    </div>


<!-- If type is audioImageRecord -->
<div v-else-if="inputType === 'audioImageRecord'">
<AudioRecord
<div v-else-if="inputType === 'videoCheck'">
<MediaRecord
:constraints="valueConstraints"
:fieldData="fieldData"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"
mode="audioImageRecord" />
:init="init"
:audio="false"
:visualizer="false"
v-on:valueChanged="sendData"/>
</div>

<!-- If type is audioRecordNumberTask -->
<div v-else-if="inputType === 'audioRecordNumberTask'">
<AudioRecord
<div v-else-if="inputType === 'audioVideoCheck'">
<MediaRecord
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"
mode="audioRecordNumberTask" />
:init="init"
:audio="true"
:visualizer="true"
v-on:valueChanged="sendData"/>
</div>

<!-- If type is audioRecordAudioTask -->
<div v-else-if="inputType === 'audioRecordAudioTask'">
<AudioRecord
<div v-else-if="inputType.startsWith('audio')">
<MediaRecord
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"
:init="init"
:audio="true"
:visualizer="true"
:mode="inputType"
:fieldData="fieldData"
mode="audioRecordAudioTask" />
v-on:valueChanged="sendData"/>
</div>

<!-- If type is audioRecordNoStop -->
<div v-else-if="inputType === 'audioRecordNoStop'">
<AudioRecord
<div v-else-if="inputType.startsWith('video')">
<MediaRecord
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"
mode="audioRecordNoStop" />
:init="init"
:audio="false"
:visualizer="false"
:mode="inputType"
:fieldData="fieldData"
v-on:valueChanged="sendData"/>
</div>


<!-- If type is text -->
<div v-else-if="inputType === 'text'">
<TextInput
Expand Down Expand Up @@ -153,7 +146,7 @@
:constraints="valueConstraints"
:selected_language="selected_language"
:init="init" v-on:valueChanged="sendData"/>
</div>
</div>

<!-- If type is date -->
<div v-else-if="inputType === 'date' || inputType === 'year'">
Expand Down Expand Up @@ -248,20 +241,19 @@

<script>
import Radio from '../Inputs/WebRadio/';
import AudioRecord from '../Inputs/WebAudioRecord/';
import MediaRecord from '../Inputs/MediaRecord/';
import TextInput from '../Inputs/WebTextInput/';
import TextArea from '../Inputs/TextArea/';
import IntegerInput from '../Inputs/WebIntegerInput/';
import FloatInput from '../Inputs/WebFloatInput/';
import RangeInput from '../Inputs/RangeInput/';
import DateInput from '../Inputs/YearInput/';
import DocumentUpload from '../Inputs/DocumentUpload';
import MultiTextInput from '../Inputs/MultiTextInput';
import SliderInput from '../Inputs/SliderInput';
import TimeRange from '../Inputs/TimeRange';
import SelectInput from '../Inputs/SelectInput';
// import AudioCheck from '../Inputs/AudioCheck';
import StaticReadOnly from '../Inputs/StaticReadOnly';
import DocumentUpload from '../Inputs/DocumentUpload/';
import MultiTextInput from '../Inputs/MultiTextInput/';
import SliderInput from '../Inputs/SliderInput/';
import TimeRange from '../Inputs/TimeRange/';
import SelectInput from '../Inputs/SelectInput/';
import StaticReadOnly from '../Inputs/StaticReadOnly/';
import SaveData from '../Inputs/SaveData/SaveData';
import StudySign from '../StudySign/StudySign';
// import Static from '../Inputs/Static';
Expand Down Expand Up @@ -314,7 +306,7 @@ export default {
StudySign,
SaveData,
Radio,
AudioRecord,
MediaRecord,
TextInput,
TextArea,
EmailInput,
Expand Down Expand Up @@ -372,3 +364,4 @@ export default {
}

</style>

Loading