{"version":3,"sources":["llms-quiz-attempt-review.js"],"names":["$","window","llms","grading","one","e","preventDefault","this","addClass","$els","length","title","LLMS","l10n","translate","points","each","id","attr","$existing","find","$ui","$textarea","gradeable","append","pts","max","text","replaceWith","$els_first","first","is","trigger","focus","setup_fields","jQuery"],"mappings":"CAMG,SAAYA,GA+FdC,OAAOC,KAAeD,OAAOC,MAAQ,GACrCD,OAAOC,KAAKC,QAAU,IAxFR,WAmFb,OAxECH,EAAG,uEAAwEI,IAAK,QAAS,SAAUC,GAElGA,EAAEC,iBAEFN,EAAGO,MAAOC,SAAU,WAiBtB,WAIC,GAFAC,KAAOT,EAAG,uEAELS,KAAKC,OAAS,EAClB,OAGD,IAAIC,EAASC,KAAKC,KAAKC,UAAW,sBACjCC,EAASH,KAAKC,KAAKC,UAAW,UAE/BL,KAAKO,KAAM,WAEV,IAAIC,EAAYjB,EAAGO,MAAOW,KAAM,oBAC/BC,EAAYnB,EAAGO,MAAOa,KAAM,kDAC5BC,EAAYrB,EAAG,iEACfsB,EAAYtB,EAAG,sDAAwDiB,EAAK,kBAK7E,GAJCM,UAAc,QAAUvB,EAAGO,MAAOW,KAAM,uBAEzCG,EAAIG,OAAQ,8CAAgDb,EAAQ,SACpEU,EAAIG,OAAQF,GACPC,UAAY,CAChB,IAAIE,EAAMzB,EAAGO,MAAOW,KAAM,oBACzBQ,EAAM1B,EAAGO,MAAOW,KAAM,eACvBG,EAAIG,OAAQ,uBAAyBP,EAAK,WAAaS,EAAM,kCAAoCD,EAAM,QAAUC,EAAM,IAAMX,GAGzHI,EAAUT,QAEdY,EAAUK,KAAMR,EAAUC,KAAM,iBAAkBO,QAClDR,EAAUS,YAAaP,IAIvBrB,EAAGO,MAAOa,KAAM,oCAAqCI,OAAQH,KAM/D,IAAIQ,EAAapB,KAAKqB,QACfD,EAAWT,KAAM,oCAAqCW,GAAI,aAEhEF,EAAWT,KAAM,kBAAmBY,QAAS,SAG9CH,EAAWT,KAAM,uBAAwBa,QA7DxCC,KAkEK3B,MA3FN,CAkGE4B","file":"../../js/llms-quiz-attempt-review.min.js","sourcesContent":[";/**\n * Quiz attempt review / grading UI & UX\n *\n * @since 3.16.0\n * @since 3.30.3 Unknown.\n * @version 5.3.0\n */( function( $ ) {\n\n\t/**\n\t * Handle UX for graving quiz attempts.\n\t *\n\t * @since 3.16.0\n\t * @since 3.30.3 Improve grading UX\n\t */\n\tvar Grading = function() {\n\n\t\t/**\n\t\t * Bind DOM events\n\t\t *\n\t\t * @since 3.16.0\n\t\t * @since 3.16.9 Unknown.\n\t\t * @return {Void}\n\t\t */\n\t\tfunction bind() {\n\n\t\t\t$( 'button[name=\"llms_quiz_attempt_action\"][value=\"llms_attempt_grade\"]' ).one( 'click', function( e ) {\n\n\t\t\t\te.preventDefault();\n\n\t\t\t\t$( this ).addClass( 'grading' );\n\n\t\t\t\tsetup_fields();\n\n\t\t\t} );\n\n\t\t}\n\n\t\t/**\n\t\t * Create editable fields for grading / remarking\n\t\t *\n\t\t * @since 3.16.0\n\t\t * @since 3.30.3 When starting a review only toggle first item if it's hidden and always automatically focus on the remarks field.\n\t\t * @since 5.3.0 Exclude removed question items.\n\t\t *\n\t\t * @return {Grading}\n\t\t */\n\t\tfunction setup_fields() {\n\n\t\t\t$els = $( '.llms-quiz-attempt-question:not(.type--content):not(.type--removed)' );\n\n\t\t\tif ( $els.length < 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar title  = LLMS.l10n.translate( 'Remarks to Student' ),\n\t\t\t\tpoints = LLMS.l10n.translate( 'points' );\n\n\t\t\t$els.each( function() {\n\n\t\t\t\tvar id        = $( this ).attr( 'data-question-id' ),\n\t\t\t\t\t$existing = $( this ).find( '.llms-quiz-attempt-answer-section.llms-remarks' ),\n\t\t\t\t\t$ui       = $( '<div class=\"llms-quiz-attempt-answer-section llms-remarks\" />' ),\n\t\t\t\t\t$textarea = $( '<textarea class=\"llms-remarks-field\" name=\"remarks[' + id + ']\"></textarea>' )\n\t\t\t\t\tgradeable = ( 'yes' === $( this ).attr( 'data-grading-manual' ) );\n\n\t\t\t\t$ui.append( '<p class=\"llms-quiz-results-label remarks\">' + title + ':</p>' )\n\t\t\t\t$ui.append( $textarea );\n\t\t\t\tif ( gradeable ) {\n\t\t\t\t\tvar pts = $( this ).attr( 'data-points-curr' ),\n\t\t\t\t\t\tmax = $( this ).attr( 'data-points' );\n\t\t\t\t\t$ui.append( '<input name=\"points[' + id + ']\" max=\"' + max + '\" min=\"0\" type=\"number\" value=\"' + pts + '\"> / ' + max + ' ' + points );\n\t\t\t\t}\n\n\t\t\t\tif ( $existing.length ) {\n\n\t\t\t\t\t$textarea.text( $existing.find( '.llms-remarks' ).text() );\n\t\t\t\t\t$existing.replaceWith( $ui );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t$( this ).find( '.llms-quiz-attempt-question-main' ).append( $ui );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\tvar $els_first = $els.first();\n\t\t\tif ( ! $els_first.find( '.llms-quiz-attempt-question-main' ).is( ':visible' ) ) {\n\t\t\t\t// expand the first question toggle.\n\t\t\t\t$els_first.find( '.toggle-answer' ).trigger( 'click' );\n\t\t\t}\n\t\t\t// focus on its remark textarea.\n\t\t\t$els_first.find( '.llms-remarks-field' ).focus();\n\t\t}\n\n\t\tbind();\n\n\t\treturn this;\n\n\t};\n\n\twindow.llms         = window.llms || {};\n\twindow.llms.grading = new Grading();\n\n} )( jQuery );\n"],"sourceRoot":"../../js"}