No Description

annual_report.blade.php 81KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. @extends('layouts.master-2')
  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. {{-- 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" data-live-search="true" 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. <hr>
  30. <div id="printButton" class="text-center"></div>
  31. </div>
  32. <div class="col-md-9">
  33. <div id="outcome-display" class="panel panel-default">
  34. <div class="panel-heading">
  35. <h4 class=" panel-title" style="cursor:auto!important;">
  36. Primer Semestre 2019-2020
  37. </h4>
  38. </div>
  39. <div class="panel-body">
  40. <div id='outcomeInfo'>
  41. </div>
  42. <div id="tableOutcome">
  43. </div>
  44. <ul id="levelTabs" class="nav nav-tabs" role="tablist">
  45. <li role="presentation" id='transformative_for_outcome'>
  46. <a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab"
  47. aria-expanded="true">Program Transformative Actions</a>
  48. </li>
  49. </ul>
  50. <div id="allLists" class="tab-content">
  51. <div role="tabpanel" class="tab-pane active" id="transformative_actions">
  52. </div>
  53. </div>
  54. <!-- <div class="table-responsive">
  55. <table class="table table-striped table-condensed datatable" style="table-layout: fixed ; width : 100%">
  56. <thead><tr><th>Objectives for courses</th><th>Criteria per Course</th><th>Transformative Actions</th></tr></thead>
  57. <tbody>
  58. </tbody>
  59. </table>
  60. </div>-->
  61. </div>
  62. </div>
  63. </div>
  64. <div class="col-md-9">
  65. <div class="no-outcome alert alert-info">
  66. <p>Select a Learning Outcome to view its information</p>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="modal fade" id="modal-status-trans">
  71. <div class="modal-dialog modal-lg">
  72. <div class="modal-content">
  73. <div class="modal-header">
  74. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  75. aria-hidden="true">&times;</span></button>
  76. <h3 id='transformative_modal_title' class="modal-title"></h3>
  77. </div>
  78. <div class="modal-body">
  79. <h5 id="was_it_implemented"> </h5>
  80. <label class="radio-inline">
  81. <input type="radio" name="implemented" value="1">Yes</label>
  82. <label class="radio-inline">
  83. <input type="radio" name="implemented" value="0">No</label>
  84. <br>
  85. <div id='useful_radio_div'>
  86. <h5>Was this transformative action helpful to achieve the learning expectation?</h5>
  87. <label class="radio-inline">
  88. <input type="radio" name="useful" value="1">Yes</label>
  89. <label class="radio-inline">
  90. <input type="radio" name="useful" value="0">No</label>
  91. </div>
  92. <br>
  93. <div id='comment_div'>
  94. <label id="implement_textarea" for='comments'></label>
  95. <textarea class="form-control" id='comments'>
  96. </textarea>
  97. </div>
  98. </div>
  99. <div class='modal-footer'>
  100. <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  101. <button type="button" class="btn btn-primary" id="save_transformative_info"
  102. onclick='saveTransReport()'>Save</button>
  103. </div><!-- /.modal-content -->
  104. </div><!-- /.modal-dialog -->
  105. </div><!-- /.modal -->
  106. </div>
  107. <div class="modal fade" id="modal-future-trans-course">
  108. <div class="modal-dialog modal-lg">
  109. <div class="modal-content">
  110. <div class="modal-header">
  111. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  112. aria-hidden="true">&times;</span></button>
  113. <h3 class="modal-title"></h3>
  114. </div>
  115. <div class="modal-body">
  116. </div>
  117. <div class='modal-footer'>
  118. <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  119. <button type="button" class="btn btn-primary" id="save_transformative_info"
  120. onclick='saveTransReport()'>Save</button>
  121. </div>
  122. </div><!-- /.modal-content -->
  123. </div><!-- /.modal-dialog -->
  124. </div><!-- /.modal -->
  125. <div class="modal fade" id="modal-delete-ta">
  126. <div class="modal-dialog modal-lg">
  127. <div class="modal-content">
  128. <div class="modal-header">
  129. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  130. aria-hidden="true">&times;</span></button>
  131. <h3 class="modal-title" id="delete-ta-title"></h3>
  132. </div>
  133. <div class="modal-body" id="delete-ta-body">
  134. </div>
  135. <div class='modal-footer'>
  136. <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  137. <button type="button" class="btn btn-primary" id="delete-ta-button">Delete</button>
  138. </div>
  139. </div><!-- /.modal-content -->
  140. </div><!-- /.modal-dialog -->
  141. </div><!-- /.modal -->
  142. <div class="modal fade" id="submit-modal">
  143. <div class="modal-dialog modal-lg">
  144. <div class="modal-content">
  145. <div class="modal-header">
  146. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  147. aria-hidden="true">&times;</span></button>
  148. <h3 class="modal-title" id="submit-modal-title"></h3>
  149. </div>
  150. <div class="modal-body" id="submit-modal-body">
  151. </div>
  152. <div class='modal-footer' id='submit-modal-footer'>
  153. </div>
  154. </div><!-- /.modal-content -->
  155. </div><!-- /.modal-dialog -->
  156. </div><!-- /.modal -->
  157. <script>
  158. function nextChar(c) {
  159. return String.fromCharCode(c.charCodeAt(0) + 1);
  160. }
  161. changed = false;
  162. $(document).ready(function() {
  163. // --------------------------------------------------------------------------
  164. // Page load
  165. // --------------------------------------------------------------------------
  166. $('#comment_div').hide();
  167. $('input[name="implemented"]').change(function() {
  168. //was implemented
  169. if (!parseInt($(this).val())) {
  170. $('#useful_radio_div').hide();
  171. $('#comment_div').show();
  172. $('#comments').val(' ');
  173. $('#implement_textarea').html(
  174. "Explain briefly why this transformative action was not implemented");
  175. } else {
  176. $('#useful_radio_div').show();
  177. $('#comment_div').show();
  178. $('#implement_textarea').html(
  179. "Explain briefly details about the implementation of this transformative action"
  180. );
  181. }
  182. })
  183. // Hide accordion panel contents by default
  184. $('.panel-group .panel-body').hide();
  185. $('#outcome-display').parent().hide();
  186. });
  187. function draw_comment_section(typ_semester_outcome_id, outcome_comments) {
  188. $('#levelTabs').append('<li role = "presentation" id = "comments_for_outcome">' +
  189. '<a data-toggle="tab" id="a_for_ta_outcome" href="#comments_outcome" role="tab" >Comments</a>' +
  190. '</li>');
  191. $('#allLists').append('<div role="tabpanel" class="tab-pane" data-typ-semester-outcome-id = "' +
  192. typ_semester_outcome_id + '" id="comments_outcome"></div>');
  193. button_for_adding_comments = $('<button>', {
  194. 'class': 'btn btn-secondary',
  195. 'id': 'add_comments_button',
  196. 'style': 'float: right',
  197. 'onclick': 'add_comments_to_plan()'
  198. }).html("<span class='glyphicon glyphicon-plus'></span> Add Comments");
  199. $('#comments_outcome').append('<h3>Comments</h3>')
  200. table_for_comments = $('<table>', {
  201. 'class': 'table table-striped table-condensed datatable',
  202. 'id': 'table_for_comments'
  203. }).html('<thead><th>Comments</th><th>Edit or Delete</th></thead><tbody></tbody>');
  204. table_for_comments.appendTo('#comments_outcome');
  205. table_for_comments = table_for_comments.DataTable();
  206. if (outcome_comments.length) {
  207. $("#table_for_comments").parent().parent().parent().show();
  208. $.each(outcome_comments, function(index, comment) {
  209. comment_td = '<div id="comments_id_' + comment.id + '">' + comment.comments + '</div>';
  210. inputEdit = $('<input>', {
  211. 'type': 'button',
  212. 'class': 'btn btn-secondary',
  213. 'onclick': 'add_comments_to_plan(' + comment.id + ')',
  214. 'id': 'edit_button_comment_' + comment.id,
  215. 'value': 'Edit'
  216. }).html('Edit');
  217. inputDelete = $('<input>', {
  218. 'type': 'button',
  219. 'class': 'btn btn-primary',
  220. 'style': 'display: inline',
  221. 'onclick': 'deleteCommentsFromOutcome(' + comment.id + ')',
  222. 'value': 'Delete'
  223. })
  224. div = $('<div>');
  225. div.append(inputEdit);
  226. div.append(inputDelete);
  227. table_for_comments.row.add([
  228. comment_td,
  229. div.html()
  230. ]).draw();
  231. });
  232. }
  233. else{
  234. $("#table_for_comments").parent().parent().parent().hide();
  235. }
  236. $('#comments_outcome').append('<hr>');
  237. $('#comments_outcome').append(button_for_adding_comments);
  238. }
  239. function open_warning_modal(trans_id) {
  240. $('#delete-ta-title').html('Delete ' + $('#transformative_action_row_' + trans_id).data('at-text') + " ?")
  241. $('#delete-ta-body').html('This action cannot be undone');
  242. $('#delete-ta-button').attr('onclick', 'deleteTrans(' + trans_id + '); $("#modal-delete-ta").modal("toggle")');
  243. $('#modal-delete-ta').modal("show");
  244. }
  245. function add_comments_to_plan(edit_id = null) {
  246. $('#add_comments_button').hide();
  247. $("#add_comment_div").remove();
  248. div_for_inputs = $('<div>', {
  249. 'id': 'add_comment_div'
  250. });
  251. textarea = $('<textarea>', {
  252. 'class': 'form-control',
  253. 'data-comment-id': edit_id,
  254. 'id': 'comment_textbox'
  255. });
  256. if (edit_id) {
  257. textarea.val($("#comments_id_" + edit_id).html());
  258. }
  259. save_button = $('<button>', {
  260. 'class': 'btn btn-primary',
  261. 'onclick': 'saveComment()',
  262. 'style': 'float: right'
  263. }).html('Save');
  264. $('#comments_outcome').append(div_for_inputs);
  265. div_for_inputs.append('<h5>Add new comment</h5>');
  266. div_for_inputs.append(textarea);
  267. div_for_inputs.append(save_button);
  268. }
  269. function saveComment() {
  270. typ_outcome_semester_id = $("#comments_outcome").data('typ-semester-outcome-id');
  271. comment_area = $('#comment_textbox');
  272. $.post(
  273. "{{ URL::action('AnnualPlansController@addCommentsToOutcome') }}", {
  274. typ_outcome_semester_id: typ_outcome_semester_id,
  275. comments: comment_area.val(),
  276. edit_id: comment_area.data('comment-id')
  277. },
  278. function(edit_id) {
  279. $('#add_comment_div').remove();
  280. $('#add_comments_button').show();
  281. if ($('#comments_id_' + edit_id).length) {
  282. $('#comments_id_' + edit_id).html(comment_area.val());
  283. } else {
  284. table_for_comments = $('#table_for_comments').DataTable();
  285. $("#table_for_comments").parent().parent().parent().show();
  286. comment_td = '<div id="comments_id_' + edit_id + '">' + comment_area.val() + '</div>';
  287. inputEdit = $('<input>', {
  288. 'type': 'button',
  289. 'class': 'btn btn-secondary',
  290. 'onclick': 'add_comments_to_plan(' + edit_id + ')',
  291. 'id': 'edit_button_comment_' + edit_id,
  292. 'value': 'Edit'
  293. }).html('Edit');
  294. inputDelete = $('<input>', {
  295. 'type': 'button',
  296. 'class': 'btn btn-primary',
  297. 'style': 'display: inline',
  298. 'onclick': 'deleteCommentsFromOutcome(' + edit_id + ')',
  299. 'value': 'Delete'
  300. })
  301. div = $('<div>');
  302. div.append(inputEdit);
  303. div.append(inputDelete);
  304. table_for_comments.row.add([
  305. comment_td,
  306. div.html()
  307. ]).draw();
  308. }
  309. }
  310. )
  311. }
  312. function deleteCommentsFromOutcome(id) {
  313. $.post(
  314. "{{ URL::action('AnnualPlansController@deleteCommentsFromOutcome') }}", {
  315. id: id
  316. },
  317. function() {
  318. $('#comments_id_' + id).parent().parent().remove();
  319. }
  320. )
  321. }
  322. // Create everything
  323. function draw_transformative_actions(transforming_actions, semester_id) {
  324. if (!transforming_actions.length) {
  325. $("#transformative_for_outcome").hide();
  326. } else {
  327. $('#levelTabs').append('<li role = "presentation" id = "transformative_for_outcome">' +
  328. '<a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" >Program Transformative Actions</a>' +
  329. '</li>');
  330. $('#allLists').append('<div role="tabpanel" class="tab-pane" id="transformative_actions"></div>');
  331. $('#transformative_actions').html('<h3>Program Transformative Actions </h3>')
  332. $.each(transforming_actions, function(index, trans_action) {
  333. div = $("<div>", {
  334. 'id': 'div_trans_id_' + trans_action.trans_id
  335. }).html('<p><strong>' + (index + 1) + '. ' + trans_action.at_text + ': </strong>' +
  336. trans_action.description + '</p>' +
  337. '<p><strong>Category: </strong> ' + trans_action.type_of_TA + '</p>');
  338. div.append('<label>Results: </label>')
  339. input_results = $("<textarea>", {
  340. 'class': 'form-control',
  341. 'id': 'results_for_' + trans_action.trans_id
  342. });
  343. div.append(input_results)
  344. div.append(
  345. '<h5>Was this transformative action helpful to achieve the learning expectation?</h5>' +
  346. '<label class="radio-inline">' +
  347. '<input type="radio" name="useful_for_' + trans_action.trans_id +
  348. '" value = "1">Yes</label>' +
  349. '<label class="radio-inline">' +
  350. '<input type="radio" name="useful_for_' + trans_action.trans_id +
  351. '" value = "0">No</label>');
  352. comments = $('<textarea>', {
  353. 'id': 'comments_for_' + trans_action.trans_id,
  354. 'class': 'form-control'
  355. });
  356. div.append('<br><label>Explain briefly details about the implementation</label>');
  357. div.append(comments);
  358. button = $('<button>', {
  359. "type": "button",
  360. "class": "btn btn-primary",
  361. "onclick": 'saveTransReport(' + trans_action.trans_id + ', ' + semester_id +
  362. ', this)',
  363. 'style': 'float: right'
  364. }).html('Save');
  365. div.append('<br>');
  366. div.append(button);
  367. div.append('<br>');
  368. div.append('<hr>');
  369. $('#transformative_actions').append(div);
  370. $('#results_for_' + trans_action.trans_id).val(trans_action.results);
  371. $('#comments_for_' + trans_action.trans_id).val(trans_action.comments);
  372. $('input[name="useful_for_' + trans_action.trans_id + '"][value="' + trans_action
  373. .it_was_useful + '"]').prop('checked', true);
  374. })
  375. }
  376. }
  377. function draw_transformative_future_course(course_code) {
  378. /* This is the modal
  379. <div class="modal fade" id="modal-future-trans-course">
  380. <div class="modal-dialog modal-lg">
  381. <div class="modal-content">
  382. <div class="modal-header">
  383. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  384. aria-hidden="true">&times;</span></button>
  385. <h3 class="modal-title"></h3>
  386. </div>
  387. <div class="modal-body">
  388. </div>
  389. <div class='modal-footer'>
  390. <button type="button" class="btn btn-secondary" data-dismiss="modal" >Cancel</button>
  391. <button type="button" class="btn btn-primary" id ="save_transformative_info" onclick ='saveTransReport()'>Save</button>
  392. </div>
  393. </div><!-- /.modal-content -->
  394. </div><!-- /.modal-dialog -->
  395. </div><!-- /.modal --> */
  396. return_complete_div = $('<div>');
  397. return_complete_div.append('<h3>Future Transformative Actions for ' + course_code.code + ' ' + course_code
  398. .number);
  399. return_complete_div.append('<hr>');
  400. table_for_transformative_future = $('<table>', {
  401. 'id': 'transformative_actions_future_table_' + course_code.typ_semester_course_id,
  402. 'class': 'table table-striped table-condensed datatable',
  403. }).html('<thead>' +
  404. '<tr>' +
  405. '<th>Transformative Actions to be Implemented</th>' +
  406. '<th>Semesters to be Implemented</th>' +
  407. '<th>Edit or Delete</th>' +
  408. '</tr>' +
  409. '</thead>' +
  410. '<tbody id="transformative_action_future_body_' + course_code.typ_semester_course_id + '"></tbody>');
  411. return_complete_div.append(table_for_transformative_future);
  412. typ_semester_course_id = course_code.typ_semester_course_id;
  413. modalComplete = $('<div>', {
  414. 'class': 'modal fade',
  415. 'id': 'modal_for_future_trans_on_' + typ_semester_course_id
  416. });
  417. modalDialog = $('<div>', {
  418. 'class': 'modal-dialog modal-lg'
  419. });
  420. modalComplete.append(modalDialog);
  421. modalContent = $('<div>', {
  422. 'class': 'modal-content'
  423. });
  424. modalDialog.append(modalContent);
  425. modalHeader = $('<div>', {
  426. 'class': 'modal-header'
  427. }).html(
  428. '<button type="button" class="close" data-dismiss="modal" onclick = "clearInputs()" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
  429. '<h3 class="modal-title">Future Transformative Actions for ' + course_code.code + ' ' + course_code
  430. .number + '</h3>');
  431. modalContent.append(modalHeader);
  432. modalBody = $('<div>', {
  433. 'class': 'modal-body'
  434. });
  435. modalContent.append(modalBody);
  436. div_for_name = $('<div>', {
  437. 'class': 'form-group',
  438. });
  439. input_name = $('<input>', {
  440. 'class': 'form-control',
  441. 'name': 'at_text',
  442. 'id': 'at_text_for_' + typ_semester_course_id
  443. });
  444. div_for_name.html("<label> Name</label>");
  445. div_for_name.append(input_name);
  446. modalBody.append(div_for_name);
  447. div_for_category = $('<div>', {
  448. 'class': 'form-group'
  449. }).html('<label>Type of Transformative Action</label>');
  450. select_for_category = $('<select>', {
  451. 'name': 'type_of_ta',
  452. 'id': 'type_of_ta_of_' + typ_semester_course_id,
  453. 'class': 'form-control selectpicker',
  454. 'data-live-search':'true',
  455. 'onchange': 'checkIfNew(this)'
  456. }).html(GlobalTransCategories);
  457. div_for_category.append(select_for_category);
  458. modalBody.append(select_for_category);
  459. div_description = $('<div>', {
  460. 'class': 'form-group',
  461. }).html('<label> Description</label>');
  462. textarea = $('<textarea>', {
  463. 'class': 'form-control',
  464. 'id': 'description_for_' + typ_semester_course_id,
  465. 'name': 'description',
  466. 'rows': '10'
  467. });
  468. div_description.append(textarea);
  469. modalBody.append(div_description);
  470. modalBody.append('<hr><label>Select when will this transformative action will be implemeneted</label>');
  471. selectpicker_for_semesters = $('<select>', {
  472. 'name': 'selected_semesters_for_' + typ_semester_course_id + '_[]',
  473. 'id': 'selected_semester_first_for_' + typ_semester_course_id,
  474. 'class': 'form-control selectpicker',
  475. 'data-live-search':'true',
  476. });
  477. options_for_semesters = '<option value = "0">Nothing Selected</option>';
  478. $.each(course_code.future_typ_course_id.future_semesters, function(index, typ_future) {
  479. options_for_semesters += '<option value="' + typ_future.typ_future_course_id +
  480. '" data-semester-id ="' + typ_future.semester_id + '" data-objective-id = "' + typ_future
  481. .objective_id + '" >' + typ_future.semester_name + ' [' + typ_future.semester_code + '] ' +
  482. '</option>';
  483. });
  484. selectpicker_for_semesters.html(options_for_semesters);
  485. modalBody.append(selectpicker_for_semesters);
  486. modalBody.append('<br><br>');
  487. button_for_more = $('<button>', {
  488. 'class': 'btn btn-secondary',
  489. 'id': 'add_more_semesters_button_for_' + typ_semester_course_id,
  490. 'onclick': 'addMoreSemesters(' + typ_semester_course_id + ', this)',
  491. 'style': 'float:right'
  492. }).html('<span class="glyphicon glyphicon-plus">' +
  493. '</span>Add another semester');
  494. modalBody.append(button_for_more);
  495. modalBody.append('<br><br>');
  496. modalFooter = $('<div>', {
  497. 'class': 'modal-footer'
  498. });
  499. modalContent.append(modalFooter);
  500. close_button = $('<button>', {
  501. 'type': 'button',
  502. 'class': 'btn btn-secondary',
  503. 'data-dismiss': 'modal',
  504. 'onclick': 'clearInputs()'
  505. }).html('Cancel');
  506. save_button = $('<button>', {
  507. 'class': 'btn btn-primary',
  508. 'id': 'save_button_for_' + typ_semester_course_id,
  509. 'onclick': 'saveFutureTrans(' + typ_semester_course_id + ', "' + course_code.code + '", "' +
  510. course_code.number + '")'
  511. }).html('Save');
  512. modalFooter.append(close_button);
  513. modalFooter.append(save_button);
  514. return_complete_div.append(modalComplete);
  515. //populating existing future transformative actions
  516. //dictionary_if_exists
  517. html_dictionary = {};
  518. $.each(course_code.future_typ_course_id.future_transformative_actions, function(index, typ_future) {
  519. //Populating table for transformative_actions
  520. if (typ_future.trans_id != null) {
  521. //$("#transformative_action_row_"+typ_future.trans_id).length !==0
  522. if (html_dictionary[typ_future.trans_id] !== undefined) {
  523. //$('#transformative_future_semester_for_'+typ_future.trans_id).append(
  524. $(html_dictionary[typ_future.trans_id]).append(
  525. '<p style="display:inline" data-typ-future-course-id ="' + typ_future
  526. .typ_future_course_id + '">, ' + typ_future.semester_code + '</p>');
  527. //)
  528. } else {
  529. //create table rows
  530. new_tr = $('<tr>', {
  531. 'id': 'transformative_action_row_' + typ_future.trans_id,
  532. 'data-at-text': typ_future.at_text,
  533. 'data-description': typ_future.description,
  534. 'data-type-of-TA': typ_future.type_of_TA
  535. });
  536. td_transformative = $('<td>').html("<strong>" + typ_future.at_text + ": </strong>" +
  537. typ_future.description);
  538. html_dictionary[typ_future.trans_id] = $('<td>', {
  539. 'id': 'transformative_future_semester_for_' + typ_future.trans_id
  540. }).html('<p style="display:inline" data-typ-future-course-id = "' + typ_future
  541. .typ_future_course_id + '">' + typ_future.semester_code + '</p>');
  542. inputEdit = $('<button>', {
  543. 'type': 'button',
  544. 'class': 'btn btn-secondary',
  545. 'onclick': 'edit_ta_modal(' + typ_future.trans_id + ', ' +
  546. typ_semester_course_id + ', "' + course_code.code + '", "' + course_code
  547. .number + '");',
  548. //'data-target':'#modal_for_future_trans_'+typ_future.trans_id,
  549. 'id': 'edit_button_for_trans_' + typ_future.trans_id
  550. //'value': 'Edit'
  551. }).html('Edit');
  552. inputDelete = $('<input>', {
  553. 'type': 'button',
  554. 'class': 'btn btn-primary',
  555. 'style': 'display: inline',
  556. 'onclick': 'open_warning_modal(' + typ_future.trans_id + ')',
  557. 'value': 'Delete'
  558. })
  559. td_for_buttons = $('<td>');
  560. td_for_buttons.append(inputEdit);
  561. td_for_buttons.append(inputDelete);
  562. new_tr.append(td_transformative);
  563. new_tr.append(html_dictionary[typ_future.trans_id]);
  564. new_tr.append(td_for_buttons);
  565. new_tr.appendTo(table_for_transformative_future);
  566. }
  567. }
  568. });
  569. return_complete_div.append(
  570. '<hr><button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#modal_for_future_trans_on_' +
  571. typ_semester_course_id + '">' +
  572. 'Add Transformative Actions' +
  573. '</button><hr>')
  574. return return_complete_div;
  575. }
  576. function deleteTrans(trans_id) {
  577. $.post(
  578. "{{ URL::action('TransformativeActionsController@deleteTaFromOutcome') }}", {
  579. trans_id: trans_id
  580. },
  581. function() {
  582. $('#transformative_action_row_' + trans_id).remove();
  583. }
  584. )
  585. }
  586. function clearInputs() {
  587. $('.input-group').remove();
  588. $('textarea[name="description"]').val('');
  589. $('input[name="at_text"]').val('');
  590. $('select[name="type_of_ta"]').val('0');
  591. $('.selectpicker').selectpicker('refresh');
  592. $('.new_type').hide();
  593. }
  594. function edit_ta_modal(future_trans_id, typ_semester_course_id, course_code, course_number) {
  595. at_text_transformative = $('#transformative_action_row_' + future_trans_id).data('at-text');
  596. description = $('#transformative_action_row_' + future_trans_id).data('description');
  597. type_of_TA = $('#transformative_action_row_' + future_trans_id).data('type-of-ta');
  598. semesters_cell = $('#transformative_future_semester_for_' + future_trans_id);
  599. amount_of_semesters = $(semesters_cell).children().length;
  600. for (i = 1; i < amount_of_semesters; i++) {
  601. $('#add_more_semesters_button_for_' + typ_semester_course_id).click();
  602. }
  603. future_typ_for_ta = [];
  604. $.each($(semesters_cell).children(), function(index, p) {
  605. future_typ_for_ta.push($(p).data('typ-future-course-id'));
  606. })
  607. $.each($('select[name="selected_semesters_for_' + typ_semester_course_id + '_[]"]'), function(index, select) {
  608. $(select).val(future_typ_for_ta[index]);
  609. })
  610. $('#save_button_for_' + typ_semester_course_id).attr('onclick', 'saveFutureTrans(' + typ_semester_course_id +
  611. ', "' + course_code + '", "' + course_number + '", ' + future_trans_id + ')')
  612. $('#at_text_for_' + typ_semester_course_id).val(at_text_transformative)
  613. $('#description_for_' + typ_semester_course_id).val(description)
  614. $('#type_of_ta_of_' + typ_semester_course_id).val(type_of_TA);
  615. $('.selectpicker').selectpicker('refresh');
  616. $('#modal_for_future_trans_on_' + typ_semester_course_id).modal();
  617. }
  618. function saveFutureTrans(typ_semester_course_id, course_code, course_number, edit_ta_id = null) {
  619. annual_plan_id = $('#annual_plan').val()
  620. at_text = $('#at_text_for_' + typ_semester_course_id).val();
  621. type_of_TA = $('#type_of_ta_of_' + typ_semester_course_id).val();
  622. is_custom = $('#type_of_ta_of_' + typ_semester_course_id).find('option:selected').data('is-custom');
  623. if (type_of_TA == "new") {
  624. type_of_TA = $('#new_type_type_of_ta_of_' + typ_semester_course_id).val();
  625. is_custom = 1;
  626. new_option = "<option value= '" + type_of_TA + "' data-is-custom='1'>" + type_of_TA + "</option>";
  627. $('#program_custom_action').append(new_option);
  628. }
  629. description = $('#description_for_' + typ_semester_course_id).val();
  630. future_typ_course_id = [];
  631. future_semesters = [];
  632. objective_id = 0
  633. $.each($('select[name="selected_semesters_for_' + typ_semester_course_id + '_[]"]'), function(index, select) {
  634. objective_id = $(select).find('option:selected').data('objective-id');
  635. future_semesters.push($(select).find('option:selected').data('semester-id'));
  636. future_typ_course_id.push($(select).val());
  637. });
  638. $.post(
  639. "{{ URL::action('AnnualPlansController@futureTransformative') }}", {
  640. at_text: at_text,
  641. type_of_TA: type_of_TA,
  642. description: description,
  643. future_semesters: future_semesters,
  644. future_typ_course_id: future_typ_course_id,
  645. is_custom: is_custom,
  646. program_id: {{ $program->id }},
  647. annual_plan_id: annual_plan_id,
  648. course_code: course_code,
  649. course_number: course_number,
  650. objective_id: objective_id,
  651. edit_ta_id: edit_ta_id
  652. },
  653. function(trans_info) {
  654. if (edit_ta_id != null) {
  655. $('#transformative_action_row_' + edit_ta_id).remove();
  656. }
  657. new_tr = $('<tr>', {
  658. 'id': 'transformative_action_row_' + trans_info[0].trans_id,
  659. 'data-at-text': trans_info[0].at_text,
  660. 'data-description': trans_info[0].description,
  661. 'data-type-of-TA': trans_info[0].type_of_TA
  662. });
  663. td_transformative = $('<td>').html("<strong>" + trans_info[0].at_text + ": </strong>" + trans_info[
  664. 0].description);
  665. td_semesters = $('<td>', {
  666. 'id': 'transformative_future_semester_for_' + trans_info[0].trans_id
  667. });
  668. $.each(trans_info, function(index, semester) {
  669. td_semesters.append('<p style="display:inline" data-typ-future-course-id = "' + semester
  670. .typ_future_course_id + '">' + semester.code + ', </p>');
  671. });
  672. inputEdit = $('<button>', {
  673. 'type': 'button',
  674. 'class': 'btn btn-secondary',
  675. 'onclick': 'edit_ta_modal(' + trans_info[0].trans_id + ', ' + typ_semester_course_id +
  676. ')',
  677. //'data-target':'#modal_for_future_trans_'+typ_future.trans_id,
  678. 'id': 'edit_button_for_trans_' + trans_info[0].trans_id
  679. //'value': 'Edit'
  680. }).html('Edit');
  681. inputDelete = $('<input>', {
  682. 'type': 'button',
  683. 'class': 'btn btn-primary',
  684. 'style': 'display: inline',
  685. 'onclick': 'deleteTrans(' + trans_info[0].trans_id + ')',
  686. 'value': 'Delete'
  687. })
  688. td_for_buttons = $('<td>');
  689. td_for_buttons.append(inputEdit);
  690. td_for_buttons.append(inputDelete);
  691. new_tr.append(td_transformative);
  692. new_tr.append(td_semesters);
  693. new_tr.append(td_for_buttons);
  694. new_tr.appendTo("#transformative_action_future_body_" + typ_semester_course_id);
  695. $('#modal_for_future_trans_on_' + typ_semester_course_id).modal('toggle');
  696. clearInputs();
  697. }
  698. )
  699. }
  700. function addMoreSemesters(typ_semester_course_id, button_add_new_semester) {
  701. first_select_options = $('#selected_semester_first_for_' + typ_semester_course_id).html();
  702. /*<div class="input-group">
  703. <select class="form-control">
  704. <option>Select option..</option>
  705. <option>Option 1</option>
  706. <option>Option 2</option>
  707. </select>
  708. <span class="input-group-btn">
  709. <button class="btn btn-default" type="button" tabindex="-1"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
  710. </span>
  711. </div> */
  712. input_group = $('<div>', {
  713. 'class': 'input-group'
  714. });
  715. newselect = $('<select>', {
  716. 'name': 'selected_semesters_for_' + typ_semester_course_id + '_[]',
  717. //'id':'selected_semester_first_for_'+typ_semester_course_id,
  718. 'class': 'form-control selectpicker',
  719. 'data-live-search':'true',
  720. }).html(first_select_options);
  721. span_group = $("<span>", {
  722. 'class': 'input-group-btn',
  723. });
  724. button_for_close = $('<button>', {
  725. 'class': 'btn btn-primary',
  726. 'type': 'button',
  727. 'onclick': '$(this).parent().parent().remove()'
  728. }).html('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>');
  729. span_group.append(button_for_close);
  730. input_group.append(newselect);
  731. input_group.append(span_group);
  732. input_group.insertBefore($(button_add_new_semester));
  733. //input_group.prepend('<hr>');
  734. $('.selectpicker').selectpicker('refresh');
  735. }
  736. function checkIfNew(select) {
  737. id = $(select).attr('id');
  738. if ($(select).val() == "new") {
  739. var new_div = $('<div/>', {
  740. 'class': 'form-group new_type'
  741. }).html("<label>New Type </label>");
  742. var input = $("<input/>", {
  743. 'type': 'text',
  744. 'id': 'new_type_' + id,
  745. 'name': "new_type",
  746. 'class': 'form-control'
  747. });
  748. new_div.append(input);
  749. $(select).parent().after(new_div)
  750. } else {
  751. $(select).parent().next('.new_type').remove();
  752. }
  753. }
  754. GlobalTransCategories = '';
  755. function fetchEverything(li) {
  756. var outcome_id = $(li).data('outcome-id');
  757. var name = $(li).data('outcome-name');
  758. var semester_id = $(li).data('semester-id');
  759. var annual_plan_id = $(li).data('annual-plan');
  760. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  761. $('#theChange').data('annual-plan', annual_plan);
  762. $.post(
  763. "{{ URL::action('AnnualPlansController@fetchReportWithOutcome') }}", {
  764. semester_id: semester_id,
  765. outcome_id: outcome_id,
  766. program_id: {{ $program->id }},
  767. annual_plan_id: annual_plan_id,
  768. typ_semester_outcome_id: typ_semester_outcome_id
  769. },
  770. function(outcome) {
  771. if (outcome.objectives) {
  772. $('table').show();
  773. $('#outcome-display').parent().show();
  774. $('#outcome-display .panel-title').html(name);
  775. $('#allLists').empty();
  776. $('#levelTabs').empty();
  777. $('.no-outcome').hide();
  778. if (outcome.outcome_program_goal) {
  779. outcome.outcome_program_goal = outcome.outcome_program_goal.expected_target;
  780. } else {
  781. outcome.outcome_program_goal = 'It has not been defined';
  782. }
  783. GlobalTransCategories = outcome.transformative_actions_categories_html;
  784. var outcomeHTML = "<h4>Performance of Students by Learning Outcome</h4>" +
  785. '<h5 style = "display: inline; margin:30px;">Target to achieve the learning outcome: </h5>' +
  786. '<p style = "display: inline;"> <i> ' + outcome.expected_outcome +
  787. '% or more of the attempts </i>' + '</p>' +
  788. '<br><h5 style = "display: inline; margin:30px;">Expected percent of students achieving the target by learning outcome: </h5>' +
  789. '<p style = "display: inline;"> <i>' + outcome.outcome_program_goal + '%</i></p>';
  790. $('#outcomeInfo').html('<p class="outcome-definition">' + outcome.definition + '</p>' +
  791. outcomeHTML);
  792. //theStudentOutcomeTable = $("<table/>");
  793. //theStudentOutcomeTable.hide();
  794. ///$('#outcomeInfo').append(theStudentOutcomeTable);
  795. wholeDict = {};
  796. tableStudent = $('<table/>', {
  797. 'class': 'table table-striped table-condensed datatable'
  798. });
  799. tableStudent.html('<thead><tr>' +
  800. '<th>Student</th>' +
  801. '<th>Criteria Attempted</th>' +
  802. '<th>Criteria Achieved</th>' +
  803. '<th>Percentage</th>' +
  804. '<th>Outcome Achieved</th>' +
  805. '</tr></thead><tbody></tbody>');
  806. first_objective_id = outcome.objectives[0].id;
  807. $.each(outcome.objectives, function(index, objective) {
  808. li = $('<li/>', {
  809. 'role': 'presentation',
  810. 'id': 'li_for_' + objective.objective_id
  811. });
  812. a = $('<a/>', {
  813. 'data-toggle': 'tab',
  814. 'id': 'a_for_' + objective.objective_id,
  815. 'href': '#' + objective.objective_id,
  816. 'role': 'tab'
  817. }).html('Objective ' + (index + 1));
  818. li.append(a);
  819. $('#levelTabs').append(li);
  820. objective_title = "<h3>" + objective.text + '</h3>';
  821. div = $('<div/>', {
  822. 'role': 'tabpanel',
  823. 'class': 'tab-pane',
  824. 'id': objective.objective_id
  825. }).html(objective_title);
  826. div.appendTo($('#allLists'))
  827. div.append(
  828. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  829. );
  830. if (objective.courses) {
  831. $.each(objective.courses, function(index, course_code) {
  832. if (course_code.criteria.length) {
  833. $.each(course_code.students, function(index, student) {
  834. if (wholeDict[student.student_id] === undefined) {
  835. wholeDict[student.student_id] = {
  836. 'student': student.student_id,
  837. 'criteria_attempted': 0,
  838. 'criteria_achieved': 0
  839. }
  840. }
  841. wholeDict[student.student_id][
  842. "criteria_attempted"
  843. ] += student
  844. .criteria_attempted;
  845. wholeDict[student.student_id][
  846. "criteria_achieved"
  847. ] += student
  848. .criteria_achieved;
  849. });
  850. /*div.append(
  851. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  852. );*/
  853. table = $('<table/>', {
  854. 'class': 'table table-striped table-condensed datatable'
  855. }).html('<thead><th>Criterion</th><th>' +
  856. 'Number of Students Assessed </th>' +
  857. '<th>Number of students that achieved the target</th></thead>'
  858. );
  859. tbody = $('<tbody/>')
  860. $.each(course_code.criteria, function(index, criterion) {
  861. tr = $('<tr/>').append(
  862. "<td>" + criterion.name + "</td>" +
  863. "<td>" + criterion.criteria_attempted +
  864. "</td>" +
  865. "<td>" + criterion.criteria_achieved +
  866. "</td>"
  867. );
  868. tbody.append(tr);
  869. });
  870. table.append(tbody);
  871. Course_section = '<h3>' + course_code.code + ' ' +
  872. course_code.number + '</h3><hr>';
  873. div.append(Course_section)
  874. div.append('<h4> Criteria Assessed in ' + course_code.code +
  875. ' ' + course_code.number + '</h4>')
  876. div.append(table);
  877. if (course_code.transforming_actions.length) {
  878. table_for_transformative_actions = $('<table>', {
  879. 'class': 'table table-striped table-condensed datatable'
  880. }).html(
  881. '<thead><th>Transformative Actions Proposed in Annual Plan</th>' +
  882. '<th>Follow up </th>' +
  883. '</thead>'
  884. );
  885. tbody_for_transformative_actions = $('<tbody>');
  886. $.each(course_code.transforming_actions, function(index,
  887. transformative_action) {
  888. button_for_followup = $('<button>', {
  889. 'class': 'btn btn-secondary',
  890. 'onclick': 'give_follow_up_questions(' +
  891. transformative_action.id +
  892. ', "' + outcome.semester_info
  893. .code + '", ' + outcome
  894. .semester_info.id + ')'
  895. }).html('Follow Up Questions');
  896. table_row = "<tr>" +
  897. '<td><p><strong>' + transformative_action
  898. .at_text + ': </strong>' +
  899. transformative_action.description +
  900. '</p></td>' +
  901. '<td>' + button_for_followup.prop(
  902. 'outerHTML') + '</td></tr>';
  903. tbody_for_transformative_actions.append(
  904. table_row)
  905. })
  906. table_for_transformative_actions.append(
  907. tbody_for_transformative_actions);
  908. div.append('<hr><h4>Transformative actions for ' +
  909. course_code.code + ' ' + course_code.number +
  910. '</h4>')
  911. div.append(table_for_transformative_actions);
  912. div.append('<hr>');
  913. //table_for_transformative_actions.DataTable();
  914. }
  915. the_drawn_transformative_future_html =
  916. draw_transformative_future_course(course_code, outcome
  917. .transformative_actions_categories_html);
  918. div.append(the_drawn_transformative_future_html);
  919. $('.selectpicker').selectpicker('refresh');
  920. table.DataTable();
  921. }
  922. })
  923. } else {
  924. div.append('<div class="no-outcome alert alert-info"' +
  925. '<p>No Course in plan has assessed yet</p>' +
  926. '</div>')
  927. }
  928. })
  929. draw_transformative_actions(outcome.transforming_actions, outcome.semester_info.id)
  930. draw_comment_section(typ_semester_outcome_id, outcome.comments);
  931. //$('#a_for_'+first_objective_id).click();
  932. theArray = [];
  933. $('#tableOutcome').html(tableStudent);
  934. //tableStudent.appendTo($('#outcomeInfo'));
  935. tableStudent = tableStudent.DataTable({
  936. dom: 'Bfrtip',
  937. buttons: [
  938. 'csv', 'excel', 'pdf', 'print'
  939. ]
  940. });
  941. students_attempted = 0;
  942. students_achieved = 0;
  943. $.each(wholeDict, function(key, dict) {
  944. if (dict.criteria_attempted) {
  945. students_attempted += 1;
  946. percentage = ((dict.criteria_achieved / dict.criteria_attempted) * 100).toFixed(
  947. 2);
  948. if (parseFloat(percentage) >= parseFloat(outcome.expected_outcome)) {
  949. achieved = "Yes"
  950. students_achieved += 1;
  951. } else achieved = "No"
  952. } else {
  953. percentage = "N/A"
  954. achieved = "N/A"
  955. }
  956. tableStudent.row.add([
  957. dict.student,
  958. dict.criteria_attempted,
  959. dict.criteria_achieved,
  960. percentage,
  961. achieved
  962. ]);
  963. })
  964. tableStudent.draw();
  965. if (students_attempted) {
  966. studentPercentage = ((students_achieved / students_attempted) * 100).toFixed(2);
  967. if (parseFloat(studentPercentage) >= parseFloat(outcome.outcome_program_goal)) {
  968. FinalReport = "<p style = 'margin: 30px; '><strong>Results for " + outcome.name +
  969. ": </strong><em style = 'color: green'>" +
  970. studentPercentage + "% </em></p>";
  971. } else {
  972. FinalReport = "<p style = 'margin: 30px'><strong>Results for " + outcome.name +
  973. ": </strong><em style = 'color: red'>" +
  974. studentPercentage + "% </em></p>";
  975. }
  976. }
  977. else{
  978. FinalReport = "<p style = 'margin: 30px'><strong>Results for " + outcome.name +
  979. ": </strong><em style = 'color: red'>" +
  980. 0+ "% </em></p>";
  981. }
  982. $("#outcomeInfo").append(FinalReport)
  983. /* table.row.add([
  984. objectivesHTML,
  985. courseshtml,
  986. courseTAhtml
  987. ]);
  988. table.draw();
  989. */
  990. } else {
  991. $('table').hide();
  992. }
  993. }
  994. );
  995. }
  996. function give_follow_up_questions(trans_id, semester_code, semester_id) {
  997. $.ajax({
  998. type: 'POST',
  999. url: "{{ URL::action('TransformativeActionsController@fetchStatus') }}",
  1000. data: {
  1001. trans_id: trans_id,
  1002. semester_id: semester_id
  1003. },
  1004. success: function(transformative_action_with_status) {
  1005. transformative_action = transformative_action_with_status[0];
  1006. $('#transformative_modal_title').html('<strong>' + transformative_action.at_text +
  1007. '</strong>: ' + transformative_action.description);
  1008. $('input[name="implemented"]').prop('checked', false);
  1009. $('input[name="useful"]').prop('checked', false);
  1010. $('#comments').val(' ');
  1011. $('#useful_radio_div').hide();
  1012. $('#comment_div').hide();
  1013. if (transformative_action['status']) {
  1014. transformative_action['status'].accomplished;
  1015. $('input[name="implemented"][value="' + transformative_action['status'].accomplished +
  1016. '"]').prop('checked', true);
  1017. if (transformative_action['status'].accomplished) {
  1018. $('#useful_radio_div').show();
  1019. $('input[name="useful"][value="' + transformative_action['status'].it_was_useful +
  1020. '"]').prop('checked', true);
  1021. $('#implement_textarea').html(
  1022. "Explain briefly details about the implementation of this transformative action"
  1023. );
  1024. } else {
  1025. $('#implement_textarea').html(
  1026. "Explain briefly why this transformative action was not implemented")
  1027. }
  1028. $('#comment_div').show();
  1029. $('#comments').val(transformative_action['status'].comments);
  1030. }
  1031. $('#was_it_implemented').html(
  1032. 'Was this transformative action implemented during Semester ' + semester_code);
  1033. $('#modal-status-trans').modal();
  1034. $('#save_transformative_info').attr('onclick', 'saveTransReport(' + trans_id + ',' +
  1035. semester_id + ',"modal")');
  1036. },
  1037. async: true
  1038. });
  1039. }
  1040. function saveTransReport(trans_id, semester_id, type_of_input) {
  1041. $('.alert-dismissible').remove();
  1042. isEverythingOkay = true;
  1043. if (type_of_input == 'modal') {
  1044. comments = $('#comments').val();
  1045. if (comments.trim().length === 0) {
  1046. alert = $('<div/>', {
  1047. 'class': 'alert alert-danger alert-dismissible',
  1048. 'role': 'alert'
  1049. })
  1050. button = $('<button/>', {
  1051. 'type': 'button',
  1052. 'class': 'close',
  1053. 'data-dismiss': 'alert',
  1054. 'alert-label': 'close'
  1055. }).html('<span aria-hidden="true">×</span>');
  1056. alert.append(button);
  1057. alert.append('<strong>Please write a valid comment </strong>')
  1058. $('#implement_texarea').after(alert);
  1059. isEverythingOkay = false;
  1060. $('html, body').animate({
  1061. scrollTop: $(alert).offset().top
  1062. }, 500);
  1063. $(alert).focus();
  1064. }
  1065. accomplished = parseInt($('input[name="implemented"]:checked').val());
  1066. if (accomplished === undefined) {
  1067. alert = $('<div/>', {
  1068. 'class': 'alert alert-danger alert-dismissible',
  1069. 'role': 'alert'
  1070. })
  1071. button = $('<button/>', {
  1072. 'type': 'button',
  1073. 'class': 'close',
  1074. 'data-dismiss': 'alert',
  1075. 'alert-label': 'close'
  1076. }).html('<span aria-hidden="true">×</span>');
  1077. alert.append(button);
  1078. alert.append('<strong>Check if it was implemented </strong>')
  1079. $('#was_it_implemented').after(alert);
  1080. isEverythingOkay = false;
  1081. $('html, body').animate({
  1082. scrollTop: $(alert).offset().top
  1083. }, 500);
  1084. $(alert).focus();
  1085. }
  1086. if (accomplished == 1) {
  1087. was_it_useful = $('input[name="useful"]:checked').val();
  1088. if (was_it_useful === undefined) {
  1089. alert = $('<div/>', {
  1090. 'class': 'alert alert-danger alert-dismissible',
  1091. 'role': 'alert'
  1092. })
  1093. button = $('<button/>', {
  1094. 'type': 'button',
  1095. 'class': 'close',
  1096. 'data-dismiss': 'alert',
  1097. 'alert-label': 'close'
  1098. }).html('<span aria-hidden="true">×</span>');
  1099. alert.append(button);
  1100. alert.append('<strong>Check if it was implemented </strong>')
  1101. $('#useful_radio_div').prepend(alert);
  1102. isEverythingOkay = false;
  1103. $('html, body').animate({
  1104. scrollTop: $(alert).offset().top
  1105. }, 500);
  1106. $(alert).focus();
  1107. }
  1108. } else was_it_useful = 0;
  1109. results = "";
  1110. } else {
  1111. comments = $('#comments_for_' + trans_id).val();
  1112. if (comments.trim().length === 0) {
  1113. alert = $('<div/>', {
  1114. 'class': 'alert alert-danger alert-dismissible',
  1115. 'role': 'alert'
  1116. })
  1117. button = $('<button/>', {
  1118. 'type': 'button',
  1119. 'class': 'close',
  1120. 'data-dismiss': 'alert',
  1121. 'alert-label': 'close'
  1122. }).html('<span aria-hidden="true">×</span>');
  1123. alert.append(button);
  1124. alert.append('<strong>Write a valid comment before saving! </strong>')
  1125. $('#comments_for_' + trans_id).before(alert);
  1126. isEverythingOkay = false;
  1127. $('html, body').animate({
  1128. scrollTop: $(alert).offset().top
  1129. }, 500);
  1130. $(alert).focus();
  1131. }
  1132. accomplished = 1;
  1133. was_it_useful = $('input[name="useful_for_' + trans_id + '"]:checked').val();
  1134. if (was_it_useful === undefined) {
  1135. alert = $('<div/>', {
  1136. 'class': 'alert alert-danger alert-dismissible',
  1137. 'role': 'alert'
  1138. })
  1139. button = $('<button/>', {
  1140. 'type': 'button',
  1141. 'class': 'close',
  1142. 'data-dismiss': 'alert',
  1143. 'alert-label': 'close'
  1144. }).html('<span aria-hidden="true">×</span>');
  1145. alert.append(button);
  1146. alert.append('<strong>Please check if it was helpful </strong>')
  1147. $('input[name="useful_for_' + trans_id + '"]').eq(0).parent().before(alert);
  1148. isEverythingOkay = false;
  1149. $('html, body').animate({
  1150. scrollTop: $(alert).offset().top
  1151. }, 500);
  1152. $(alert).focus();
  1153. }
  1154. results = $('#results_for_' + trans_id).val();
  1155. if (results.trim().length === 0) {
  1156. alert = $('<div/>', {
  1157. 'class': 'alert alert-danger alert-dismissible',
  1158. 'role': 'alert'
  1159. })
  1160. button = $('<button/>', {
  1161. 'type': 'button',
  1162. 'class': 'close',
  1163. 'data-dismiss': 'alert',
  1164. 'alert-label': 'close'
  1165. }).html('<span aria-hidden="true">×</span>');
  1166. alert.append(button);
  1167. alert.append('<strong>Please check if it was helpful </strong>')
  1168. $('#results_for_' + trans_id).before(alert);
  1169. isEverythingOkay = false;
  1170. $('html, body').animate({
  1171. scrollTop: $(alert).offset().top
  1172. }, 2000);
  1173. $(alert).focus();
  1174. }
  1175. }
  1176. if (isEverythingOkay == false) return;
  1177. $.post(
  1178. "{{ URL::action('TransformativeActionsController@saveTransStatus') }}", {
  1179. semester_id: semester_id,
  1180. trans_id: trans_id,
  1181. results: results,
  1182. comments: comments,
  1183. accomplished: accomplished,
  1184. was_it_useful: was_it_useful,
  1185. },
  1186. function(message) {
  1187. if (type_of_input == 'modal') {
  1188. $('#modal-status-trans').modal("toggle");
  1189. } else {
  1190. alert = $('<div/>', {
  1191. 'class': 'alert alert-success alert-dismissible',
  1192. 'role': 'alert'
  1193. })
  1194. button = $('<button/>', {
  1195. 'type': 'button',
  1196. 'class': 'close',
  1197. 'data-dismiss': 'alert',
  1198. 'alert-label': 'close'
  1199. }).html('<span aria-hidden="true">×</span>');
  1200. alert.append(button);
  1201. alert.append('<strong>Saved! </strong>')
  1202. $(type_of_input).parent().prepend(alert);
  1203. }
  1204. }
  1205. )
  1206. }
  1207. $('#allOutcomes').hide();
  1208. function fetchInfo(id) {
  1209. annual_id = $("#" + id).val();
  1210. program_id = {{ $program->id }};
  1211. $.post("{{ URL::action('AnnualPlansController@fetchInfo') }}", {
  1212. id: annual_id,
  1213. program_id: program_id
  1214. },
  1215. function(json) {
  1216. div = $('<div/>', {
  1217. 'class': 'list-group',
  1218. 'id': 'list'
  1219. });
  1220. if (json.outcomes.first) {
  1221. header5 = $('<h5/>', {
  1222. 'style': "padding-left: 10px"
  1223. }).html("First Semester");
  1224. div.append(header5);
  1225. list = '';
  1226. for (outcome in json.outcomes.first) {
  1227. list +=
  1228. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  1229. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.first[
  1230. outcome].typ_semester_outcome_id + "' data-semester-id = '" + json.allSemesterOrder
  1231. .first.id +
  1232. "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" +
  1233. json
  1234. .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[
  1235. outcome]
  1236. .name + " </li>";
  1237. }
  1238. div.append(list);
  1239. }
  1240. if (json.outcomes.second) {
  1241. header4 = $('<h5/>', {
  1242. 'style': "padding-left: 10px"
  1243. }).html("Second Semester");
  1244. div.append(header4);
  1245. list = '';
  1246. for (outcome in json.outcomes.second) {
  1247. list +=
  1248. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  1249. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.second[
  1250. outcome].typ_semester_outcome_id + "'data-semester-id = '" + json.allSemesterOrder
  1251. .second.id +
  1252. "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" +
  1253. json
  1254. .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
  1255. outcome].name + " </li>";
  1256. }
  1257. div.append(list);
  1258. }
  1259. html = div[0].innerHTML;
  1260. $("#allOutcomes").html(div[0].innerHTML);
  1261. $("#allOutcomes").show();
  1262. //create button for print
  1263. div_btn_group = $('<div>', {
  1264. 'class': 'btn-group-vertical',
  1265. 'role': 'group'
  1266. });
  1267. button_save = $('<button>', {
  1268. 'class': ' btn btn-lg btn-primary btn-block',
  1269. 'type': 'button',
  1270. 'onclick': 'check_if_ready(' + annual_id + ')'
  1271. }).html('Submit Annual Report');
  1272. button_print = $("<button>", {
  1273. "class": 'btn btn-lg btn-primary btn-block',
  1274. "type": "button",
  1275. "onclick": "window.location.href = " +
  1276. "'{{ URL::action('AnnualPlansController@printAnnualReport') }}" +
  1277. "/" +
  1278. annual_id + "'",
  1279. }).html("Print Report");
  1280. div_btn_group.append(button_print);
  1281. div_btn_group.append(button_save);
  1282. $('#printButton').html(div_btn_group);
  1283. },
  1284. "json",
  1285. );
  1286. }
  1287. function check_if_ready(annual_id) {
  1288. $.post(
  1289. "{{ URL::action('AnnualPlansController@checkIfReady') }}", {
  1290. annual_id: annual_id
  1291. },
  1292. function(courses_with_missing_data) {
  1293. if (courses_with_missing_data.outcomes.length > 0 || courses_with_missing_data.courses.length > 0) {
  1294. //id="submit-modal">
  1295. //This means there is still data to be filled before submit.
  1296. $('#submit-modal-title').html("There is still some data to be filled. ")
  1297. //close button <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  1298. button = $('<button>', {
  1299. 'class': 'btn btn-secondary',
  1300. 'type': 'button',
  1301. 'data-dismiss': 'modal'
  1302. }).html('Close');
  1303. $('#submit-modal-footer').html(button);
  1304. $('#submit-modal-body').html("These are the following transformative actions");
  1305. if (courses_with_missing_data.courses.length > 0) {
  1306. div_for_courses = $("<div>", {
  1307. 'id': 'courses_ta',
  1308. }).html("<h4>These are the Courses Transformative Actions need to be filled</h4>")
  1309. ol_course_ta = $("<ol>", {
  1310. 'id': 'course_ta',
  1311. 'type': 'I'
  1312. });
  1313. div_for_courses.append(ol_course_ta);
  1314. //"<ol id='course_ta' type='I'>");
  1315. //div_for_outcomes
  1316. $('#submit-modal-body').append(div_for_courses)
  1317. $.each(courses_with_missing_data.courses, function(index, info) {
  1318. /*
  1319. $array_to_be_appended = [
  1320. 'course_name' => $course->code . '-' . $course->number,
  1321. 'objective' => $objective_info,
  1322. 'outcome' => $outcome_info,
  1323. 'transformative_action_title' => $ta->at_text,
  1324. 'transformative_action_description' => $ta->description
  1325. ];
  1326. */
  1327. selector = $('#course_typ_outcome_' + info.outcome.typ_semester_outcome_id);
  1328. if (selector.length === 0) {
  1329. li_outcome = $('<li>').html(info.outcome.name);
  1330. ol = $("<ol>", {
  1331. 'id': 'course_typ_outcome_' + info.outcome
  1332. .typ_semester_outcome_id,
  1333. 'type': 'A'
  1334. });
  1335. li_outcome.append(ol);
  1336. $("#course_ta").append(li_outcome);
  1337. //selector = $('<div>').html(info.outcome.typ_semester_outcome_id);
  1338. //selector.append('<ol type = "A">');
  1339. //objective_li = $("<li>");
  1340. //objective_id = $("<div>",{
  1341. // 'class':'typ-objective-'+info.objective.typ_semester_objective_id,
  1342. //}).html();
  1343. //li.append(selector);
  1344. }
  1345. selector = $("#course_typ_objective_" + info.objective
  1346. .typ_semester_objective_id)
  1347. if (selector.length === 0) {
  1348. li_objective = $("<li>").html(info.objective.text);
  1349. ol_objective = $("<ol>", {
  1350. 'id': 'course_typ_objective_' + info.objective
  1351. .typ_semester_objective_id,
  1352. 'type': '1'
  1353. });
  1354. li_objective.append(ol_objective);
  1355. $('#course_typ_outcome_' + info.outcome.typ_semester_outcome_id).append(
  1356. li_objective);
  1357. }
  1358. selector = $("#course_ul_" + info.typ_semester_course_id)
  1359. if (selector.length === 0) {
  1360. li_course = $("<li>").html(info.course_name);
  1361. ol_course = $("<ul>", {
  1362. 'id': "course_ul_" + info.typ_semester_course_id,
  1363. });
  1364. li_course.append(ol_course);
  1365. $('#course_typ_objective_' + info.objective.typ_semester_objective_id)
  1366. .append(li_course);
  1367. }
  1368. li_ta = $('<li>').html('<p><strong>' + info.transformative_action_title +
  1369. ': </strong>' + info.transformative_action_description + '</p>');
  1370. $("#course_ul_" + info.typ_semester_course_id).append(li_ta);
  1371. });
  1372. //$('#submit-modal-body').append("</ol>")
  1373. //$('#submit-modal-footer').html(button);
  1374. }
  1375. if (courses_with_missing_data.outcomes.length > 0) {
  1376. div_for_outcomes = $("<div>", {
  1377. 'id': 'outcomes_ta',
  1378. }).html("<h4>These are the Program Transformative Actions need to be filled</h4>");
  1379. ol = $('<ol>', {
  1380. 'id': 'list_for_outcomes',
  1381. 'type': 'I'
  1382. });
  1383. ol.appendTo(div_for_outcomes);
  1384. $('#submit-modal-body').append(div_for_outcomes);
  1385. $.each(courses_with_missing_data.outcomes, function(index, info) {
  1386. if ($("#outcome_ta_for_" + info.typ_semester_outcome_id).length === 0) {
  1387. li_outcome = $("<li>").html(info.outcome_name);
  1388. li_outcome.appendTo($("#list_for_outcomes"));
  1389. ol = $('<ol>', {
  1390. 'id': "outcome_ta_for_" + info.typ_semester_outcome_id
  1391. })
  1392. ol.appendTo(li_outcome);
  1393. }
  1394. li = $('<li>').html('<p><strong>' + info.transformative_action_title +
  1395. ': </strong>' + info.transformative_action_description + '</p>');
  1396. $('#outcome_ta_for_' + info.typ_semester_outcome_id).append(li);
  1397. })
  1398. // div_for_outcomes.append(ol);
  1399. }
  1400. } else {
  1401. button = $('<button>', {
  1402. 'class': 'btn btn-secondary',
  1403. 'type': 'button',
  1404. 'data-dismiss': 'modal'
  1405. }).html('Close');
  1406. button_for_save = $("<button>", {
  1407. 'class': 'btn btn-primary',
  1408. 'type': 'button',
  1409. 'onclick': "postAnnualReport(" + annual_id + ")"
  1410. }).html("Submit Annual Report");
  1411. $("#submit-modal-title").html("Are you sure you want to submit this report?");
  1412. $("#submit-modal-body")
  1413. .html(
  1414. "You can submit again later, but may need to give explination to administration on why was it resubmitted." +
  1415. "When submitting, please be patient. It may take a while."
  1416. );
  1417. $('#submit-modal-footer').html(button);
  1418. $("#submit-modal-footer").append(button_for_save);
  1419. }
  1420. $("#submit-modal").modal('toggle');
  1421. }
  1422. )
  1423. }
  1424. function postAnnualReport(annual_id) {
  1425. $.post(
  1426. "{{ URL::action('AnnualPlansController@postAnnualReport') }}/" + annual_id, {},
  1427. function(message) {
  1428. if (message = '200') {
  1429. $("#submit-modal").modal('toggle');
  1430. alert = $('<div/>', {
  1431. 'class': 'alert alert-success alert-dismissible',
  1432. 'role': 'alert'
  1433. })
  1434. button = $('<button/>', {
  1435. 'type': 'button',
  1436. 'class': 'close',
  1437. 'data-dismiss': 'alert',
  1438. 'alert-label': 'close'
  1439. }).html('<span aria-hidden="true">×</span>');
  1440. alert.append(button);
  1441. alert.append(
  1442. '<strong>Report is complete, You can check it out in View Annual Reports or Print Report </strong>'
  1443. )
  1444. alert.appendTo($("#alert-for-save"));
  1445. }
  1446. window.open("{{URL::action('AnnualPlansController@printAnnualReport')}}/"+annual_id+'/1', "_blank");
  1447. });
  1448. }
  1449. </script>
  1450. @stop
  1451. @section('included-js')
  1452. @include('global._datatables_js')
  1453. @stop