1414// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1515
1616/**
17- * support for the mdl35+ mobile app. PHP calls this from within
17+ * support for the Moodle mobile app >= 3.9.5 . PHP calls this from within
1818 * classes/output/mobile.php
1919 */
20- /* jshint esversion: 6 */
21- /* eslint-disable no-console */
2220
2321var that = this ;
2422var result = {
2523 componentInit : function ( ) {
2624 var div = document . createElement ( 'div' ) ;
2725 div . innerHTML = this . question . html ;
28- this . question . text = this . CoreDomUtilsProvider . getContentsOfElement ( div , '.qtext' ) ;
26+ this . question . text = div . querySelector ( '.qtext' ) . innerHTML ;
2927
3028 // Replace Moodle's correct/incorrect and feedback classes with our own.
31- this . CoreQuestionHelperProvider . replaceCorrectnessClasses ( div ) ;
32- this . CoreQuestionHelperProvider . replaceFeedbackClasses ( div ) ;
29+ that . CoreQuestionHelperProvider . replaceCorrectnessClasses ( div ) ;
30+ that . CoreQuestionHelperProvider . replaceFeedbackClasses ( div ) ;
31+ that . CoreQuestionHelperProvider . treatCorrectnessIcons ( div ) ;
3332
34- // Treat the correct/incorrect icons.
35- this . CoreQuestionHelperProvider . treatCorrectnessIcons ( div ) ;
33+ if ( typeof this . question . text === 'undefined' ) {
34+ return that . CoreQuestionHelperProvider . showComponentError ( this . onAbort ) ;
35+ }
3636
3737 if ( div . querySelector ( '.readonly' ) !== null ) {
3838 this . question . readOnly = true ;
3939 }
40+
4041 if ( div . querySelector ( '.feedback' ) !== null ) {
4142 this . question . feedback = div . querySelector ( '.feedback' ) ;
4243 this . question . feedbackHTML = true ;
4344 }
4445
45- if ( typeof this . question . text == 'undefined' ) {
46- this . logger . warn ( 'Aborting because of an error parsing question.' , this . question . name ) ;
47- return this . CoreQuestionHelperProvider . showComponentError ( this . onAbort ) ;
48- }
4946 return true ;
5047 }
5148} ;
49+
50+ /* eslint-disable-next-line */
5251result ;
0 commit comments