PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 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 All 142 releases
← All changes | assets/src/apps/js/frontend/quiz/components/timer/index.js +11 -13 4.1.7 → 4.4.10 View file →
@@ -8,28 +8,22 @@
8 8
9 9 const Timer = () => {
10 10 const { getData } = select( 'learnpress/quiz' );
11 11 const { submitQuiz } = dispatch( 'learnpress/quiz' );
12 -
13 - const totalTime = getData( 'totalTime' );
12 + let totalTime = getData( 'totalTime' );
14 13 const durationTime = getData( 'duration' );
15 - /* const endTime = getData( 'endTime' );
16 -
17 - const d1 = new Date( endTime.replace( /-/g, '/' ) );
18 - const d2 = new Date();
19 - const tz = new Date().getTimezoneOffset();
20 - const t = parseInt( ( d1.getTime() / 1000 ) - ( ( d2.getTime() / 1000 ) + ( tz * 60 ) ) );*/
21 -
14 + const timeSpendG = getData( 'timeSpend' );
22 15 const [ seconds, setSeconds ] = useState( totalTime );
23 - let [ timeSpend, setTimeSpend ] = useState( 0 );
24 - const limitTime = totalTime > 0;
16 + let [ timeSpend, setTimeSpend ] = useState( timeSpendG );
25 17
26 18 useEffect( () => {
27 19 const myInterval = setInterval( () => {
28 - if ( limitTime ) {
20 + if ( durationTime > 0 ) {
29 21 let remainSeconds = seconds;
30 22 remainSeconds -= 1;
31 23
24 + remainSeconds = wp.hooks.applyFilters( 'js-lp-quiz-remaining_time', remainSeconds, durationTime );
25 +
32 26 if ( remainSeconds > 0 ) {
33 27 setSeconds( remainSeconds );
34 28 timeSpend++;
35 29 setTimeSpend( durationTime - remainSeconds );
@@ -50,8 +44,12 @@
50 44 const formatTime = ( separator = ':' ) => {
51 45 const t = [];
52 46 let m;
53 47
48 + if ( timeSpendG ) {
49 + totalTime = timeSpendG;
50 + }
51 +
54 52 if ( totalTime < 3600 ) {
55 53 t.push( ( seconds - ( seconds % 60 ) ) / 60 );
56 54 t.push( seconds % 60 );
57 55 } else if ( totalTime ) {
@@ -67,9 +65,9 @@
67 65 };
68 66
69 67 return (
70 68 <div className="countdown">
71 - <i className="fas fa-stopwatch"></i>
69 + <i className="lp-icon-stopwatch"></i>
72 70 <span>{ formatTime() }</span>
73 71 <input type="hidden" name="lp-quiz-time-spend" value={ timeSpend } />
74 72 </div>
75 73 );