PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
learnpress / assets / src / apps / js / frontend / quiz / components / meta / index.js

index.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.9, at assets/src/apps/js/frontend/quiz/components/meta/index.js

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Quiz Meta.
3 * Edit: Use React Hook.
4 *
5 * @author Nhamdv - ThimPress
6 */
7 import { select } from '@wordpress/data';
8 import { __ } from '@wordpress/i18n';
9
10 import { default as formatDuration } from '../duration';
11 const { Hook } = LP;
12
13 const Meta = () => {
14 const getData = ( attr ) => {
15 return select( 'learnpress/quiz' ).getData( attr );
16 };
17
18 const metaFields = Hook.applyFilters( 'quiz-meta-fields', {
19 duration: {
20 title: __( 'Duration:', 'learnpress' ),
21 name: 'duration',
22 content: formatDuration( getData( 'duration' ) ) || '--',
23 },
24 passingGrade: {
25 title: __( 'Passing grade:', 'learnpress' ),
26 name: 'passing-grade',
27 content: getData( 'passingGrade' ) || '--',
28 },
29 questionsCount: {
30 title: __( 'Questions:', 'learnpress' ),
31 name: 'questions-count',
32 content: getData( 'questionIds' ) ? getData( 'questionIds' ).length : 0,
33 },
34 } );
35
36 return (
37 metaFields && (
38 <>
39 <ul className="quiz-intro">
40 { Object.values( metaFields ).map( ( field, i ) => {
41 const id = field.name || i;
42
43 return (
44 <li key={ `quiz-intro-field-${ i }` } className={ `quiz-intro-item quiz-intro-item--${ id }` }>
45 <div className="quiz-intro-item__title" dangerouslySetInnerHTML={ { __html: field.title } } />
46 <span className="quiz-intro-item__content" dangerouslySetInnerHTML={ { __html: field.content } } />
47 </li>
48 );
49 } ) }
50 </ul>
51 </>
52 )
53 );
54 };
55
56 export default Meta;
57