| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin question editor: editor template. |
| 4 |
* |
| 5 |
* @since 3.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
$question = LP_Question::get_question(); |
| 9 |
|
| 10 |
learn_press_admin_view( 'question/actions' ); |
| 11 |
learn_press_admin_view( 'question/answer' ); |
| 12 |
learn_press_admin_view( 'question/fill-in-blanks' ); |
| 13 |
?> |
| 14 |
|
| 15 |
<div id="admin-editor-lp_question"> |
| 16 |
<div class="lp-place-holder"> |
| 17 |
<div class="line-heading"></div> |
| 18 |
|
| 19 |
<div class="line-sm"></div> |
| 20 |
<div class="line-xs"></div> |
| 21 |
|
| 22 |
<div class="line-df"></div> |
| 23 |
<div class="line-lgx"></div> |
| 24 |
<div class="line-lg"></div> |
| 25 |
|
| 26 |
<div class="line-df"></div> |
| 27 |
<div class="line-lg"></div> |
| 28 |
<div class="line-lgx"></div> |
| 29 |
</div> |
| 30 |
</div> |
| 31 |
|
| 32 |
<script type="text/x-template" id="tmpl-lp-question-editor"> |
| 33 |
<div> |
| 34 |
<template v-if="!supportAnswerOptions"> |
| 35 |
<?php do_action( 'learn-press/question-editor/question-js-component', $question ); ?> |
| 36 |
</template> |
| 37 |
<template v-else> |
| 38 |
<div id="admin-editor-lp_question" :class="['lp-admin-editor learn-press-box-data', type]"> |
| 39 |
<lp-question-actions :type="type" @changeType="changeType"></lp-question-actions> |
| 40 |
|
| 41 |
<template v-if="isFillInBlank"> |
| 42 |
<lp-fib-question-answer :type="type" :answers="answers"></lp-fib-question-answer> |
| 43 |
</template> |
| 44 |
<template v-else> |
| 45 |
<lp-question-answer :type="type" :answers="answers"></lp-question-answer> |
| 46 |
</template> |
| 47 |
</div> |
| 48 |
</template> |
| 49 |
</div> |
| 50 |
</script> |
| 51 |
|
| 52 |
<script type="text/javascript"> |
| 53 |
jQuery( function($) { |
| 54 |
var $store = window.LP_Question_Store; |
| 55 |
|
| 56 |
window.$Vue = window.$Vue || Vue; |
| 57 |
|
| 58 |
$Vue.component('lp-question-editor', { |
| 59 |
template: '#tmpl-lp-question-editor', |
| 60 |
mounted: function() { |
| 61 |
var vm = this; |
| 62 |
|
| 63 |
vm.$watch('type', function() { |
| 64 |
}); |
| 65 |
|
| 66 |
if(lpAdminSettings.screen.action === 'add') { |
| 67 |
$store.dispatch('changeQuestionType', { |
| 68 |
type: vm.type |
| 69 |
}); |
| 70 |
} |
| 71 |
}, |
| 72 |
computed: { |
| 73 |
type: function() { |
| 74 |
return $store.getters['type']['key']; |
| 75 |
}, |
| 76 |
isFillInBlank: function() { |
| 77 |
return this.type === 'fill_in_blanks'; |
| 78 |
}, |
| 79 |
supportAnswerOptions: function () { |
| 80 |
return $store.getters['supportAnswerOptions'].indexOf( this.type ) !== -1; |
| 81 |
}, |
| 82 |
answers: function() { |
| 83 |
return $store.getters['answers']; |
| 84 |
} |
| 85 |
}, |
| 86 |
created: function() { |
| 87 |
}, |
| 88 |
methods: { |
| 89 |
changeType: function (type) { |
| 90 |
$store.dispatch('changeQuestionType', { |
| 91 |
question: { |
| 92 |
title: $('input[name=post_title]').val(), |
| 93 |
content: $('textarea[name=content]').val() |
| 94 |
}, |
| 95 |
type: type |
| 96 |
}); |
| 97 |
} |
| 98 |
} |
| 99 |
}); |
| 100 |
}); |
| 101 |
</script> |
| 102 |
|