Skip to content

Commit

Permalink
add free text quiz type, hint responses
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcfadden committed Oct 11, 2021
1 parent 7a29178 commit 3da1c13
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 19 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 29 additions & 3 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@
"/css/app.css": "/css/app.css",
"/css/edit.css": "/css/edit.css",
"/js/edit.js": "/js/edit.js",
"/js/edit.18adf069c7f6893e2a40.hot-update.js": "/js/edit.18adf069c7f6893e2a40.hot-update.js",
"/js/app.834b67ec4678ab660f98.hot-update.js": "/js/app.834b67ec4678ab660f98.hot-update.js",
"/js/app.6c2a7390c0b62bcc8dbc.hot-update.js": "/js/app.6c2a7390c0b62bcc8dbc.hot-update.js"
"/js/edit.cc37702bd3a8fed87c2e.hot-update.js": "/js/edit.cc37702bd3a8fed87c2e.hot-update.js",
"/js/edit.f33ae8d34f04cb23a4e6.hot-update.js": "/js/edit.f33ae8d34f04cb23a4e6.hot-update.js",
"/js/edit.1b296d6ef89334adca0a.hot-update.js": "/js/edit.1b296d6ef89334adca0a.hot-update.js",
"/js/edit.1a039008e67c5c7597b0.hot-update.js": "/js/edit.1a039008e67c5c7597b0.hot-update.js",
"/js/edit.d0a4db5f2df9076edd46.hot-update.js": "/js/edit.d0a4db5f2df9076edd46.hot-update.js",
"/js/edit.c4e76b77031d635fef5c.hot-update.js": "/js/edit.c4e76b77031d635fef5c.hot-update.js",
"/js/edit.0ec9ce7b2dad0a227e69.hot-update.js": "/js/edit.0ec9ce7b2dad0a227e69.hot-update.js",
"/js/edit.8e0ec146f068eaf20109.hot-update.js": "/js/edit.8e0ec146f068eaf20109.hot-update.js",
"/js/edit.798c8f65b771e3b081ba.hot-update.js": "/js/edit.798c8f65b771e3b081ba.hot-update.js",
"/js/edit.c53f78d517e4fc31be72.hot-update.js": "/js/edit.c53f78d517e4fc31be72.hot-update.js",
"/js/edit.a98f989a75efbc66fce0.hot-update.js": "/js/edit.a98f989a75efbc66fce0.hot-update.js",
"/js/edit.02850a0b82c27267ce33.hot-update.js": "/js/edit.02850a0b82c27267ce33.hot-update.js",
"/js/edit.0af1bd00dc544c208213.hot-update.js": "/js/edit.0af1bd00dc544c208213.hot-update.js",
"/js/edit.a55029b5d8c952fc4995.hot-update.js": "/js/edit.a55029b5d8c952fc4995.hot-update.js",
"/js/app.1ff6c189f7a6e8e7000c.hot-update.js": "/js/app.1ff6c189f7a6e8e7000c.hot-update.js",
"/js/app.5853df025738ec767dda.hot-update.js": "/js/app.5853df025738ec767dda.hot-update.js",
"/js/app.d18ed89baa600bef7053.hot-update.js": "/js/app.d18ed89baa600bef7053.hot-update.js",
"/js/edit.0abc3007e9f9cb001067.hot-update.js": "/js/edit.0abc3007e9f9cb001067.hot-update.js",
"/js/app.66d8ea77bbbfe75e7850.hot-update.js": "/js/app.66d8ea77bbbfe75e7850.hot-update.js",
"/js/app.370d7acb9b8ce9d2a546.hot-update.js": "/js/app.370d7acb9b8ce9d2a546.hot-update.js",
"/js/app.bc517a8a0652b570da0e.hot-update.js": "/js/app.bc517a8a0652b570da0e.hot-update.js",
"/js/edit.1fb52286e84601ad2866.hot-update.js": "/js/edit.1fb52286e84601ad2866.hot-update.js",
"/js/edit.50516b4cd21c54d34f75.hot-update.js": "/js/edit.50516b4cd21c54d34f75.hot-update.js",
"/js/app.7f3bb4b92609724f1ccb.hot-update.js": "/js/app.7f3bb4b92609724f1ccb.hot-update.js",
"/js/app.7b785462b4a0a7aca00f.hot-update.js": "/js/app.7b785462b4a0a7aca00f.hot-update.js",
"/js/edit.7b0f8223a26165269657.hot-update.js": "/js/edit.7b0f8223a26165269657.hot-update.js",
"/js/app.af4d2f66f8939002ec43.hot-update.js": "/js/app.af4d2f66f8939002ec43.hot-update.js",
"/js/edit.3919c3ddf5bc030b7c04.hot-update.js": "/js/edit.3919c3ddf5bc030b7c04.hot-update.js",
"/js/app.22c8cc6d83de617546cf.hot-update.js": "/js/app.22c8cc6d83de617546cf.hot-update.js"
}
52 changes: 43 additions & 9 deletions resources/js/components/Quiz.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@
<div>

<p>{{ stage.questionText[$i18n.locale] }}</p>
<div class="form-check" v-for="(response,index) in stage.responses" :key="index">
<label class="form-check-label">
<input type="radio" class="form-check-input" :value="response" v-model="selectedAnswer">
{{ response.text[$i18n.locale] }}
</label>

