Sin descripción

learning-outcomes.blade.php 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. @endif
  10. @stop
  11. @section('main')
  12. <div class="row">
  13. <div class="col-md-12">
  14. <p>Click on the values you want to change. Invalid values will be rejected automatically. To save your changes,
  15. click the 'Save' button at the bottom of the page.</p>
  16. <table class="table table-striped table-condensed editable-table" id='outcomes_table'>
  17. <thead>
  18. <tr class="center-text">
  19. <th class="col-md-1">ID</th>
  20. <th class="col-md-4">Learning Outcome</th>
  21. <th class="col-md-6">Definition</th>
  22. <th class="col-md-1">Expected Value</th>
  23. <th class="col-md-2">Activation date</th>
  24. <th class="col-md-2">Deactivation date</th>
  25. <th class="col-md-1">Level<br><font size="-5">1:undergrad, 2:grad, 3:both</font></th>
  26. <th class="col-md-1">Equivalent to</th>
  27. </thead>
  28. <tbody>
  29. @foreach ($outcomes as $outcome)
  30. {{-- @foreach ($semesters as $semester) --}}
  31. {{-- display an outcome only if it is part of a currently selected semester --}}
  32. @if ($outcome->deactivation_date == '0000-00-00' or $outcome->deactivation_date == '')
  33. {{-- and ($outcome->activation_date >= $semester->start && $outcome->activation_date <= $semester->end)) --}}
  34. <tr data-id="{{ $outcome->id }}">
  35. <td class="id col-md-1">{{ $outcome->id }}</td>
  36. <td contenteditable="true" class="name col-md-4">{{ $outcome->name }}</td>
  37. <td contenteditable="true" data-type="textarea" class="definition col-md-6">{{ $outcome->definition }}</td>
  38. <td contenteditable="true" class="expected-outcome col-md-1">{{ $outcome->expected_outcome }}</td>
  39. <td contenteditable="true" class="activation-date col-md-2">{{ $outcome->activation_date }}</td>
  40. <td contenteditable="true" class="deactivation-date col-md-2">{{ $outcome->deactivation_date }}</td>
  41. <td contenteditable="true" class="level col-md-1">{{ $outcome->level }}</td>
  42. <td></td>
  43. <td><button class="btn btn-sm btn-primary center-block del" id='del{{ $outcome->id }}'>Del</button></td>
  44. </tr>
  45. @endif
  46. {{-- @endforeach --}}
  47. @endforeach
  48. @foreach ($outcomes as $outcome)
  49. {{-- @foreach ($semesters as $semester) --}}
  50. {{-- display an outcome only if it is part of a currently selected semester --}}
  51. @if ($outcome->deactivation_date != '0000-00-00' and $outcome->deactivation_date != '')
  52. {{-- and ($outcome->deactivation_date != '0000-00-00') and ($outcome->deactivation_date != '')) --}}
  53. <tr data-id="{{ $outcome->id }}">
  54. <td class="id col-md-1">{{ $outcome->id }}</td>
  55. <td contenteditable="true" class="name col-md-4">{{ $outcome->name }}</td>
  56. <td contenteditable="true" data-type="textarea" class="definition col-md-6">{{ $outcome->definition }}</td>
  57. <td contenteditable="true" class="expected-outcome col-md-1">{{ $outcome->expected_outcome }}</td>
  58. <td contenteditable="true" class="activation-date col-md-2">{{ $outcome->activation_date }}</td>
  59. <td contenteditable="true" class="deactivation-date col-md-2">{{ $outcome->deactivation_date }}</td>
  60. <td contenteditable="true" class="level col-md-1">{{ $outcome->level }}</td>
  61. <td contenteditable="true" class="new_outcome_id col-md-1">{{ $outcome->new_outcome_id }}</td>
  62. <td><button class="btn btn-sm btn-primary center-block del" id='del{{ $outcome->id }}'>Del</button></td>
  63. </tr>
  64. @endif
  65. {{-- @endforeach --}}
  66. @endforeach
  67. </tbody>
  68. </table>
  69. </div>
  70. </div>
  71. <div class="row">
  72. <div class="col-md-6"><button class="btn btn-lg btn-secondary center-block" id='show'>New Outcome</button>
  73. </div>
  74. <div class="col-md-6"><button class="btn btn-lg btn-primary center-block" id='save'>Save</button></div>
  75. </div>
  76. <div class="" id='new_outcome_form'>
  77. <h2>Add a new Learning Outcomes</h2>
  78. {{-- For for adding a new outcome --}}
  79. {{ Form::open(['action' => 'OutcomesController@create']) }}
  80. <div class="form-group">
  81. {{ Form::label('name', 'Name') }}
  82. {{ Form::text('name', '', ['class' => 'form-control', 'id' => 'outcome_name']) }}
  83. </div>
  84. <div class="form-group">
  85. {{ Form::label('definition', 'Definition') }}
  86. {{ Form::textarea('definition', 'At least 10 characters long', ['class' => 'form-control', 'id' => 'outcome_definition']) }}
  87. </div>
  88. Due to technical limitationss, the following must be edited after adding the new Outcome:
  89. {{-- the technical limitation is: the Outcome Model has to be edited --}}
  90. <ul>
  91. <li>Expected Outcome</li>
  92. <li>Activation Date</li>
  93. <li>Deactivation Date</li>
  94. <li>Level</li>
  95. </ul>
  96. <div class="row">
  97. <div class="col-md-6"><button type="reset" class="btn btn-lg btn-secondary center-block" id='hide'>Hide
  98. Form</button></div>
  99. <div class="col-md-6"><button type="submit" class="btn btn-lg btn-primary center-block">Submit New
  100. Outcome</button></div>
  101. </div>
  102. {{ Form::close() }}
  103. <hr>
  104. </div>
  105. @stop
  106. @section('javascript')
  107. @foreach ($outcomes as $outcome)
  108. $('#del{{ $outcome->id }}').on('click', function(e)
  109. {
  110. e.preventDefault();
  111. //outcomeObject.id= $(this).data('id');
  112. if(confirm("Are you sure you want to delete the outcome with id {{ $outcome->id }}"))
  113. {
  114. console.log("si");
  115. var outcomeObject = new Object();
  116. outcomeObject.id= {{ $outcome->id }};
  117. outcomeObject.delete=1;
  118. console.log("algo"+JSON.stringify({{ $outcome->id }}));
  119. console.log("algo"+JSON.stringify(outcomeObject));
  120. var clone = jQuery.extend({}, outcomeObject);
  121. // outcomeArray.push(clone);
  122. // console.log("algo"+JSON.stringify(outcomeArray));
  123. $.post(
  124. "{{ URL::action('OutcomesController@delete') }}",
  125. { outcomeArray: JSON.stringify(outcomeObject)},
  126. function(data)
  127. {
  128. location.reload();
  129. }
  130. );
  131. }
  132. else
  133. {
  134. console.log("no");
  135. // outcomeObject.delete=0;
  136. }
  137. });
  138. @endforeach
  139. $('#new_outcome_form').hide();
  140. //show form
  141. $('#show').on('click', function(e)
  142. {
  143. $('#new_outcome_form').show();
  144. $('#show').hide();
  145. });
  146. //hide form
  147. $('#hide').on('click', function(e)
  148. {
  149. $('#new_outcome_form').hide();
  150. $('#show').show();
  151. });
  152. $('#save').on('click', function(e)
  153. {
  154. e.preventDefault();
  155. var outcomeArray= new Array();
  156. // For each learning outcome, get its value and put it into an array
  157. $('tbody tr').each(function( index )
  158. {
  159. var outcomeObject = new Object();
  160. outcomeObject.id= $(this).data('id');
  161. outcomeObject.name= $(this).children('.name').text();
  162. outcomeObject.definition= $(this).children('.definition').text();
  163. outcomeObject.expected_outcome= $(this).children('.expected-outcome').text();
  164. outcomeObject.activation_date= $(this).children('.activation-date').text();
  165. outcomeObject.deactivation_date= $(this).children('.deactivation-date').text();
  166. outcomeObject.level= $(this).children('.level').text();
  167. if($(this).children('.new_outcome_id').text()!="")outcomeObject.new_outcome_id= $(this).children('.new_outcome_id').text();
  168. if($(this).find('.glyphicon-eye-close').length>0)
  169. {
  170. outcomeObject.delete=1;
  171. }
  172. else
  173. {
  174. outcomeObject.delete=0;
  175. }
  176. var clone = jQuery.extend({}, outcomeObject);
  177. outcomeArray.push(clone);
  178. });
  179. $.post(
  180. "{{ URL::action('OutcomesController@updateMore') }}",
  181. { outcomeArray: JSON.stringify(outcomeArray)},
  182. function(data)
  183. {
  184. location.reload();
  185. }
  186. );
  187. });
  188. $('span').on('click', function()
  189. {
  190. if($(this).hasClass('glyphicon-eye-open'))
  191. $(this).removeClass('glyphicon-eye-open').addClass('glyphicon-eye-close');
  192. else
  193. $(this).removeClass('glyphicon-eye-close').addClass('glyphicon-eye-open');
  194. });
  195. @stop