← All changes
|
assets/src/apps/js/admin/editor/actions/question.js
+113
-113
4.3.9
→
4.4.9
View file →
| @@ -1,113 +1,113 @@ | ||
| 1 | -const Question = { | |
| 2 | - changeQuestionType( context, payload ) { | |
| 3 | - const draftQuestion = undefined !== payload.question ? payload.question : ''; | |
| 4 | - | |
| 5 | - LP.Request( { | |
| 6 | - type: 'change-question-type', | |
| 7 | - question_type: payload.type, | |
| 8 | - draft_question: context.getters.autoDraft ? draftQuestion : '', | |
| 9 | - } ).then( function( response ) { | |
| 10 | - const result = response.body; | |
| 11 | - | |
| 12 | - if ( result.success ) { | |
| 13 | - context.commit( 'UPDATE_AUTO_DRAFT_STATUS', false ); | |
| 14 | - context.commit( 'CHANGE_QUESTION_TYPE', result.data ); | |
| 15 | - } | |
| 16 | - } ); | |
| 17 | - }, | |
| 18 | - | |
| 19 | - updateAnswersOrder( context, order ) { | |
| 20 | - LP.Request( { | |
| 21 | - type: 'sort-answer', | |
| 22 | - order, | |
| 23 | - } ).then( | |
| 24 | - function( response ) { | |
| 25 | - const result = response.body; | |
| 26 | - if ( result.success ) { | |
| 27 | - // context.commit('SET_ANSWERS', result.data); | |
| 28 | - } | |
| 29 | - } | |
| 30 | - ); | |
| 31 | - }, | |
| 32 | - | |
| 33 | - updateAnswerTitle( context, answer ) { | |
| 34 | - if ( typeof answer.question_answer_id == 'undefined' ) { | |
| 35 | - return; | |
| 36 | - } | |
| 37 | - | |
| 38 | - answer = JSON.stringify( answer ); | |
| 39 | - | |
| 40 | - LP.Request( { | |
| 41 | - type: 'update-answer-title', | |
| 42 | - answer, | |
| 43 | - } ); | |
| 44 | - }, | |
| 45 | - | |
| 46 | - updateCorrectAnswer( context, correct ) { | |
| 47 | - LP.Request( { | |
| 48 | - type: 'change-correct', | |
| 49 | - correct: JSON.stringify( correct ), | |
| 50 | - } ).then( | |
| 51 | - function( response ) { | |
| 52 | - const result = response.body; | |
| 53 | - if ( result.success ) { | |
| 54 | - context.commit( 'UPDATE_ANSWERS', result.data ); | |
| 55 | - context.commit( 'UPDATE_AUTO_DRAFT_STATUS', false ); | |
| 56 | - } | |
| 57 | - } | |
| 58 | - ); | |
| 59 | - }, | |
| 60 | - | |
| 61 | - deleteAnswer( context, payload ) { | |
| 62 | - context.commit( 'DELETE_ANSWER', payload.id ); | |
| 63 | - LP.Request( { | |
| 64 | - type: 'delete-answer', | |
| 65 | - answer_id: payload.id, | |
| 66 | - } ).then( | |
| 67 | - function( response ) { | |
| 68 | - const result = response.body; | |
| 69 | - | |
| 70 | - if ( result.success ) { | |
| 71 | - context.commit( 'SET_ANSWERS', result.data ); | |
| 72 | - } else { | |
| 73 | - // notice error | |
| 74 | - } | |
| 75 | - } ); | |
| 76 | - }, | |
| 77 | - | |
| 78 | - newAnswer( context, data ) { | |
| 79 | - context.commit( 'ADD_NEW_ANSWER', data.answer ); | |
| 80 | - LP.Request( { | |
| 81 | - type: 'new-answer', | |
| 82 | - } ).then( | |
| 83 | - function( response ) { | |
| 84 | - const result = response.body; | |
| 85 | - | |
| 86 | - if ( result.success ) { | |
| 87 | - context.commit( 'UPDATE_ANSWERS', result.data ); | |
| 88 | - } else { | |
| 89 | - // notice error | |
| 90 | - } | |
| 91 | - } ); | |
| 92 | - }, | |
| 93 | - | |
| 94 | - newRequest( context ) { | |
| 95 | - context.commit( 'INCREASE_NUMBER_REQUEST' ); | |
| 96 | - context.commit( 'UPDATE_STATUS', 'loading' ); | |
| 97 | - | |
| 98 | - window.onbeforeunload = function() { | |
| 99 | - return ''; | |
| 100 | - }; | |
| 101 | - }, | |
| 102 | - | |
| 103 | - requestCompleted( context, status ) { | |
| 104 | - context.commit( 'DECREASE_NUMBER_REQUEST' ); | |
| 105 | - | |
| 106 | - if ( context.getters.currentRequest === 0 ) { | |
| 107 | - context.commit( 'UPDATE_STATUS', status ); | |
| 108 | - window.onbeforeunload = null; | |
| 109 | - } | |
| 110 | - }, | |
| 111 | -}; | |
| 112 | - | |
| 113 | -export default Question; | |
| 1 | +const Question = { | |
| 2 | + changeQuestionType( context, payload ) { | |
| 3 | + const draftQuestion = undefined !== payload.question ? payload.question : ''; | |
| 4 | + | |
| 5 | + LP.Request( { | |
| 6 | + type: 'change-question-type', | |
| 7 | + question_type: payload.type, | |
| 8 | + draft_question: context.getters.autoDraft ? draftQuestion : '', | |
| 9 | + } ).then( function( response ) { | |
| 10 | + const result = response.body; | |
| 11 | + | |
| 12 | + if ( result.success ) { | |
| 13 | + context.commit( 'UPDATE_AUTO_DRAFT_STATUS', false ); | |
| 14 | + context.commit( 'CHANGE_QUESTION_TYPE', result.data ); | |
| 15 | + } | |
| 16 | + } ); | |
| 17 | + }, | |
| 18 | + | |
| 19 | + updateAnswersOrder( context, order ) { | |
| 20 | + LP.Request( { | |
| 21 | + type: 'sort-answer', | |
| 22 | + order, | |
| 23 | + } ).then( | |
| 24 | + function( response ) { | |
| 25 | + const result = response.body; | |
| 26 | + if ( result.success ) { | |
| 27 | + // context.commit('SET_ANSWERS', result.data); | |
| 28 | + } | |
| 29 | + } | |
| 30 | + ); | |
| 31 | + }, | |
| 32 | + | |
| 33 | + updateAnswerTitle( context, answer ) { | |
| 34 | + if ( typeof answer.question_answer_id == 'undefined' ) { | |
| 35 | + return; | |
| 36 | + } | |
| 37 | + | |
| 38 | + answer = JSON.stringify( answer ); | |
| 39 | + | |
| 40 | + LP.Request( { | |
| 41 | + type: 'update-answer-title', | |
| 42 | + answer, | |
| 43 | + } ); | |
| 44 | + }, | |
| 45 | + | |
| 46 | + updateCorrectAnswer( context, correct ) { | |
| 47 | + LP.Request( { | |
| 48 | + type: 'change-correct', | |
| 49 | + correct: JSON.stringify( correct ), | |
| 50 | + } ).then( | |
| 51 | + function( response ) { | |
| 52 | + const result = response.body; | |
| 53 | + if ( result.success ) { | |
| 54 | + context.commit( 'UPDATE_ANSWERS', result.data ); | |
| 55 | + context.commit( 'UPDATE_AUTO_DRAFT_STATUS', false ); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + ); | |
| 59 | + }, | |
| 60 | + | |
| 61 | + deleteAnswer( context, payload ) { | |
| 62 | + context.commit( 'DELETE_ANSWER', payload.id ); | |
| 63 | + LP.Request( { | |
| 64 | + type: 'delete-answer', | |
| 65 | + answer_id: payload.id, | |
| 66 | + } ).then( | |
| 67 | + function( response ) { | |
| 68 | + const result = response.body; | |
| 69 | + | |
| 70 | + if ( result.success ) { | |
| 71 | + context.commit( 'SET_ANSWERS', result.data ); | |
| 72 | + } else { | |
| 73 | + // notice error | |
| 74 | + } | |
| 75 | + } ); | |
| 76 | + }, | |
| 77 | + | |
| 78 | + newAnswer( context, data ) { | |
| 79 | + context.commit( 'ADD_NEW_ANSWER', data.answer ); | |
| 80 | + LP.Request( { | |
| 81 | + type: 'new-answer', | |
| 82 | + } ).then( | |
| 83 | + function( response ) { | |
| 84 | + const result = response.body; | |
| 85 | + | |
| 86 | + if ( result.success ) { | |
| 87 | + context.commit( 'UPDATE_ANSWERS', result.data ); | |
| 88 | + } else { | |
| 89 | + // notice error | |
| 90 | + } | |
| 91 | + } ); | |
| 92 | + }, | |
| 93 | + | |
| 94 | + newRequest( context ) { | |
| 95 | + context.commit( 'INCREASE_NUMBER_REQUEST' ); | |
| 96 | + context.commit( 'UPDATE_STATUS', 'loading' ); | |
| 97 | + | |
| 98 | + window.onbeforeunload = function() { | |
| 99 | + return ''; | |
| 100 | + }; | |
| 101 | + }, | |
| 102 | + | |
| 103 | + requestCompleted( context, status ) { | |
| 104 | + context.commit( 'DECREASE_NUMBER_REQUEST' ); | |
| 105 | + | |
| 106 | + if ( context.getters.currentRequest === 0 ) { | |
| 107 | + context.commit( 'UPDATE_STATUS', status ); | |
| 108 | + window.onbeforeunload = null; | |
| 109 | + } | |
| 110 | + }, | |
| 111 | +}; | |
| 112 | + | |
| 113 | +export default Question; | |