Без опису

view-criteria-outcome.blade.php 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. </div>
  31. </div>
  32. <!-- Modal -->
  33. <div id="criteria-modal" class="modal fade" role="dialog">
  34. <div class="modal-dialog">
  35. <!-- Modal content-->
  36. <div class="modal-content">
  37. <div class="modal-header">
  38. <button type="button" class="close" data-dismiss="modal">&times;</button>
  39. <h4 class="modal-title"></h4>
  40. </div>
  41. <div class="modal-body">
  42. </div>
  43. <div class="modal-footer">
  44. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <script>
  50. $(document).ready(function(){
  51. onLoad();
  52. });
  53. function onLoad(){
  54. fetchAllObjectives('#select-program');
  55. }
  56. function fetchAllObjectives(select){
  57. program_id =$(select).val();
  58. is_graduate = $(select).find(':selected').data('is-graduate');
  59. $.post(
  60. "{{URL::action('CriteriaController@fetchCriteriaOutcomes')}}",
  61. {
  62. program_id:program_id
  63. },
  64. function(criteria_outcomes){
  65. drawTable(criteria_outcomes.criteria, criteria_outcomes.outcomes, is_graduate);
  66. }
  67. )
  68. }
  69. function drawTable(criteria, outcomes, is_graduate){
  70. table = $('<table>',{
  71. 'id': 'theMainTable',
  72. 'class': 'table table-striped table-condensed datatable'
  73. });
  74. thead = $("<thead>");
  75. thead_row = $('<tr>');
  76. th= $('<th>').html('Criteria');
  77. thead_row.append(th);
  78. outcomes_th = [];
  79. $.each(outcomes, function(ind, outcomes){
  80. th = $('<th>', {
  81. 'class':'th-outcomes th-out-id',
  82. 'data-outcome-id':outcomes.id
  83. }).html(outcomes.name);
  84. outcomes_th.push(th);
  85. thead_row.append(th);
  86. })
  87. th = $('<th>', {
  88. 'class':'th-outcomes'
  89. }).html('Objectives');
  90. thead_row.append(th);
  91. thead.append(thead_row);
  92. tbody = $('<tbody>');
  93. $.each(criteria, function(ind, criterion){
  94. tr = $("<tr>", {
  95. 'class':'criteria',
  96. 'data-criterion-id':criterion.id,
  97. })
  98. td = $("<td>", {
  99. 'class': 'objective',
  100. 'data-criterion-id':criterion.id,
  101. }).html(criterion.name);
  102. tr.append(td);
  103. $(outcomes_th).each(function(id, th){
  104. var td = $('<td>');
  105. outcome_id = $(th).data('outcome-id');
  106. //console.log(outcome_id);
  107. if(criterion.outcome_ids.includes(outcome_id)){
  108. var span = $("<span>", {
  109. 'class':'glyphicon glyphicon-ok'
  110. })
  111. td.append(span);
  112. }
  113. tr.append(td);
  114. });
  115. td_link = $('<td>');
  116. a = $("<a>",{
  117. 'onclick':'fetchObjectiveCriteria("'+criterion.id+'", "#select-program")'
  118. }).html('View Objectives');
  119. td_link.append(a);
  120. tr.append(td_link);
  121. tbody.append(tr);
  122. });
  123. table.append(thead)
  124. table.append(tbody);
  125. $('#div_table').html(table);
  126. table = $("#theMainTable").DataTable();
  127. table.draw();
  128. }
  129. function fetchObjectiveCriteria(criterion_id,program_select){
  130. program_id = $(program_select).val();
  131. $.post(
  132. "{{URL::action('CriteriaController@fetchCriteriaObjectiveOutcomes')}}",
  133. {
  134. program_id:program_id,
  135. criterion_id:criterion_id
  136. },
  137. function(data){
  138. modal = "#criteria-modal";
  139. $(modal).find('.modal-body').html(createModalContent(data.outcomes));
  140. $(modal).find('.modal-title').html("Objectives for <strong>"+data.criterion.name+"</strong>")
  141. $(modal).modal('show');
  142. }
  143. )
  144. }
  145. function createModalContent(outcomes){
  146. ol_out = $("<ol>")
  147. $.each(outcomes, function(ind, out){
  148. //ol_out = $("<ol>")
  149. if(out.objectives.length == 0)
  150. return;
  151. li = $('<li>').html("<p><strong>"+out.name+"</strong></p>");
  152. ul = $('<ul>');
  153. $.each(out.objectives, function(ind, obj){
  154. li2 = $("<li>").html(obj.text);
  155. ul.append(li2);
  156. });
  157. li.append(ul);
  158. ol_out.append(li)
  159. //div.append(ol_out)
  160. })
  161. return ol_out;
  162. }
  163. </script>
  164. @stop
  165. @section('included-js')
  166. @include('global._datatables_js')
  167. @stop
  168. @section('javascript')
  169. @stop