No Description

view-objectives-outcome.blade.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if (Auth::user()->role == 1)
  4. @include('local.managers.admins._new_navigation')
  5. @elseif(Auth::user()->role == 2)
  6. @include('local.managers.sCoords._new_navigation')
  7. @elseif(Auth::user()->role == 3)
  8. @include('local.managers.pCoords._new_navigation')
  9. @elseif(Auth::user()->role == 4)
  10. @include('local.professors._navigation')
  11. @endif
  12. @stop
  13. @section('main')
  14. <div class ='row'>
  15. <div class ='col-md-3'>
  16. <div class="form-group">
  17. {{ Form::label('program_id2', 'Select Program') }}
  18. <select id='select-program' class="form-control selectpicker"
  19. onchange='fetchAllObjectives("#select-program")'>
  20. @foreach ($programs as $program)
  21. <option value='{{ $program->id }}' data-is-graduate = "{{$program->is_graduate}}" data-subtext="{{ $program->code }}">
  22. {{ $program->name }}</option>
  23. @endforeach
  24. </select>
  25. </div>
  26. </div>
  27. </div>
  28. <div class = 'row'>
  29. <div class = 'col-md-12' id ='div_table'>
  30. <table id = 'theMainTable' class ='table table-striped table-condensed datatable'>
  31. <thead>
  32. <tr id = 'outcomes-thead'>
  33. <th>Objectives</th>
  34. </tr>
  35. </thead>
  36. <tbody id = 'objectves-outcomes'>
  37. </tbody>
  38. </table>
  39. </div>
  40. </div>
  41. <!-- Modal -->
  42. <div id="criteria-modal" class="modal fade" role="dialog">
  43. <div class="modal-dialog">
  44. <!-- Modal content-->
  45. <div class="modal-content">
  46. <div class="modal-header">
  47. <button type="button" class="close" data-dismiss="modal">&times;</button>
  48. <h4 class="modal-title"></h4>
  49. </div>
  50. <div class="modal-body">
  51. </div>
  52. <div class="modal-footer">
  53. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <script>
  59. $(document).ready(function(){
  60. onLoad();
  61. });
  62. function onLoad(){
  63. fetchAllObjectives('#select-program');
  64. }
  65. function fetchAllObjectives(select){
  66. program_id =$(select).val();
  67. is_graduate = $(select).find(':selected').data('is-graduate');
  68. $.post(
  69. "{{URL::action('Objective2Controller@fetchObjectiveOutcome')}}",
  70. {
  71. program_id:program_id
  72. },
  73. function(objectives_outcomes){
  74. drawTable(objectives_outcomes.objectives, objectives_outcomes.outcomes, is_graduate);
  75. }
  76. )
  77. }
  78. function drawTable(objectives, outcomes, is_graduate){
  79. table = $('<table>',{
  80. 'id': 'theMainTable',
  81. 'class': 'table table-striped table-condensed datatable'
  82. });
  83. thead = $("<thead>");
  84. thead_row = $('<tr>');
  85. th= $('<th>').html('Objectives');
  86. thead_row.append(th);
  87. outcomes_th = [];
  88. $.each(outcomes, function(ind, outcomes){
  89. th = $('<th>', {
  90. 'class':'th-outcomes th-out-id',
  91. 'data-outcome-id':outcomes.id
  92. }).html(outcomes.name);
  93. outcomes_th.push(th);
  94. thead_row.append(th);
  95. })
  96. th = $('<th>', {
  97. 'class':'th-outcomes'
  98. }).html('Criteria');
  99. thead_row.append(th);
  100. thead.append(thead_row);
  101. tbody = $('<tbody>');
  102. $.each(objectives, function(ind, objective){
  103. tr = $("<tr>", {
  104. 'class':'objectives',
  105. 'data-objective-id':objective.id,
  106. })
  107. td = $("<td>", {
  108. 'class': 'objective',
  109. 'data-objective-id':objective.id,
  110. }).html(objective.text);
  111. tr.append(td);
  112. $(outcomes_th).each(function(id, th){
  113. var td = $('<td>');
  114. outcome_id = $(th).data('outcome-id');
  115. //console.log(outcome_id);
  116. if(objective.outcome_ids.includes(outcome_id)){
  117. var span = $("<span>", {
  118. 'class':'glyphicon glyphicon-ok'
  119. })
  120. td.append(span);
  121. }
  122. tr.append(td);
  123. });
  124. td_link = $('<td>');
  125. a = $("<a>",{
  126. 'onclick':'fetchObjectiveCriteria("'+objective.id+'", "#select-program")'
  127. }).html('View Criteria');
  128. td_link.append(a);
  129. tr.append(td_link);
  130. tbody.append(tr);
  131. });
  132. table.append(thead)
  133. table.append(tbody);
  134. $('#div_table').html(table);
  135. table = $("#theMainTable").DataTable();
  136. table.draw();
  137. }
  138. function fetchObjectiveCriteria(objective_id,program_select){
  139. program_id = $(program_select).val();
  140. $.post(
  141. "{{URL::action('CriteriaController@fetchObjectiveCriteria')}}",
  142. {
  143. program_id:program_id,
  144. objective_id:objective_id
  145. },
  146. function(data){
  147. modal = "#criteria-modal";
  148. $(modal).find('.modal-body').html(createModalContent(data.outcomes));
  149. $(modal).find('.modal-title').html("Criteria for <strong>"+data.objective.text+"</strong>")
  150. $(modal).modal('show');
  151. }
  152. )
  153. }
  154. function createModalContent(outcomes){
  155. ol_out = $("<ol>")
  156. $.each(outcomes, function(ind, out){
  157. //ol_out = $("<ol>")
  158. if(out.criteria.length == 0)
  159. return;
  160. li = $('<li>').html("<p><strong>"+out.name+"</strong></p>");
  161. ul = $('<ul>');
  162. $.each(out.criteria, function(ind, crit){
  163. li2 = $("<li>").html(crit.name);
  164. ul.append(li2);
  165. });
  166. li.append(ul);
  167. ol_out.append(li)
  168. //div.append(ol_out)
  169. })
  170. return ol_out;
  171. }
  172. </script>
  173. @stop
  174. @section('included-js')
  175. @include('global._datatables_js')
  176. @stop
  177. @section('javascript')
  178. @stop