| 1 |
const { Hook } = LP; |
| 2 |
|
| 3 |
export const classNames = { |
| 4 |
Quiz: { |
| 5 |
Result: [ 'quiz-result' ], |
| 6 |
Content: [ 'quiz-content' ], |
| 7 |
Questions: [ 'quiz-questions' ], |
| 8 |
Buttons: [ 'quiz-buttons' ], |
| 9 |
Attempts: [ 'quiz-attempts' ], |
| 10 |
}, |
| 11 |
}; |
| 12 |
|
| 13 |
const questionCheckers = { |
| 14 |
single_choice() { |
| 15 |
|
| 16 |
}, |
| 17 |
|
| 18 |
multi_choice() { |
| 19 |
|
| 20 |
}, |
| 21 |
|
| 22 |
true_or_false() { |
| 23 |
|
| 24 |
}, |
| 25 |
}; |
| 26 |
|
| 27 |
export const isQuestionCorrect = { |
| 28 |
fill_in_blank() { |
| 29 |
return true; |
| 30 |
}, |
| 31 |
}; |
| 32 |
|
| 33 |
/** |
| 34 |
* Question blocks. |
| 35 |
* |
| 36 |
* Allow to sort the blocks of question |
| 37 |
*/ |
| 38 |
export const questionBlocks = function() { |
| 39 |
return LP.Hook.applyFilters( 'question-blocks', [ 'title', 'content', 'answer-options', 'explanation', 'hint', 'buttons' ] ); |
| 40 |
}; |
| 41 |
|
| 42 |
export const questionFooterButtons = function() { |
| 43 |
return LP.Hook.applyFilters( 'question-footer-buttons', [ 'instant-check' ] ); |
| 44 |
}; |
| 45 |
|
| 46 |
export const questionTitleParts = function() { |
| 47 |
return LP.Hook.applyFilters( 'question-title-parts', [ 'index', 'title', 'hint', 'edit-permalink' ] ); |
| 48 |
}; |
| 49 |
|
| 50 |
export const questionChecker = function( type ) { |
| 51 |
const c = LP.Hook.applyFilters( 'question-checkers', questionCheckers ); |
| 52 |
|
| 53 |
return type && c[ type ] ? c[ type ] : function() { |
| 54 |
return {}; |
| 55 |
}; |
| 56 |
}; |
| 57 |
|
| 58 |
export const quizStartBlocks = function() { |
| 59 |
const blocks = Hook.applyFilters( 'quiz-start-blocks', { |
| 60 |
meta: true, |
| 61 |
description: true, |
| 62 |
custom: 'Hello', |
| 63 |
} ); |
| 64 |
}; |
| 65 |
|