File "std-task-quizzes.min.js"

Path: /ThinkIB/js/std/std-task-quizzesminjs
File size: 4.54 KB
MIME-type: text/plain
Charset: utf-8

 
Open Back
function quizLogger(quiz,scoreMarks,checkAll=!0){var exerciseIndex=0,logger={};return quiz.find(".exercise").each((function(){var exercise=$(this),isExerciseChecked;(0===exercise.find(".btn.check").length||checkAll)&&(log=checkAll?{score:scoreMarks[exerciseIndex].score,mark:scoreMarks[exerciseIndex].mark,answers:[]}:{score:scoreMarks.score,mark:scoreMarks.mark,answers:[]},exercise.find("label").length>0&&exercise.find("label input").each((function(k,v){$(this).is(":checked")&&log.answers.push(k)})),exercise.find('input[type="text"]').length>0&&exercise.find('input[type="text"]').each((function(k,v){log.answers.push($(this).val())})),logger[exerciseIndex]=log),exerciseIndex++})),logger}function popupCenter(url,title,w,h){const dualScreenLeft=void 0!==window.screenLeft?window.screenLeft:window.screenX,dualScreenTop=void 0!==window.screenTop?window.screenTop:window.screenY,width=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,height=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,systemZoom=width/window.screen.availWidth,left=(width-w)/2/systemZoom+dualScreenLeft,top=(height-h)/2/systemZoom+dualScreenTop,newWindow=window.open(url,title,`\n      scrollbars=yes,\n      width=${w/systemZoom}, \n      height=${h/systemZoom}, \n      top=${top}, \n      left=${left}\n      `);return window.focus&&newWindow.focus(),newWindow}function saveUploadedAnswer(){var data={ticket:ticket,"std-task-student-id":taskStdId,content:$(".dedicated-uploader")[0].outerHTML};$.post("pages/std/std-task-quizzes.php?action=uploaded-answer-mark-as-done",data,(function(response){"1"==response.success?($("#submit-upload-answer").hide(),$("#task-completed-badge").show(),$("html, body").animate({scrollTop:$("#task-completed-badge").position().top}),$("#upload-dedicated-attachment").hide(),$('label[for="upload-dedicated-attachment"]').hide(),$("span.total-files").hide(),$(".dedicated-uploader").find("div.header").text("Your answer(s)"),$("li.dedicated-upload-file").each((function(){$(this).find("i.remove-attachment").remove()})),$("#return-my-tasks-q").show()):"0"==response.success&&alert(response.msg)}),"json")}function saveQuizLog(logger,score,markTaskDone=1){var iTime=timeSpent(),isExam="undefined"!=typeof examTime,taskID=$("#task-ID").length?$("#task-ID").val():"";if(!$("#task-completed-badge").hasClass("already-submitted")){var data={ticket:ticket,"std-task-student-id":taskStdId,"student-ID":studentID,"task-ID":taskID,score:score,isExam:isExam,"init-time":iTime,"start-time":amountSecs,logger:logger,addVisits:"page-quiz"==taskMode?"yes":"no","mark-as-done":1===markTaskDone?"1":"0"};$.post("pages/std/std-task-quizzes.php?action=save-quiz-log",data,(function(response){"1"==response.success?(sendLogs=!1,markTaskDone&&($("#task-completed-badge").show(),$("html, body").animate({scrollTop:$("#task-completed-badge").position().top})),controlExamInCombinedTask()):"0"==response.success&&alert(response.msg)}),"json")}}$(document).ready((function(){catchEventsToTrack(),$(".scrollToTask").click((function(e){if(e.preventDefault(),null!==$(this).data("target")){var target="#"+$(this).data("target");$(target).length&&$("html, body").animate({scrollTop:$(target).offset().top-70},500)}})),$("#submit-upload-answer").click((function(e){if(e.preventDefault(),$(this).hasClass("disabled"))return!1;saveUploadedAnswer()})),$("#print-custom").click((function(){var title=$(".section-title").html()+"<br><br><hr>",instructions=$(".instructions-title").html()+"<br><br>";title+=instructions+=$(".instructions").html()+"<br><br>";var quizContent=$(".tib-quiz").html();quizContent=title+=quizContent;var w,h,quiz=popupCenter("","Print quiz",$(window).width()-.3*$(window).width(),$(window).height()-1*$(window).height());quiz.document.write(quizContent),quiz.print()}));const isExamModeWrittenTask="undefined"!=typeof isExamMode&&isExamMode;isExamModeWrittenTask||(!sendLogs&&"manual-quiz"==taskMode||"page-quiz"==taskMode)&&$("#tib-written-task").length&&($(".manual-q-answer p.std-manual-answer").each((function(){$(this).addClass("well")})),$.when(getEditorAnswers(JSON.stringify(tibQuizzes))).then((function(answers){appendEditorAnswers($("#main-content"),answers,"right")})),showEssayWordLimit(),$("p.std-manual-answer").filter((function(i,a){return 0==$.trim($(a).text()).length})).append('<span class="std-no-manual-answer">No answer submitted</span>')),$("#quiz-marked").change((function(){var quiz,logger;saveQuizLog(quizLogger($(this).closest(".tib-quiz")),$("#quiz-scored").val())}))}));