No Description

view_template.blade.php 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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-12">
  16. <div class="btn-group pull-right">
  17. {{ HTML::linkAction('TemplatesController@printview', 'Print', array($template->id), array('class'=>'btn btn-default')) }}
  18. <button class= 'btn btn-default' onclick ='fetchObjectivesForTemplate("#bodyRubric")'>View Objectives</button>
  19. </div>
  20. <p>Passing Criteria:
  21. <span id="expected_percentage">{{{ $template->expected_percentage }}}% of students must obtain at least </span>
  22. <span id="expected_points">{{{$template->expected_points}}}</span> points
  23. </p>
  24. <table class="table datatable" id= "RubricTable">
  25. <thead>
  26. <tr>
  27. <th></th>
  28. <th>Criterion</th>
  29. @for($i = 0; $i <$template->num_scales; $i++)
  30. <th>{{$template->titles[$i]}} ({{1+($i*($template->max_score/$template->num_scales))}} - {{(1+$i)*($template->max_score/$template->num_scales)}})</th>
  31. @endfor
  32. <th>Learning Outcome</th>
  33. @if($can_edit)
  34. <th>Show Objectives</th>
  35. @endif
  36. </tr>
  37. </thead>
  38. <tbody id ="bodyRubric">
  39. @foreach($template->criteria as $index=> $criterion)
  40. <tr data-criterion-id = "{{$criterion->id}}" data-criterion-copyright="{{$criterion->copyright}}" data-criterion-notes="{{$criterion->notes}}">
  41. <td>{{$index+1}}.</td>
  42. @if($criterion->notes)
  43. <td id='criterion-name'><span><em data-toggle="tooltip" data-placement="top" title="{{$criterion->notes}}">{{$criterion->name}}</em></span><sup></sup></td>
  44. @else
  45. <td id='criterion-name'><span>{{$criterion->name}}</span><sup></sup></td>
  46. @endif
  47. @foreach ($criterion->scales as $scale)
  48. <td>{{$scale}}</td>
  49. @endforeach
  50. <td><ol>
  51. @foreach ($criterion->outcomes as $outcome)
  52. <p>{{$outcome->name}}</p>
  53. @endforeach
  54. </ol></td>
  55. @if($can_edit)
  56. <td>
  57. <a data-criterion-id = '{{$criterion->id}}' onclick = 'pairObjectivesModal(this)'>Show or pair objectives to Criteria</a>
  58. </td>
  59. @endif
  60. </tr>
  61. @endforeach
  62. </tbody>
  63. </table>
  64. <br>
  65. <br>
  66. <div id="copyright-info">
  67. <hr>
  68. <p class="small"><strong>Copyright Information</strong></p>
  69. <ul id="copyright-list" class="list-unstyled small">
  70. </ul>
  71. <hr>
  72. </div>
  73. <br>
  74. <br>
  75. <br>
  76. </div>
  77. </div>
  78. <div class="modal fade" id="objectives-crit-modal">
  79. <div class="modal-dialog modal-md">
  80. <div class="modal-content">
  81. <div class="modal-header">
  82. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  83. <h4 class="modal-title text-center" id ="modal-title-rubric">These are the objectives in each Criterion in this Rubric</h4>
  84. </div>
  85. <div class="modal-body" id ="objectives-crit-modal-body">
  86. </div>
  87. <div class="modal-footer">
  88. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  89. </div>
  90. </div><!-- /.modal-content -->
  91. </div><!-- /.modal-dialog -->
  92. </div>
  93. <div class="modal fade" id="pair-objectives">
  94. <div class="modal-dialog modal-md">
  95. <div class="modal-content">
  96. <div class="modal-header">
  97. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  98. <h4 class="modal-title text-center" id ="pair-objectives-title">Select objectives you want to pair</h4>
  99. </div>
  100. <div class="modal-body" id ="pair-objectives-body">
  101. </div>
  102. <div class="modal-footer">
  103. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  104. </div>
  105. </div><!-- /.modal-content -->
  106. </div><!-- /.modal-dialog -->
  107. </div>
  108. <script>
  109. function pairObjectivesModal(a){
  110. criterion_id = $(a).data('criterion-id')
  111. $.post(
  112. "{{URL::action('CriteriaController@fetchFromTemplate')}}",
  113. {
  114. criterion_id: criterion_id
  115. },
  116. function(objectives){
  117. $("#pair-objectives-body").html('<label>Objectives Paired to '+$('#criterion-name').html()+'</label>');
  118. options = makeOptions(objectives.objectives_available);
  119. if(objectives.objectives_selected.length == 0){
  120. $("#pair-objectives-body").append(createObjectiveSelect('', options,criterion_id));
  121. }
  122. else{
  123. $.each(objectives.objectives_selected, function (ind, obj){
  124. $("#pair-objectives-body").append(createObjectiveSelect(obj, options,criterion_id));
  125. })
  126. }
  127. $("#pair-objectives-body").append(addObjectiveButton(criterion_id));
  128. $("#pair-objectives-body").attr('data-outcome-ids', JSON.stringify(objectives.outcomes));
  129. $("#pair-objectives").modal('show');
  130. $('.selectpicker').selectpicker('refresh');
  131. }
  132. )
  133. }
  134. options = '';
  135. function makeOptions(objectives){
  136. options = "<option value = '0'>Nothing Selected</option>";
  137. $.each(objectives, function(ind, obj){
  138. //objective_outcome_array = [obj.objective_id,obj.outcome_id];
  139. options += "<option value = '"+obj.id+"'><p>" +obj.text+"</p></option>";
  140. });
  141. return options;
  142. }
  143. function addObjectiveButton(criterion_id){
  144. div_row = $("<div>",{
  145. "class":'row',
  146. 'id':"objective_button"
  147. }
  148. );
  149. div_col = $("<div>", {
  150. 'id':'objective_button',
  151. 'class':'col-md-12'
  152. });
  153. button = $("<button>", {
  154. 'class':"btn btn-md btn-secondary pull-right",
  155. 'onclick':'addObjectives("#objective_button", '+criterion_id+')'
  156. }).html('<span class ="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Objective');
  157. div_col.append(button);
  158. div_row.append(div_col);
  159. return div_row;
  160. }
  161. function addObjectives(div, criterion_id){
  162. $(div).before(createObjectiveSelect('',options, criterion_id));
  163. $(".selectpicker").selectpicker('refresh');
  164. }
  165. function createObjectiveSelect(objective = '', options, criterion_id){
  166. div_master = $('<div>',{
  167. 'class':'removable_div'
  168. })
  169. div_select = $("<div>",{
  170. 'class':'form-group col-md-11',
  171. })
  172. select = $('<select>',{
  173. 'name':'objectives[]',
  174. 'class':'selectpicker form-control removable',
  175. 'data-live-search':'true',
  176. "data-old-objective": ((objective == '') ? 'none': objective.id),
  177. 'data-criterion-id':criterion_id,
  178. 'onchange':'postObjective(this)'
  179. }).html(options);
  180. if(objective != ''){
  181. select.val(objective.id);
  182. }
  183. div_rem_button = $('<div>',
  184. {
  185. 'class':'col-md-1 remove-btn'
  186. })
  187. rem_button = $('<button>',{
  188. 'type':'button',
  189. 'class':'btn btn-primary',
  190. 'onclick':'deleteCriterion(this);'
  191. }).html("<span class='glyphicon glyphicon-remove'></span>")
  192. div_select.append(select);
  193. div_rem_button.append(rem_button);
  194. div_master.append(div_select);
  195. div_master.append(div_rem_button);
  196. return div_master;
  197. }
  198. function postObjective(select){
  199. old_objective = $(select).data('old-objective');
  200. criterion_id = $(select).data('criterion-id');
  201. new_objective = $(select).val();
  202. if(old_objective == 'none'){
  203. url = "{{URL::action('Objective2Controller@insertPCOBOFromTemplate')}}";
  204. }
  205. else{
  206. url = "{{URL::action('Objective2Controller@updatePCOBOFromTemplate')}}";
  207. }
  208. $.post(
  209. url,
  210. {
  211. old_objective: old_objective,
  212. template_id: {{$template->id}},
  213. criterion_id: criterion_id ,
  214. new_objective:new_objective
  215. },
  216. function(){
  217. $(select).data('old-objective', new_objective);
  218. }
  219. )
  220. }
  221. function deleteCriterion(button){
  222. removable_div = $(button).parent().parent();
  223. select = removable_div.find('select.removable');
  224. if(select.data('old-objective')== 'none'){
  225. modal_body = removable_div.parent();
  226. removable_div.remove();
  227. if(modal_body.children('.removable_div').length == 0){
  228. addObjectives("#objective_button");
  229. }
  230. return;
  231. }
  232. $.post(
  233. "{{URL::action('Objective2Controller@deletePCOBOFromTemplate')}}",
  234. {
  235. template_id: {{$template->id}},
  236. objective_id:select.val(),
  237. criterion_id:select.data('criterion-id'),
  238. },
  239. function (){
  240. modal_body = removable_div.parent();
  241. removable_div.remove();
  242. if(modal_body.children('.removable_div').length == 0){
  243. addObjectives("#objective_button");
  244. }
  245. return;
  246. }
  247. )
  248. }
  249. function fetchObjectivesForTemplate(tbody){
  250. allCriteria = [];
  251. $(tbody).children('tr').each(function (index){
  252. allCriteria.push($(this).data('criterion-id'));
  253. })
  254. $.post(
  255. "{{URL::action('TemplatesController@fetchObjectivesForTemplate')}}",
  256. {
  257. allCriteria:allCriteria,
  258. template_id:{{$template->id}}
  259. },
  260. function(crit){
  261. modal_name = '#objectives-crit-modal';
  262. $(modal_name+'-body').html(' ');
  263. ol_crit = $("<ol>")
  264. $(modal_name+'-body').append(ol_crit);
  265. $.each(crit, function(index, cri){
  266. li = $("<li>").html("<strong>"+cri.name+"</strong>");
  267. ul_for_ob = $("<ul>");
  268. $.each(cri.all_objectives, function(ind, obj){
  269. li2 = $("<li>").html(obj.text)
  270. ul_for_ob.append(li2);
  271. })
  272. li.append(ul_for_ob);
  273. ol_crit.append(li);
  274. })
  275. $(modal_name).modal('show');
  276. }
  277. )
  278. }
  279. /*
  280. function createTable(){
  281. $.post("{{URL::action('TemplatesController@onLoadFetch')}}",
  282. {id :{{$template->id}}},
  283. function (json){
  284. table = $('#RubricTable');
  285. for(criterionIndex in json.criteria ){
  286. criterion = json.criteria[criterionIndex];
  287. trFull = '<tr data-criterion-copyright="'+criterion.copyright+'" data-criterion-notes="'+criterion.notes+'">';
  288. trFull+= '<td>'+(parseInt(criterionIndex)+1)+'.</td>';
  289. if(criterion.notes){
  290. trFull+= '<td><span><em data-toggle="tooltip" data-placement="top" title="'+criterion.notes+'">'+criterion.name+'</em></span><sup></sup></td>';
  291. //if(criterion.subcriteria){
  292. //}
  293. }
  294. else{
  295. trFull+='<td><span>'+criterion.name+'</span><sup></sup></td>';
  296. }
  297. for(scalesIndex in json.scales[criterion.criterion_id]){
  298. scale = json.scales[criterion.criterion_id][scalesIndex];
  299. trFull += '<td>'+scale.description+'</td>';
  300. }
  301. trFull += '<td>Prueba</td>';
  302. trFull +='</tr>';
  303. $("#bodyRubric").append(trFull);
  304. }
  305. }, 'json'
  306. );
  307. }**/
  308. </script>
  309. @stop
  310. @section('included-js')
  311. @include('global._datatables_js')
  312. @stop
  313. @section('javascript')
  314. // --------------------------------------------------------------------------
  315. // Page load
  316. // --------------------------------------------------------------------------
  317. buildCopyrightList();
  318. // --------------------------------------------------------------------------
  319. // Functions
  320. // --------------------------------------------------------------------------
  321. // Build list from copyright info in template
  322. function buildCopyrightList()
  323. {
  324. // Empty the copyright list
  325. $('#copyright-list').empty();
  326. $('tbody tr').each(function( index )
  327. {
  328. var criterion = $(this);
  329. // If there's copyright info (in this particular view, it checks for empty strings)
  330. if(criterion.data('criterion-copyright')!='')
  331. {
  332. var copyright = criterion.data('criterion-copyright');
  333. // If there is anything in the copyright list
  334. if($('#copyright-list li').length>0)
  335. {
  336. // Check copyright list for the same copyright text
  337. var found = false;
  338. $('#copyright-list li').each(function()
  339. {
  340. // If found, give the string its number
  341. if(copyright==$(this).find('span').text())
  342. {
  343. copyrightNumber = Number.parseInt($(this).find('sup').text());
  344. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  345. found =true;
  346. //to break
  347. return false;
  348. }
  349. });
  350. // Otherwise, give it the next number and append a new item to the
  351. // list
  352. if(!found)
  353. {
  354. var copyrightNumber = $('#copyright-list li').length+1;
  355. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  356. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  357. }
  358. }
  359. // Otherwise, give it number 1 and append it
  360. else
  361. {
  362. criterion.children('td:nth-child(2)').find('sup').text('1');
  363. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  364. }
  365. }
  366. });
  367. if($('#copyright-info li').length>0)
  368. {
  369. $('#copyright-info').show();
  370. }
  371. else
  372. {
  373. $('#copyright-info').hide();
  374. }
  375. }
  376. @stop