No Description

annual_report.blade.php 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. @extends('layouts.master-2')
  2. @section('navigation')
  3. @if (Auth::user()->role == 1)
  4. @include('local.managers.admins._navigation')
  5. @elseif(Auth::user()->role == 2)
  6. @include('local.managers.sCoords._navigation')
  7. @elseif(Auth::user()->role == 3)
  8. @include('local.managers.pCoords._navigation')
  9. @elseif(Auth::user()->role == 4)
  10. @include('local.professors._navigation')
  11. @endif
  12. @stop
  13. @section('main')
  14. {{-- TODO: look where to place this script.
  15. if placed inside .ready() or before it,
  16. an error that the function is not defined occurs. --}}
  17. {{-- TODO: no reconoce acentos --}}
  18. <div class="row">
  19. <div class="col-md-3">
  20. <select class="form-control selectpicker" id="annual_plan" onchange="fetchInfo('annual_plan')">
  21. <option value='0'> Nothing Selected</option>
  22. @foreach ($annual_plans as $an_plan)
  23. <option value={{ $an_plan->annual_id }}>Plan {{ $an_plan->academic_year }}</option>
  24. @endforeach
  25. </select>
  26. <br>
  27. <div id='allOutcomes'>
  28. </div>
  29. </div>
  30. <div class="col-md-9">
  31. <div id="outcome-display" class="panel panel-default">
  32. <div class="panel-heading">
  33. <h4 class=" panel-title" style="cursor:auto!important;">
  34. Primer Semestre 2019-2020
  35. </h4>
  36. </div>
  37. <div class="panel-body">
  38. <div id='outcomeInfo'>
  39. </div>
  40. <div id="tableOutcome">
  41. </div>
  42. <ul id="levelTabs" class="nav nav-tabs" role="tablist">
  43. <li role = "presentation" id = 'transformative_for_outcome'>
  44. <a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" aria-expanded="true">Transformative Actions</a>
  45. </li>
  46. </ul>
  47. <div id="allLists" class="tab-content">
  48. <div role="tabpanel" class="tab-pane active" id="transformative_actions">
  49. </div>
  50. </div>
  51. <!-- <div class="table-responsive">
  52. <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
  53. <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
  54. <tbody>
  55. </tbody>
  56. </table>
  57. </div>-->
  58. </div>
  59. </div>
  60. </div>
  61. <div class="col-md-9">
  62. <div class="no-outcome alert alert-info">
  63. <p>Select a Learning Outcome to view its information</p>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="modal fade" id="modal-status-trans">
  68. <div class="modal-dialog modal-lg">
  69. <div class="modal-content">
  70. <div class="modal-header">
  71. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  72. aria-hidden="true">&times;</span></button>
  73. <h3 class="modal-title"></h3>
  74. </div>
  75. <div class="modal-body">
  76. <h5 id="was_it_implemented"> </h5>
  77. <label class="radio-inline">
  78. <input type="radio" name="implemented" value = "1">Yes</label>
  79. <label class="radio-inline">
  80. <input type="radio" name="implemented" value = "0">No</label>
  81. <br>
  82. <div id='useful_radio_div'>
  83. <h5>Was this transformative action helpful to achieve the learning expectation?</h5>
  84. <label class="radio-inline">
  85. <input type="radio" name="useful" value = "1">Yes</label>
  86. <label class="radio-inline">
  87. <input type="radio" name="useful" value = "0">No</label>
  88. </div>
  89. <br>
  90. <div id='comment_div'>
  91. <label id="implement_textarea" for='comments'></label>
  92. <textarea class="form-control" id='comments'>
  93. </textarea>
  94. </div>
  95. </div>
  96. <div class='modal-footer'>
  97. <button type="button" class="btn btn-secondary" data-dismiss="modal" >Cancel</button>
  98. <button type="button" class="btn btn-primary" id ="save_transformative_info" onclick ='saveTransReport()'>Save</button>
  99. </div><!-- /.modal-content -->
  100. </div><!-- /.modal-dialog -->
  101. </div><!-- /.modal -->
  102. <script>
  103. function nextChar(c) {
  104. return String.fromCharCode(c.charCodeAt(0) + 1);
  105. }
  106. changed = false;
  107. $(document).ready(function() {
  108. // --------------------------------------------------------------------------
  109. // Page load
  110. // --------------------------------------------------------------------------
  111. $('#comment_div').hide();
  112. $('input[name="implemented"]').change(function(){
  113. //was implemented
  114. if(!parseInt($(this).val())){
  115. $('#useful_radio_div').hide();
  116. $('#comment_div').show();
  117. $('#comments').val(' ');
  118. $('#implement_textarea').html("Explain briefly why this transformative action was not implemented");
  119. }
  120. else{
  121. $('#useful_radio_div').show();
  122. $('#comment_div').show();
  123. $('#implement_textarea').html("Explain briefly details about the implementation of this transformative action");
  124. }
  125. })
  126. // Hide accordion panel contents by default
  127. $('.panel-group .panel-body').hide();
  128. $('#outcome-display').parent().hide();
  129. });
  130. function draw_comment_section(typ_semester_outcome_id, outcome_comments){
  131. $('#levelTabs').append('<li role = "presentation" id = "comments_for_outcome">'+
  132. '<a data-toggle="tab" id="a_for_ta_outcome" href="#comments_outcome" role="tab" >Comments for Outcome</a>'+
  133. '</li>');
  134. $('#allLists').append('<div role="tabpanel" class="tab-pane" data-typ-semester-outcome-id = "'+typ_semester_outcome_id+'" id="comments_outcome"></div>');
  135. button_for_adding_comments = $('<button>', {
  136. 'class':'btn btn-secondary',
  137. 'id':'add_comments_button',
  138. 'style':'float: right',
  139. 'onclick': 'add_comments_to_plan()'
  140. }).html("<span class='glyphicon glyphicon-plus'></span> Add Comments");
  141. $('#comments_outcome').append('<h3>Comments</h3>')
  142. if(outcome_comments.length){
  143. table_for_comments = $('<table>',{
  144. 'class':'table table-striped table-condensed datatable',
  145. 'id':'table_for_comments'
  146. }).html('<thead><th>Comments</th><th>Edit or Delete</th></thead><tbody></tbody>');
  147. table_for_comments.appendTo('#comments_outcome');
  148. table_for_comments = table_for_comments.DataTable();
  149. $.each(outcome_comments, function(index, comment){
  150. comment_td = '<div id="comments_id_'+comment.id+'">'+comment.comments+'</div>';
  151. inputEdit = $('<input>', {
  152. 'type': 'button',
  153. 'class': 'btn btn-secondary',
  154. 'onclick': 'add_comments_to_plan('+comment.id+')',
  155. 'id': 'edit_button_comment_' + comment.id,
  156. 'value': 'Edit'
  157. }).html('Edit');
  158. inputDelete = $('<input>', {
  159. 'type': 'button',
  160. 'class': 'btn btn-primary',
  161. 'style': 'display: inline',
  162. 'onclick': 'deleteCommentsFromOutcome('+comment.id+')',
  163. 'value': 'Delete'
  164. })
  165. div = $('<div>');
  166. div.append(inputEdit);
  167. div.append(inputDelete);
  168. table_for_comments.row.add([
  169. comment_td,
  170. div.html()
  171. ]).draw();
  172. });
  173. }
  174. $('#comments_outcome').append('<hr>');
  175. $('#comments_outcome').append(button_for_adding_comments);
  176. }
  177. function add_comments_to_plan(edit_id = null){
  178. $('#add_comments_button').hide();
  179. div_for_inputs = $('<div>', {
  180. 'id':'add_comment_div'
  181. });
  182. textarea = $('<textarea>',{
  183. 'class':'form-control',
  184. 'data-comment-id':edit_id,
  185. 'id':'comment_textbox'
  186. });
  187. if(edit_id){
  188. textarea.val($("#comments_id_"+edit_id).html());
  189. }
  190. save_button = $('<button>', {
  191. 'class':'btn btn-primary',
  192. 'onclick':'saveComment()',
  193. 'style':'float: right'
  194. }).html('Save');
  195. $('#comments_outcome').append(div_for_inputs);
  196. div_for_inputs.append('<h5>Add new comment</h5>');
  197. div_for_inputs.append(textarea);
  198. div_for_inputs.append(save_button);
  199. }
  200. function saveComment(){
  201. typ_outcome_semester_id = $("#comments_outcome").data('typ-semester-outcome-id');
  202. comment_area = $('#comment_textbox');
  203. $.post(
  204. "{{URL::action('AnnualPlansController@addCommentsToOutcome')}}",
  205. {
  206. typ_outcome_semester_id:typ_outcome_semester_id,
  207. comments:comment_area.val(),
  208. edit_id:comment_area.data('comment-id')
  209. },
  210. function(edit_id){
  211. $('#add_comment_div').remove();
  212. $('#add_comments_button').show();
  213. if($('#comments_id_'+edit_id).length){
  214. $('#comments_id_'+edit_id).html(comment_area.val());
  215. }
  216. else{
  217. table_for_comments = $('#table_for_comments').DataTable();
  218. comment_td = '<div id="comments_id_'+edit_id+'">'+comment_area.val()+'</div>';
  219. inputEdit = $('<input>', {
  220. 'type': 'button',
  221. 'class': 'btn btn-secondary',
  222. 'onclick': 'add_comments_to_plan('+edit_id+')',
  223. 'id': 'edit_button_comment_' + edit_id,
  224. 'value': 'Edit'
  225. }).html('Edit');
  226. inputDelete = $('<input>', {
  227. 'type': 'button',
  228. 'class': 'btn btn-primary',
  229. 'style': 'display: inline',
  230. 'onclick': 'deleteCommentsFromOutcome('+edit_id+')',
  231. 'value': 'Delete'
  232. })
  233. div = $('<div>');
  234. div.append(inputEdit);
  235. div.append(inputDelete);
  236. table_for_comments.row.add([
  237. comment_td,
  238. div.html()
  239. ]).draw();
  240. }
  241. }
  242. )
  243. }
  244. function deleteCommentsFromOutcome(id){
  245. $.post(
  246. "{{URL::action('AnnualPlansController@deleteCommentsFromOutcome')}}",
  247. {id:id},
  248. function(){
  249. $('#comments_id_'+id).parent().parent().remove();
  250. }
  251. )
  252. }
  253. // Create everything
  254. function draw_transformative_actions(transforming_actions, semester_id){
  255. if(!transforming_actions.length){
  256. $("#transformative_for_outcome").hide();
  257. }
  258. else{
  259. $('#levelTabs').prepend('<li role = "presentation" id = "transformative_for_outcome">'+
  260. '<a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" >Transformative Actions to Outcome</a>'+
  261. '</li>');
  262. $('#allLists').prepend('<div role="tabpanel" class="tab-pane" id="transformative_actions"></div>');
  263. $('#transformative_actions').html('<h3>Tranformative actions for Learning Outcome')
  264. $.each(transforming_actions, function(index, trans_action){
  265. div = $("<div>", {
  266. 'id':'div_trans_id_'+trans_action.trans_id
  267. }).html('<p><strong>'+(index+1)+'. '+trans_action.at_text+': </strong>'+trans_action.description+'</p>'+
  268. '<p><strong>Category: </strong> '+trans_action.type_of_TA+'</p>');
  269. div.append('<label>Results: </label>')
  270. input_results = $("<textarea>", {
  271. 'class':'form-control',
  272. 'id':'results_for_'+trans_action.trans_id
  273. });
  274. div.append(input_results)
  275. div.append('<h5>Was this transformative action helpful to achieve the learning expectation?</h5>'+
  276. '<label class="radio-inline">'+
  277. '<input type="radio" name="useful_for_'+trans_action.trans_id+'" value = "1">Yes</label>'+
  278. '<label class="radio-inline">'+
  279. '<input type="radio" name="useful_for_'+trans_action.trans_id+'" value = "0">No</label>');
  280. comments = $('<textarea>',{
  281. 'id':'comments_for_'+trans_action.trans_id,
  282. 'class':'form-control'
  283. });
  284. div.append('<br><label>Explain briefly details about the implementation</label>');
  285. div.append(comments);
  286. button = $('<button>',{
  287. "type":"button",
  288. "class":"btn btn-primary",
  289. "onclick":'saveTransReport('+trans_action.trans_id+', '+semester_id+')',
  290. 'style':'float: right'
  291. }).html('Save');
  292. div.append('<br>');
  293. div.append(button);
  294. div.append('<br>');
  295. div.append('<hr>');
  296. $('#transformative_actions').append(div);
  297. $('#results_for_'+trans_action.trans_id).val(trans_action.results);
  298. $('#comments_for_'+trans_action.trans_id).val(trans_action.comments);
  299. $('input[name="useful_for_'+trans_action.trans_id+'"][value="'+trans_action.it_was_useful + '"]').prop('checked', true);
  300. })
  301. }
  302. }
  303. function fetchEverything(li) {
  304. var outcome_id = $(li).data('outcome-id');
  305. var name = $(li).data('outcome-name');
  306. var semester_id = $(li).data('semester-id');
  307. var annual_plan_id = $(li).data('annual-plan');
  308. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  309. $('#theChange').data('annual-plan', annual_plan);
  310. $.post(
  311. "{{ URL::action('AnnualPlansController@fetchReportWithOutcome') }}", {
  312. semester_id: semester_id,
  313. outcome_id: outcome_id,
  314. program_id: {{ $program->id }},
  315. annual_plan_id: annual_plan_id,
  316. typ_semester_outcome_id: typ_semester_outcome_id
  317. },
  318. function(outcome) {
  319. if (outcome.objectives) {
  320. $('table').show();
  321. $('#outcome-display').parent().show();
  322. $('#outcome-display .panel-title').html(name);
  323. $('#allLists').empty();
  324. $('#levelTabs').empty();
  325. $('.no-outcome').hide();
  326. if (outcome.outcome_program_goal) {
  327. outcome.outcome_program_goal = outcome.outcome_program_goal.expected_target;
  328. } else {
  329. outcome.outcome_program_goal = 'It has not been defined';
  330. }
  331. var outcomeHTML = "<h4>Performance of Students by Learning Outcome</h4>" +
  332. '<h5 style = "display: inline; margin:30px;">Target learning by learning outcome: </h5>' +
  333. '<p style = "display: inline;"> <i>>= ' + outcome.expected_outcome +
  334. ' of the attempts</i>' + '</p>' +
  335. '<br><h5 style = "display: inline; margin:30px;">Expected percent of students achieving the target by learning outcome: </h5>' +
  336. '<p style = "display: inline;"> <i>' + outcome.outcome_program_goal + '</i></p>';
  337. $('#outcomeInfo').html('<p class="outcome-definition">' + outcome.definition + '</p>' +
  338. outcomeHTML);
  339. //theStudentOutcomeTable = $("<table/>");
  340. //theStudentOutcomeTable.hide();
  341. ///$('#outcomeInfo').append(theStudentOutcomeTable);
  342. wholeDict = {};
  343. tableStudent = $('<table/>', {
  344. 'class': 'table table-striped table-condensed datatable'
  345. });
  346. tableStudent.html('<thead><tr>' +
  347. '<th>Student</th>' +
  348. '<th>Criteria Attempted</th>' +
  349. '<th>Criteria Achieved</th>' +
  350. '<th>Percentage</th>' +
  351. '<th>Outcome Achieved</th>' +
  352. '</tr></thead><tbody></tbody>');
  353. first_objective_id = outcome.objectives[0].id;
  354. $.each(outcome.objectives, function(index, objective) {
  355. li = $('<li/>', {
  356. 'role': 'presentation',
  357. 'id':'li_for_'+objective.id
  358. });
  359. a = $('<a/>', {
  360. 'data-toggle': 'tab',
  361. 'id': 'a_for_'+objective.id,
  362. 'href': '#' + objective.id,
  363. 'role': 'tab'
  364. }).html('Objective ' + (index + 1));
  365. li.append(a);
  366. $('#levelTabs').append(li);
  367. objective_title = "<h3>" + objective.text + '</h3>';
  368. div = $('<div/>', {
  369. 'role': 'tabpanel',
  370. 'class': 'tab-pane',
  371. 'id': objective.id
  372. }).html(objective_title);
  373. div.appendTo($('#allLists'))
  374. div.append(
  375. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  376. );
  377. if (objective.courses) {
  378. $.each(objective.courses, function(index, course_code) {
  379. if (course_code.criteria.length) {
  380. $.each(course_code.students, function(index, student) {
  381. if (wholeDict[student.student_id] === undefined) {
  382. wholeDict[student.student_id] = {
  383. 'student': student.student_id,
  384. 'criteria_attempted': 0,
  385. 'criteria_achieved': 0
  386. }
  387. }
  388. wholeDict[student.student_id][
  389. "criteria_attempted"
  390. ] += student
  391. .criteria_attempted;
  392. wholeDict[student.student_id][
  393. "criteria_achieved"
  394. ] += student
  395. .criteria_achieved;
  396. });
  397. /*div.append(
  398. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  399. );*/
  400. table = $('<table/>', {
  401. 'class': 'table table-striped table-condensed datatable'
  402. }).html('<thead><th>Criterion</th><th>' +
  403. 'Number of Students Assessed </th>' +
  404. '<th>Number of students that achieved the target</th></thead>'
  405. );
  406. tbody = $('<tbody/>')
  407. $.each(course_code.criteria, function(index, criterion) {
  408. tr = $('<tr/>').append(
  409. "<td>" + criterion.name + "</td>" +
  410. "<td>" + criterion.criteria_attempted +
  411. "</td>" +
  412. "<td>" + criterion.criteria_achieved +
  413. "</td>"
  414. );
  415. tbody.append(tr);
  416. });
  417. table.append(tbody);
  418. Course_section = '<h3>' + course_code.code + ' ' +
  419. course_code.number + '</h3><hr>';
  420. div.append(Course_section)
  421. div.append('<h4> Criteria Assessed in '+course_code.code+' '+course_code.number+'</h4>')
  422. div.append(table);
  423. if (course_code.transforming_actions.length) {
  424. table_for_transformative_actions = $('<table>',{
  425. 'class': 'table table-striped table-condensed datatable'
  426. }).html('<thead><th>Transformative Actions Proposed in Annual Plan</th>' +
  427. '<th>Follow up </th>' +
  428. '</thead>'
  429. );
  430. tbody_for_transformative_actions = $('<tbody>');
  431. $.each(course_code.transforming_actions, function(index,
  432. transformative_action) {
  433. button_for_followup = $('<button>',{
  434. 'class':'btn btn-secondary',
  435. 'onclick':'give_follow_up_questions('+transformative_action.id+', "'+outcome.semester_info.code+'", '+outcome.semester_info.id+')'
  436. }).html('Follow Up Questions');
  437. table_row = "<tr>"+
  438. '<td><p><strong>'+transformative_action.at_text +': </strong>'+
  439. transformative_action.description+'</p></td>'+
  440. '<td>'+button_for_followup.prop('outerHTML')+'</td></tr>';
  441. tbody_for_transformative_actions.append(table_row)
  442. })
  443. table_for_transformative_actions.append(tbody_for_transformative_actions);
  444. div.append('<hr><h4>Transformative actions for '+course_code.code+' '+course_code.number+'</h4>')
  445. div.append(table_for_transformative_actions);
  446. //table_for_transformative_actions.DataTable();
  447. }
  448. table.DataTable();
  449. }
  450. })
  451. } else {
  452. div.append('<div class="no-outcome alert alert-info"' +
  453. '<p>No Course in plan has assessed yet</p>' +
  454. '</div>')
  455. }
  456. })
  457. draw_transformative_actions(outcome.transforming_actions, outcome.semester_info.id)
  458. draw_comment_section(typ_semester_outcome_id, outcome.comments);
  459. //$('#a_for_'+first_objective_id).click();
  460. theArray = [];
  461. $('#tableOutcome').html(tableStudent);
  462. //tableStudent.appendTo($('#outcomeInfo'));
  463. tableStudent = tableStudent.DataTable({
  464. dom: 'Bfrtip',
  465. buttons: [
  466. 'csv', 'excel', 'pdf', 'print'
  467. ]
  468. });
  469. students_attempted = 0;
  470. students_achieved = 0;
  471. $.each(wholeDict, function(key, dict) {
  472. if (dict.criteria_attempted) {
  473. students_attempted += 1;
  474. percentage = ((dict.criteria_achieved / dict.criteria_attempted) * 100).toFixed(
  475. 2);
  476. if (parseFloat(percentage) >= parseFloat(outcome.expected_outcome)) {
  477. achieved = "Yes"
  478. students_achieved += 1;
  479. } else achieved = "No"
  480. } else {
  481. percentage = "N/A"
  482. achieved = "N/A"
  483. }
  484. tableStudent.row.add([
  485. dict.student,
  486. dict.criteria_attempted,
  487. dict.criteria_achieved,
  488. percentage,
  489. achieved
  490. ]);
  491. })
  492. tableStudent.draw();
  493. if (students_attempted) {
  494. studentPercentage = ((students_achieved / students_attempted) * 100).toFixed(2);
  495. if (parseFloat(studentPercentage) >= parseFloat(outcome.outcome_program_goal)) {
  496. FinalReport = "<br><p><strong>The students achieved the Learning Outcome with " +
  497. studentPercentage + "% of students achieving.</strong></p>";
  498. } else {
  499. FinalReport = "<br><p><strong>The students did not achieve the Learning Outcome with " +
  500. studentPercentage + "% of students achieving.</strong></p>";
  501. }
  502. }
  503. $("#outcomeInfo").append(FinalReport)
  504. /* table.row.add([
  505. objectivesHTML,
  506. courseshtml,
  507. courseTAhtml
  508. ]);
  509. table.draw();
  510. */
  511. } else {
  512. $('table').hide();
  513. }
  514. }
  515. );
  516. }
  517. function give_follow_up_questions(trans_id, semester_code, semester_id){
  518. $.ajax({
  519. type: 'POST',
  520. url: "{{ URL::action('TransformativeActionsController@fetchStatus') }}",
  521. data: {
  522. trans_id:trans_id,
  523. semester_id:semester_id
  524. },
  525. success: function(transformative_action_with_status) {
  526. transformative_action = transformative_action_with_status[0];
  527. $('.modal-title').html('<strong>'+transformative_action.at_text+'</strong>: '+transformative_action.description);
  528. $('input[name="implemented"]').prop('checked',false);
  529. $('input[name="useful"]').prop('checked',false);
  530. $('#comments').val(' ');
  531. $('#useful_radio_div').hide();
  532. $('#comment_div').hide();
  533. if(transformative_action['status']){
  534. transformative_action['status'].accomplished;
  535. $('input[name="implemented"][value="'+ transformative_action['status'].accomplished + '"]').prop('checked', true);
  536. if(transformative_action['status'].accomplished){
  537. $('#useful_radio_div').show();
  538. $('input[name="useful"][value="'+ transformative_action['status'].it_was_useful + '"]').prop('checked', true);
  539. }
  540. $('#comment_div').show();
  541. $('#comments').val(transformative_action['status'].comments);
  542. }
  543. $('#was_it_implemented').html('Was this transformative action implemented during Semester '+semester_code);
  544. $('#modal-status-trans').modal();
  545. $('#save_transformative_info').attr('onclick', 'saveTransReport('+trans_id+','+semester_id+',"modal")');
  546. },
  547. async: true
  548. });
  549. }
  550. function saveTransReport(trans_id, semester_id, type_of_input){
  551. if(type_of_input=='modal'){
  552. comments = $('#comments').val();
  553. accomplished = parseInt($('input[name="implemented"]:checked').val());
  554. if(accomplished)
  555. was_it_useful = $('input[name="useful"]:checked').val();
  556. else was_it_useful =0;
  557. results = "";
  558. }
  559. else{
  560. comments = $('#comments_for_'+trans_id).val();
  561. accomplished = 1;
  562. was_it_useful = $('input[name="useful_for_'+trans_id+'"]:checked').val();
  563. results = $('#results_for_'+trans_id).val();
  564. }
  565. $.post(
  566. "{{URL::action('TransformativeActionsController@saveTransStatus')}}",
  567. {
  568. semester_id:semester_id,
  569. trans_id:trans_id,
  570. results:results,
  571. comments:comments,
  572. accomplished:accomplished,
  573. was_it_useful:was_it_useful,
  574. },
  575. function(message){
  576. alert(message);
  577. }
  578. )
  579. }
  580. function posttoTransAnnual(annual_id, selectTransId, typ_course_id) {
  581. ta = $("#" + selectTransId).val();
  582. old_ta = $("#" + selectTransId).data('old-TA');
  583. if (ta == "0") return;
  584. $.post("../annual-plan-postTA", {
  585. annual_id: annual_id,
  586. TA_id: ta,
  587. typ_course_id: typ_course_id,
  588. old_ta: old_ta
  589. },
  590. function(message) {
  591. $("#" + selectTransId).data('old-TA', ta);
  592. }
  593. )
  594. }
  595. function addTAselect(options, master_div, annual_plan_id, objective_id, typ_course_id, selected_ta) {
  596. var $div = $('<div/>', {
  597. 'class': 'form-group '
  598. });
  599. counter = parseInt($('#' + master_div).data('amount-ta'));
  600. var selectTA = $('<select/>', {
  601. 'class': "selectpicker form-control",
  602. 'data-live-search': 'true',
  603. 'data-old-TA': '0',
  604. 'data-width': '180px',
  605. 'id': 'transformativeForObjective' + master_div + '_' + counter,
  606. 'onchange': 'posttoTransAnnual(' + annual_plan_id + ', "transformativeForObjective' + master_div +
  607. '_' + counter + '", ' + typ_course_id + ')'
  608. });
  609. selectTA.append(options);
  610. selectTA.appendTo($div);
  611. selectTA.val(selected_ta);
  612. selectTA.data('old-TA', selected_ta);
  613. selectTA.selectpicker('refresh');
  614. $span = $('<span/>', {
  615. 'id': 'close',
  616. 'onclick': ' postDeleteTA(' + annual_plan_id + ', "transformativeForObjective' + master_div + '_' +
  617. counter + '", ' + typ_course_id +
  618. '); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  619. }).html('x');
  620. $span.appendTo($div);
  621. $div.append("<br><br>");
  622. $('#' + master_div).append("<br>");
  623. $div.appendTo($('#' + master_div));
  624. $('#' + master_div).data('amount-ta', counter + 1);
  625. }
  626. function postDeleteTA(annual_id, selectTransId, typ_course_id) {
  627. ta = $("#" + selectTransId).val();
  628. if (ta == "0") return;
  629. $.post("../annual-plan-deleteTA", {
  630. annual_id: annual_id,
  631. TA_id: ta,
  632. typ_id: typ_course_id,
  633. });
  634. parent = $("#" + selectTransId).parent().parent().parent();
  635. counter = parseInt(parent.data('amount-ta'));
  636. parent.data('amount-ta', counter - 1);
  637. }
  638. function postToAnnualPlans(typ_course_id, criteria_select) {
  639. var criteria = $('#' + criteria_select).val();
  640. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  641. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  642. var annual = criteriaNode.dataset.annualPlan;
  643. $.post("../annual-plan-postOnChange", {
  644. criteria: criteria,
  645. typ_course_id: typ_course_id,
  646. annual_plan: annual,
  647. old_criteria: oldCriteria
  648. },
  649. function(message) {
  650. if (message == "Duplicate entry, please choose another criteria.") {
  651. alert(message)
  652. } else {
  653. $('#' + criteria_select).data('old-criteria', criteria);
  654. changed = true;
  655. }
  656. })
  657. }
  658. function addCriteriaTest(div, new_id_for_select, typ_course_id, i = null, options) {
  659. if (!i) amount_select = $('#' + div).data("amount-select");
  660. else amount_select = i;
  661. $select = $('<select/>', {
  662. 'class': "selectpicker form-control",
  663. 'data-live-search': 'true',
  664. 'data-old-criteria': '0',
  665. 'data-width': '180px',
  666. 'id': 'criteriaFor' + new_id_for_select + '_' + amount_select,
  667. 'onchange': 'postToAnnualPlans(' + typ_course_id + ', "criteriaFor' + new_id_for_select + '_' +
  668. amount_select + '")'
  669. })
  670. var $div = $('<div/>', {
  671. 'id': 'courseSelect_' + new_id_for_select + '_' + amount_select,
  672. 'class': 'form-group '
  673. });
  674. $select.append(options);
  675. $select.appendTo($div);
  676. $span = $('<span/>', {
  677. 'id': 'close',
  678. 'onclick': ' postDelete(' + typ_course_id + ', "criteriaFor' + new_id_for_select + '_' +
  679. amount_select + '"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  680. }).html('x');
  681. $div.append($span);
  682. $div.append("<br><br>")
  683. $('#' + div).append("<br>");
  684. $div.appendTo($("#" + div));
  685. $select.selectpicker('refresh');
  686. $("#" + div).data("amount-select", amount_select + 1);
  687. }
  688. $('#allOutcomes').hide();
  689. function postDelete(typ_course_id, criteria_select) {
  690. var criteria = $('#' + criteria_select).val();
  691. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  692. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  693. var annual = criteriaNode.dataset.annualPlan;
  694. $.post("../annual-plan-deleteCriteria", {
  695. criteria: criteria,
  696. typ_course_id: typ_course_id,
  697. annual_plan: annual,
  698. old_criteria: oldCriteria
  699. });
  700. }
  701. function fetchInfo(id) {
  702. annual_id = $("#" + id).val();
  703. program_id = {{ $program->id }};
  704. $.post("{{ URL::action('AnnualPlansController@fetchInfo') }}", {
  705. id: annual_id,
  706. program_id: program_id
  707. },
  708. function(json) {
  709. div = $('<div/>', {
  710. 'class': 'list-group',
  711. 'id': 'list'
  712. });
  713. if (json.outcomes.first) {
  714. header5 = $('<h5/>', {
  715. 'style': "padding-left: 10px"
  716. }).html("First Semester");
  717. div.append(header5);
  718. list = '';
  719. for (outcome in json.outcomes.first) {
  720. list +=
  721. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  722. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.first[
  723. outcome].typ_semester_outcome_id + "' data-semester-id = '" + json.allSemesterOrder
  724. .first.id +
  725. "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" +
  726. json
  727. .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[
  728. outcome]
  729. .name + " </li>";
  730. }
  731. div.append(list);
  732. }
  733. if (json.outcomes.second) {
  734. header4 = $('<h5/>', {
  735. 'style': "padding-left: 10px"
  736. }).html("Second Semester");
  737. div.append(header4);
  738. list = '';
  739. for (outcome in json.outcomes.second) {
  740. list +=
  741. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  742. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.second[
  743. outcome].typ_semester_outcome_id + "'data-semester-id = '" + json.allSemesterOrder
  744. .second.id +
  745. "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" +
  746. json
  747. .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
  748. outcome].name + " </li>";
  749. }
  750. div.append(list);
  751. }
  752. html = div[0].innerHTML;
  753. $("#allOutcomes").html(div[0].innerHTML);
  754. $("#allOutcomes").show();
  755. },
  756. "json",
  757. );
  758. }
  759. function deleteObjective(objectiveSelectDiv, closeObj) {
  760. $('#' + objectiveSelectDiv).remove();
  761. $('#' + closeObj).remove();
  762. $('#' + div).data("amount-select", $('#' + div).data("amount-select") - 1);
  763. }
  764. </script>
  765. @stop
  766. @section('included-js')
  767. @include('global._datatables_js')
  768. @stop