<div v-if="stage.quizType == 'multiple_choice'">
<div class="form-check" v-for="(response,index) in stage.responses" :key="index" >
<label class="form-check-label">
<input type="radio" class="form-check-input" :value="response" v-model="selectedAnswer">
{{ response.text[$i18n.locale] }}
</label>
</div>
</div>
<div v-else>
<div class="form-group">
<label for="">{{ stage.answerPrompt[$i18n.locale] }}</label>
<input type="text" class="form-control" name="quiz_answer" v-model="selectedAnswer">
</div>
</div>

<p v-if="showHint">
{{ stage.hintText[$i18n.locale]}}
</p>
<button class="btn btn-outline-primary" @click="showHint=true">{{ stage.hintPrompt[$i18n.locale] }}</button>
<button class="btn btn-outline-primary" @click="checkMyAnswer">{{ stage.buttonText[$i18n.locale] }}</button>
<save-alert :showAlert.sync="showAlert"><i class="far fa-check-circle answer align-middle" v-if="correct"></i> <i class="far fa-times-circle answer align-middle" v-if="!correct"></i> </save-alert>

</div>
</template>

Expand All @@ -32,21 +47,40 @@ export default {
return {
selectedAnswer: "",
showAlert: false,
correct: false
correct: false,
showHint: false
}
},
computed: {
},
methods: {
checkMyAnswer: function() {
if(this.selectedAnswer.correct == true) {
this.correct = true;
if(this.stage.quizType == 'multiple_choice') {
if(this.selectedAnswer.correct == true) {
this.correct = true;
}
else {
this.correct = false;
}
}
else if(this.stage.quizType == 'free_text') {
if(this.stage.responses.filter(r => r.text[this.$i18n.locale].toLowerCase().trim() == this.selectedAnswer.toLowerCase().trim()).length > 0) {
this.correct = true;
}
else {
this.correct=false;
}
}
if(this.correct) {
this.showAlert = true;
this.$store.commit('unlockStop', {"stop": this.currentStopId, "text":this.stage.questionText[this.$i18n.locale]});
}
else {
this.correct = false;
this.showAlert = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions resources/js/components/edit/LocationSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ var otherMarkerGroup;
}
targetNavs.forEach(targetPoint => {
if(!targetPoint) {
return;
}
if(!targetPoint.targetPoint) {
return;
}
Expand Down
50 changes: 47 additions & 3 deletions resources/js/components/edit/Quiz.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,57 @@
Quiz Question Text
</language-text>


<div class="form-group row">
<label for="quizType" class="col-sm-1"><b>Quiz Type</b></label>
<div class="col-sm-6 ">
<div class="form-check">
<label class="form-check-label">
<input type="radio" name="quizType" class="form-check-input" v-model="stage.quizType" value="multiple_choice">
Multiple Choice
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" name="quizType" class="form-check-input" v-model="stage.quizType" value="free_text">
Free Text
</label>
</div>
</div>
</div>

<div class="form-group row responseOutline" v-for="(response,index) in stage.responses" :key="index">
<div class="col-sm-12">
<language-text :text="response.text" :languages="languages" :largetext="true">
<div class="col-sm-12 mt-2">
<language-text :text="response.text" :languages="languages" :largetext="isMultipleChoice">
Response
</language-text>
<input type="checkbox" v-model="response.correct" value="1"> Correct
<span v-if="isMultipleChoice">
<input type="checkbox" v-model="response.correct" value="1" > Correct
</span>
</div>
</div>

<button @click="addResponse" class="btn btn-outline-primary"><i class="fas fa-plus"></i> Add response</button>

<language-text :text="stage.hintText" :languages="languages" :largetext="true">
Hint
</language-text>

<div>
<language-text :text="stage.buttonText" :languages="languages" :largetext="false">
Button Text
</language-text>
</div>
<div v-if="!isMultipleChoice">
<language-text :text="stage.answerPrompt" :languages="languages" :largetext="false">
Answer Prompt
</language-text>
</div>
<div >
<language-text :text="stage.hintPrompt" :languages="languages" :largetext="false">
Hint Prompt
</language-text>
</div>
<div>
<input type="checkbox" v-model="stage.requireCorrect" value="1" /> Require Correct Answer to Advance
</div>
Expand All @@ -39,12 +74,21 @@
created() {
if (!this.stage.questionText) {
Vue.set(this.stage, "questionText",{"placeholder": null});
Vue.set(this.stage, "hintText",{"placeholder": null});
Vue.set(this.stage, "quizType","multiple_choice");
Vue.set(this.stage, "responses", []);
Vue.set(this.stage, "requireCorrect", 0);
Vue.set(this.stage, "buttonText", {"placeholder": null, "English": "Check my Answer"});
Vue.set(this.stage, "answerPrompt", {"placeholder": null, "English": "Answer"});
Vue.set(this.stage, "hintPrompt", {"placeholder": null, "English": "Show Hint"});
}
},
computed: {
isMultipleChoice: function() {
return this.stage.quizType == "multiple_choice";
}
},
methods: {
addResponse: function() {
this.stage.responses.push({"text":{"placeholder": null}, "correct":0});
Expand Down

0 comments on commit 3da1c13

Please sign in to comment.