No Description

annual_plan_js.blade.php 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <script>
  2. $(document).ready(function()
  3. {
  4. // --------------------------------------------------------------------------
  5. // Page load
  6. // --------------------------------------------------------------------------
  7. // Hide accordion panel contents by default
  8. $('.panel-group .panel-body').hide();
  9. $('#outcome-display').parent().hide();
  10. // --------------------------------------------------------------------------
  11. // Functions
  12. // --------------------------------------------------------------------------
  13. // --------------------------------------------------------------------------
  14. // Events
  15. // --------------------------------------------------------------------------
  16. // When list item is clicked, load corresponding info
  17. $('.list-group-item').on('click', function()
  18. {
  19. var id = $(this).data('outcome-id');
  20. var name = $(this).data('outcome-name');
  21. var semester = $(this).data('semester-id');
  22. $.post(
  23. "../annual-plan-fetchTYP/{{$program->id}}",
  24. { id: id,
  25. semester: semester
  26. },
  27. function(json)
  28. {
  29. // Retrieve datatable instance
  30. var table = $('.datatable').DataTable();
  31. alert(json);
  32. var objectives = json.unique_objective;
  33. var courses = json.courses;
  34. var courseHTML = '<ol>';
  35. var objectiveHTML = '';
  36. var criteria = json.criteria
  37. nextLetter ="@";
  38. counter = 1;
  39. for(course in courses){
  40. courseHTML+='<li>'+courses[course].code+' '+courses[course].number+'</li>';
  41. }
  42. courseHTML += "</ol>"
  43. courses = json.courses_objective;
  44. for(objective in objectives){
  45. for(course in courses[objectives[objective].id]){
  46. objectiveHTML += "<strong>"+courses[objectives[objective].id][course].code+" "+courses[objectives[objective].id][course].number +", </strong>";
  47. }
  48. objectiveHTML += "<ol type ='A' start='"+counter.toString()+"'>";
  49. objectiveHTML += "<li>"+objectives[objective].text+"</li>";
  50. objectiveHTML += "</ol>";
  51. counter++;
  52. }
  53. for(objective in objectives){
  54. $divForEach =$('<div/>',{
  55. 'id':'objective #'+objectives[objective]
  56. });
  57. $objective = "<h4>"+objectives[objective].text+"</h4>";
  58. $divForEach.append($objective)
  59. $select = $('<select/>',{
  60. 'class': "selectpicker form-control",
  61. 'name' : "criteriaFor["+objectives[objective].id+"]",
  62. 'data-live-search':'true',
  63. 'id': 'criteriaFor'+objectives[objective].id+'_0'
  64. })
  65. options = ''
  66. for (criterion in criteria[objectives[objective].id]){
  67. options += "<option value='"+criteria[objectives[objective].id][criterion].id+"'>"+criteria[objectives[objective].id][criterion].name+"</option>";
  68. }
  69. $select.append(options);
  70. $divForEach.append($select);
  71. $divForEach.appendTo('#theChange');
  72. $select.selectpicker('refresh');
  73. }
  74. $('#outcome-display').parent().show();
  75. $('.no-outcome').parent().hide();
  76. //Display title and definition
  77. $('#outcome-display .panel-title').html(name);
  78. //Empty table
  79. table.clear();
  80. // Add new criteria
  81. if(courses)
  82. {
  83. $('table').show();
  84. table.row.add([
  85. courseHTML,
  86. objectiveHTML
  87. ]);
  88. }
  89. else
  90. {
  91. $('table').hide();
  92. }
  93. // Update display
  94. table.draw();
  95. },
  96. 'json'
  97. );
  98. })
  99. });
  100. function addObjectiveTest() {
  101. selectObj = document.getElementById('objective_0').innerHTML;
  102. var $select = $('<select/>', {
  103. 'class': "selectpicker form-control",
  104. 'name': "objective[]",
  105. 'data-live-search': 'true',
  106. 'id': 'objective_' + counterObj.toString()
  107. });
  108. var $div = $('<div/>', {
  109. 'id': 'objectiveForm' + counterObj.toString(),
  110. 'class': 'form-group col-md-11'
  111. });
  112. var $divForButton = $('<div/>', {
  113. 'class': 'col-md-1',
  114. 'id': 'closeObj' + counterObj.toString()
  115. });
  116. var $button = $('<button/>', {
  117. 'type': 'button',
  118. 'class': 'btn btn-primary',
  119. 'onclick': 'deleteObjective("objectiveForm' + counterObj.toString() + '", "closeObj' + counterObj.toString() + '")'
  120. });
  121. $button.append('X');
  122. $divForButton.append($button);
  123. $div.appendTo('#objectiveGroup')
  124. $select.append(selectObj);
  125. $select.appendTo('#objectiveForm' + counterObj.toString()).selectpicker('refresh');
  126. counterObj += 1;
  127. $divForButton.appendTo('#objectiveGroup');
  128. $('#counterObjective').val(counterObj)
  129. }
  130. </script>