File "std-access-tools-add-task.min.js"

Path: /ThinkIB/chem/js/std-access/std-access-tools-add-taskminjs
File size: 4.95 KB
MIME-type: text/plain
Charset: utf-8

 
Open Back
var selectedGroups=[],selectedStudents=[];function saveTaskFromTools(andSend){$("#modal-std-access-tools-add-task .save-actions .btn").toggleClass("hidden");var url="pages/std-access/std-assignments.php?action=save-assignment",data={ticket:null,task_id:"",deadline:null,groups:selectedGroups,students:selectedStudents,general_id:null,and_send:andSend,resources:[]},form=$("#form-send-page-task").serializeArray(),resource={"see-answers":"false","see-w-solutions":"false"};$.each(form,(function(i,field){if(field.value.length){var formInputName=field.name,formInputValue=field.value;if("subject-id"==formInputName)formInputName="general_id";else if("minutes"==formInputName)formInputName="resource-examTime";else if("deadline"==formInputName){var d=$("#modal-std-access-tools-add-task .deadline-datepicker").datepicker("getDate");d.setHours(23),d.setMinutes(59),d.setSeconds(59),formInputValue=d.toISOString()}else if("dynamic-question-ids"==formInputName)resource.extra={"dynamic-question-ids":formInputValue};else if(formInputName.startsWith("score-answer-options")){var mode;formInputValue=$(".score-answers-container").find('input[name="'+formInputName+'"]:checked').data("opt")}data.hasOwnProperty(formInputName)&&formInputValue.length?data[formInputName]=formInputValue:"resource-"==formInputName.substring(0,9)?resource[formInputName.substring(9)]=formInputValue:formInputName.startsWith("score-answer-options")&&(resource.see_score_answers=formInputValue),"see-answers"===formInputName&&(resource["see-answers"]="true"),"see-w-solutions"===formInputName&&(resource["see-w-solutions"]="true")}})),data.resources.push(resource),$.post(url,data,(function(response){if("1"==response.success){$("#std-access-tools a.access.forced").each((function(){$(this).removeClass("forced")})),$("#modal-std-access-tools-add-task").modal("hide");var saveBlurb=andSend?"sent":"saved as draft";$("#std-sidebox-task-added-msg").html(['<div class="alert alert-success" style="margin-bottom: 10px; margin-top: 10px;">','<i class="fa fa-check-circle-o"></i>&nbsp;',"<strong>Task successfully "+saveBlurb+"!</strong>","</div>"].join("")).show("fast").delay(4e3).hide("slow",(function(){$(this).remove()}))}else"0"==response.success&&alert(response.msg)}),"json").done((function(){$("#modal-std-access-tools-add-task .save-actions .btn").toggleClass("hidden"),load_std_access_side_box(!1),$("#form-send-page-task")[0].reset(),$(".exam-mode-minutes").hide()}))}function showScoreAnswersMode(){var taskType=$('input[name="resource-type"]').val(),resourceId=$('input[name="resource-id"]').val();switch(taskType){case"quiz-page":$(".score-answers-container").html(printQuizScoreAnswersOptions(resourceId,!1));break;case"short-answer":$(".score-answers-container").html(printWrittenScoreAnswersOptions(resourceId,!1));break;case"in-page-combined-task":$(".score-answers-container").html(printQuizScoreAnswersOptions(resourceId,!0))}}function updateStdAccessToolsRecipients(){selectedGroups=[],selectedStudents=[];var modalRecipients=[];$("#std-access-tools").find(".set-as-task").each((function(){if($(this).is(":checked")){var tr=$(this).closest("tr"),group=parseInt(tr.data("groupid"));selectedGroups.push(group);var students=tr.data("student-ids");if("string"==typeof students&&students.indexOf(",")>=0){students=students.split(",");for(var i=0;i<students.length;i++)selectedStudents.indexOf(parseInt(students[i]))<0&&selectedStudents.push(parseInt(students[i]))}else"number"==typeof students&&selectedStudents.push(parseInt(students));modalRecipients.push(tr.find("td").first().text().trim())}})),$("#modal-std-access-tools-recipients").text(modalRecipients.join(", "))}$(document).ready((function(){$("#modal-std-access-tools-add-task .deadline-datepicker").datepicker({weekStart:1,startDate:new Date,autoclose:!0,clearBtn:!0,format:"dd M yyyy"}),$("#modal-std-access-tools-add-task .deadline-datepicker").next(".add-on").click((function(e){e.preventDefault(),$(this).next(".deadline-datepicker").datepicker("show")})),$("#exam-mode").change((function(){$(this).parent("label").next(".exam-mode-minutes").toggleClass("hidden")})),$("#modal-std-access-tools-add-task").on("show",(function(){showScoreAnswersMode(),updateStdAccessToolsRecipients()})),1==$(".tib-quiz").length&&$(".tib-quiz")[0].hasAttribute("data-question-ids")&&$("#std-tools-dyn-quiz-ids").val($(".tib-quiz").data("question-ids")),$(".tib-quiz").length>1&&$(".tib-quiz").each((function(){if(void 0!==$(this).data("question-ids")){var dynamicQuestionIds=$(this).data("question-ids");$("#std-tools-dyn-quiz-ids").val(dynamicQuestionIds)}})),$("#modal-std-access-tools-add-task .deadline-datepicker").change((function(){var d=$(this).datepicker("getDate");$("#modal-std-access-tools-add-task .save-actions .btn").attr("disabled",isNaN(d.getTime()))})),$(".deadline-datepicker").prev(".add-on").click((function(e){$(this).next(".deadline-datepicker").datepicker().focus()})),$("#modal-std-access-tools-add-task .save-task-from-tools").click((function(){var andSend;saveTaskFromTools($(this).hasClass("also-send"))}))}));