Sin descripción

annual_report.blade.php 81KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839
  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" 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. 'onchange': 'checkIfNew(this)'
  455. }).html(GlobalTransCategories);
  456. div_for_category.append(select_for_category);
  457. modalBody.append(select_for_category);
  458. div_description = $('<div>', {
  459. 'class': 'form-group',
  460. }).html('<label> Description</label>');
  461. textarea = $('<textarea>', {
  462. 'class': 'form-control',
  463. 'id': 'description_for_' + typ_semester_course_id,
  464. 'name': 'description',
  465. 'rows': '10'
  466. });
  467. div_description.append(textarea);
  468. modalBody.append(div_description);
  469. modalBody.append('<hr><label>Select when will this transformative action will be implemeneted</label>');
  470. selectpicker_for_semesters = $('<select>', {
  471. 'name': 'selected_semesters_for_' + typ_semester_course_id + '_[]',
  472. 'id': 'selected_semester_first_for_' + typ_semester_course_id,
  473. 'class': 'form-control selectpicker'
  474. });
  475. options_for_semesters = '<option value = "0">Nothing Selected</option>';
  476. $.each(course_code.future_typ_course_id.future_semesters, function(index, typ_future) {
  477. options_for_semesters += '<option value="' + typ_future.typ_future_course_id +
  478. '" data-semester-id ="' + typ_future.semester_id + '" data-objective-id = "' + typ_future
  479. .objective_id + '" >' + typ_future.semester_name + ' [' + typ_future.semester_code + '] ' +
  480. '</option>';
  481. });
  482. selectpicker_for_semesters.html(options_for_semesters);
  483. modalBody.append(selectpicker_for_semesters);
  484. modalBody.append('<br><br>');
  485. button_for_more = $('<button>', {
  486. 'class': 'btn btn-secondary',
  487. 'id': 'add_more_semesters_button_for_' + typ_semester_course_id,
  488. 'onclick': 'addMoreSemesters(' + typ_semester_course_id + ', this)',
  489. 'style': 'float:right'
  490. }).html('<span class="glyphicon glyphicon-plus">' +
  491. '</span>Add another semester');
  492. modalBody.append(button_for_more);
  493. modalBody.append('<br><br>');
  494. modalFooter = $('<div>', {
  495. 'class': 'modal-footer'
  496. });
  497. modalContent.append(modalFooter);
  498. close_button = $('<button>', {
  499. 'type': 'button',
  500. 'class': 'btn btn-secondary',
  501. 'data-dismiss': 'modal',
  502. 'onclick': 'clearInputs()'
  503. }).html('Cancel');
  504. save_button = $('<button>', {
  505. 'class': 'btn btn-primary',
  506. 'id': 'save_button_for_' + typ_semester_course_id,
  507. 'onclick': 'saveFutureTrans(' + typ_semester_course_id + ', "' + course_code.code + '", "' +
  508. course_code.number + '")'
  509. }).html('Save');
  510. modalFooter.append(close_button);
  511. modalFooter.append(save_button);
  512. return_complete_div.append(modalComplete);
  513. //populating existing future transformative actions
  514. //dictionary_if_exists
  515. html_dictionary = {};
  516. $.each(course_code.future_typ_course_id.future_transformative_actions, function(index, typ_future) {
  517. //Populating table for transformative_actions
  518. if (typ_future.trans_id != null) {
  519. //$("#transformative_action_row_"+typ_future.trans_id).length !==0
  520. if (html_dictionary[typ_future.trans_id] !== undefined) {
  521. //$('#transformative_future_semester_for_'+typ_future.trans_id).append(
  522. $(html_dictionary[typ_future.trans_id]).append(
  523. '<p style="display:inline" data-typ-future-course-id ="' + typ_future
  524. .typ_future_course_id + '">, ' + typ_future.semester_code + '</p>');
  525. //)
  526. } else {
  527. //create table rows
  528. new_tr = $('<tr>', {
  529. 'id': 'transformative_action_row_' + typ_future.trans_id,
  530. 'data-at-text': typ_future.at_text,
  531. 'data-description': typ_future.description,
  532. 'data-type-of-TA': typ_future.type_of_TA
  533. });
  534. td_transformative = $('<td>').html("<strong>" + typ_future.at_text + ": </strong>" +
  535. typ_future.description);
  536. html_dictionary[typ_future.trans_id] = $('<td>', {
  537. 'id': 'transformative_future_semester_for_' + typ_future.trans_id
  538. }).html('<p style="display:inline" data-typ-future-course-id = "' + typ_future
  539. .typ_future_course_id + '">' + typ_future.semester_code + '</p>');
  540. inputEdit = $('<button>', {
  541. 'type': 'button',
  542. 'class': 'btn btn-secondary',
  543. 'onclick': 'edit_ta_modal(' + typ_future.trans_id + ', ' +
  544. typ_semester_course_id + ', "' + course_code.code + '", "' + course_code
  545. .number + '");',
  546. //'data-target':'#modal_for_future_trans_'+typ_future.trans_id,
  547. 'id': 'edit_button_for_trans_' + typ_future.trans_id
  548. //'value': 'Edit'
  549. }).html('Edit');
  550. inputDelete = $('<input>', {
  551. 'type': 'button',
  552. 'class': 'btn btn-primary',
  553. 'style': 'display: inline',
  554. 'onclick': 'open_warning_modal(' + typ_future.trans_id + ')',
  555. 'value': 'Delete'
  556. })
  557. td_for_buttons = $('<td>');
  558. td_for_buttons.append(inputEdit);
  559. td_for_buttons.append(inputDelete);
  560. new_tr.append(td_transformative);
  561. new_tr.append(html_dictionary[typ_future.trans_id]);
  562. new_tr.append(td_for_buttons);
  563. new_tr.appendTo(table_for_transformative_future);
  564. }
  565. }
  566. });
  567. return_complete_div.append(
  568. '<hr><button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#modal_for_future_trans_on_' +
  569. typ_semester_course_id + '">' +
  570. 'Add Transformative Actions' +
  571. '</button><hr>')
  572. return return_complete_div;
  573. }
  574. function deleteTrans(trans_id) {
  575. $.post(
  576. "{{ URL::action('TransformativeActionsController@deleteTaFromOutcome') }}", {
  577. trans_id: trans_id
  578. },
  579. function() {
  580. $('#transformative_action_row_' + trans_id).remove();
  581. }
  582. )
  583. }
  584. function clearInputs() {
  585. $('.input-group').remove();
  586. $('textarea[name="description"]').val('');
  587. $('input[name="at_text"]').val('');
  588. $('select[name="type_of_ta"]').val('0');
  589. $('.selectpicker').selectpicker('refresh');
  590. $('.new_type').hide();
  591. }
  592. function edit_ta_modal(future_trans_id, typ_semester_course_id, course_code, course_number) {
  593. at_text_transformative = $('#transformative_action_row_' + future_trans_id).data('at-text');
  594. description = $('#transformative_action_row_' + future_trans_id).data('description');
  595. type_of_TA = $('#transformative_action_row_' + future_trans_id).data('type-of-ta');
  596. semesters_cell = $('#transformative_future_semester_for_' + future_trans_id);
  597. amount_of_semesters = $(semesters_cell).children().length;
  598. for (i = 1; i < amount_of_semesters; i++) {
  599. $('#add_more_semesters_button_for_' + typ_semester_course_id).click();
  600. }
  601. future_typ_for_ta = [];
  602. $.each($(semesters_cell).children(), function(index, p) {
  603. future_typ_for_ta.push($(p).data('typ-future-course-id'));
  604. })
  605. $.each($('select[name="selected_semesters_for_' + typ_semester_course_id + '_[]"]'), function(index, select) {
  606. $(select).val(future_typ_for_ta[index]);
  607. })
  608. $('#save_button_for_' + typ_semester_course_id).attr('onclick', 'saveFutureTrans(' + typ_semester_course_id +
  609. ', "' + course_code + '", "' + course_number + '", ' + future_trans_id + ')')
  610. $('#at_text_for_' + typ_semester_course_id).val(at_text_transformative)
  611. $('#description_for_' + typ_semester_course_id).val(description)
  612. $('#type_of_ta_of_' + typ_semester_course_id).val(type_of_TA);
  613. $('.selectpicker').selectpicker('refresh');
  614. $('#modal_for_future_trans_on_' + typ_semester_course_id).modal();
  615. }
  616. function saveFutureTrans(typ_semester_course_id, course_code, course_number, edit_ta_id = null) {
  617. annual_plan_id = $('#annual_plan').val()
  618. at_text = $('#at_text_for_' + typ_semester_course_id).val();
  619. type_of_TA = $('#type_of_ta_of_' + typ_semester_course_id).val();
  620. is_custom = $('#type_of_ta_of_' + typ_semester_course_id).find('option:selected').data('is-custom');
  621. if (type_of_TA == "new") {
  622. type_of_TA = $('#new_type_type_of_ta_of_' + typ_semester_course_id).val();
  623. is_custom = 1;
  624. new_option = "<option value= '" + type_of_TA + "' data-is-custom='1'>" + type_of_TA + "</option>";
  625. $('#program_custom_action').append(new_option);
  626. }
  627. description = $('#description_for_' + typ_semester_course_id).val();
  628. future_typ_course_id = [];
  629. future_semesters = [];
  630. objective_id = 0
  631. $.each($('select[name="selected_semesters_for_' + typ_semester_course_id + '_[]"]'), function(index, select) {
  632. objective_id = $(select).find('option:selected').data('objective-id');
  633. future_semesters.push($(select).find('option:selected').data('semester-id'));
  634. future_typ_course_id.push($(select).val());
  635. });
  636. $.post(
  637. "{{ URL::action('AnnualPlansController@futureTransformative') }}", {
  638. at_text: at_text,
  639. type_of_TA: type_of_TA,
  640. description: description,
  641. future_semesters: future_semesters,
  642. future_typ_course_id: future_typ_course_id,
  643. is_custom: is_custom,
  644. program_id: {{ $program->id }},
  645. annual_plan_id: annual_plan_id,
  646. course_code: course_code,
  647. course_number: course_number,
  648. objective_id: objective_id,
  649. edit_ta_id: edit_ta_id
  650. },
  651. function(trans_info) {
  652. if (edit_ta_id != null) {
  653. $('#transformative_action_row_' + edit_ta_id).remove();
  654. }
  655. new_tr = $('<tr>', {
  656. 'id': 'transformative_action_row_' + trans_info[0].trans_id,
  657. 'data-at-text': trans_info[0].at_text,
  658. 'data-description': trans_info[0].description,
  659. 'data-type-of-TA': trans_info[0].type_of_TA
  660. });
  661. td_transformative = $('<td>').html("<strong>" + trans_info[0].at_text + ": </strong>" + trans_info[
  662. 0].description);
  663. td_semesters = $('<td>', {
  664. 'id': 'transformative_future_semester_for_' + trans_info[0].trans_id
  665. });
  666. $.each(trans_info, function(index, semester) {
  667. td_semesters.append('<p style="display:inline" data-typ-future-course-id = "' + semester
  668. .typ_future_course_id + '">' + semester.code + ', </p>');
  669. });
  670. inputEdit = $('<button>', {
  671. 'type': 'button',
  672. 'class': 'btn btn-secondary',
  673. 'onclick': 'edit_ta_modal(' + trans_info[0].trans_id + ', ' + typ_semester_course_id +
  674. ')',
  675. //'data-target':'#modal_for_future_trans_'+typ_future.trans_id,
  676. 'id': 'edit_button_for_trans_' + trans_info[0].trans_id
  677. //'value': 'Edit'
  678. }).html('Edit');
  679. inputDelete = $('<input>', {
  680. 'type': 'button',
  681. 'class': 'btn btn-primary',
  682. 'style': 'display: inline',
  683. 'onclick': 'deleteTrans(' + trans_info[0].trans_id + ')',
  684. 'value': 'Delete'
  685. })
  686. td_for_buttons = $('<td>');
  687. td_for_buttons.append(inputEdit);
  688. td_for_buttons.append(inputDelete);
  689. new_tr.append(td_transformative);
  690. new_tr.append(td_semesters);
  691. new_tr.append(td_for_buttons);
  692. new_tr.appendTo("#transformative_action_future_body_" + typ_semester_course_id);
  693. $('#modal_for_future_trans_on_' + typ_semester_course_id).modal('toggle');
  694. clearInputs();
  695. }
  696. )
  697. }
  698. function addMoreSemesters(typ_semester_course_id, button_add_new_semester) {
  699. first_select_options = $('#selected_semester_first_for_' + typ_semester_course_id).html();
  700. /*<div class="input-group">
  701. <select class="form-control">
  702. <option>Select option..</option>
  703. <option>Option 1</option>
  704. <option>Option 2</option>
  705. </select>
  706. <span class="input-group-btn">
  707. <button class="btn btn-default" type="button" tabindex="-1"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
  708. </span>
  709. </div> */
  710. input_group = $('<div>', {
  711. 'class': 'input-group'
  712. });
  713. newselect = $('<select>', {
  714. 'name': 'selected_semesters_for_' + typ_semester_course_id + '_[]',
  715. //'id':'selected_semester_first_for_'+typ_semester_course_id,
  716. 'class': 'form-control selectpicker'
  717. }).html(first_select_options);
  718. span_group = $("<span>", {
  719. 'class': 'input-group-btn',
  720. });
  721. button_for_close = $('<button>', {
  722. 'class': 'btn btn-primary',
  723. 'type': 'button',
  724. 'onclick': '$(this).parent().parent().remove()'
  725. }).html('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>');
  726. span_group.append(button_for_close);
  727. input_group.append(newselect);
  728. input_group.append(span_group);
  729. input_group.insertBefore($(button_add_new_semester));
  730. //input_group.prepend('<hr>');
  731. $('.selectpicker').selectpicker('refresh');
  732. }
  733. function checkIfNew(select) {
  734. id = $(select).attr('id');
  735. if ($(select).val() == "new") {
  736. var new_div = $('<div/>', {
  737. 'class': 'form-group new_type'
  738. }).html("<label>New Type </label>");
  739. var input = $("<input/>", {
  740. 'type': 'text',
  741. 'id': 'new_type_' + id,
  742. 'name': "new_type",
  743. 'class': 'form-control'
  744. });
  745. new_div.append(input);
  746. $(select).parent().after(new_div)
  747. } else {
  748. $(select).parent().next('.new_type').remove();
  749. }
  750. }
  751. GlobalTransCategories = '';
  752. function fetchEverything(li) {
  753. var outcome_id = $(li).data('outcome-id');
  754. var name = $(li).data('outcome-name');
  755. var semester_id = $(li).data('semester-id');
  756. var annual_plan_id = $(li).data('annual-plan');
  757. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  758. $('#theChange').data('annual-plan', annual_plan);
  759. $.post(
  760. "{{ URL::action('AnnualPlansController@fetchReportWithOutcome') }}", {
  761. semester_id: semester_id,
  762. outcome_id: outcome_id,
  763. program_id: {{ $program->id }},
  764. annual_plan_id: annual_plan_id,
  765. typ_semester_outcome_id: typ_semester_outcome_id
  766. },
  767. function(outcome) {
  768. if (outcome.objectives) {
  769. $('table').show();
  770. $('#outcome-display').parent().show();
  771. $('#outcome-display .panel-title').html(name);
  772. $('#allLists').empty();
  773. $('#levelTabs').empty();
  774. $('.no-outcome').hide();
  775. if (outcome.outcome_program_goal) {
  776. outcome.outcome_program_goal = outcome.outcome_program_goal.expected_target;
  777. } else {
  778. outcome.outcome_program_goal = 'It has not been defined';
  779. }
  780. GlobalTransCategories = outcome.transformative_actions_categories_html;
  781. var outcomeHTML = "<h4>Performance of Students by Learning Outcome</h4>" +
  782. '<h5 style = "display: inline; margin:30px;">Target to achieve the learning outcome: </h5>' +
  783. '<p style = "display: inline;"> <i> ' + outcome.expected_outcome +
  784. '% or more of the attempts </i>' + '</p>' +
  785. '<br><h5 style = "display: inline; margin:30px;">Expected percent of students achieving the target by learning outcome: </h5>' +
  786. '<p style = "display: inline;"> <i>' + outcome.outcome_program_goal + '%</i></p>';
  787. $('#outcomeInfo').html('<p class="outcome-definition">' + outcome.definition + '</p>' +
  788. outcomeHTML);
  789. //theStudentOutcomeTable = $("<table/>");
  790. //theStudentOutcomeTable.hide();
  791. ///$('#outcomeInfo').append(theStudentOutcomeTable);
  792. wholeDict = {};
  793. tableStudent = $('<table/>', {
  794. 'class': 'table table-striped table-condensed datatable'
  795. });
  796. tableStudent.html('<thead><tr>' +
  797. '<th>Student</th>' +
  798. '<th>Criteria Attempted</th>' +
  799. '<th>Criteria Achieved</th>' +
  800. '<th>Percentage</th>' +
  801. '<th>Outcome Achieved</th>' +
  802. '</tr></thead><tbody></tbody>');
  803. first_objective_id = outcome.objectives[0].id;
  804. $.each(outcome.objectives, function(index, objective) {
  805. li = $('<li/>', {
  806. 'role': 'presentation',
  807. 'id': 'li_for_' + objective.objective_id
  808. });
  809. a = $('<a/>', {
  810. 'data-toggle': 'tab',
  811. 'id': 'a_for_' + objective.objective_id,
  812. 'href': '#' + objective.objective_id,
  813. 'role': 'tab'
  814. }).html('Objective ' + (index + 1));
  815. li.append(a);
  816. $('#levelTabs').append(li);
  817. objective_title = "<h3>" + objective.text + '</h3>';
  818. div = $('<div/>', {
  819. 'role': 'tabpanel',
  820. 'class': 'tab-pane',
  821. 'id': objective.objective_id
  822. }).html(objective_title);
  823. div.appendTo($('#allLists'))
  824. div.append(
  825. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  826. );
  827. if (objective.courses) {
  828. $.each(objective.courses, function(index, course_code) {
  829. if (course_code.criteria.length) {
  830. $.each(course_code.students, function(index, student) {
  831. if (wholeDict[student.student_id] === undefined) {
  832. wholeDict[student.student_id] = {
  833. 'student': student.student_id,
  834. 'criteria_attempted': 0,
  835. 'criteria_achieved': 0
  836. }
  837. }
  838. wholeDict[student.student_id][
  839. "criteria_attempted"
  840. ] += student
  841. .criteria_attempted;
  842. wholeDict[student.student_id][
  843. "criteria_achieved"
  844. ] += student
  845. .criteria_achieved;
  846. });
  847. /*div.append(
  848. '<p>The following results are from the courses in the selected semester with the focused criteria in the selected annual plan</p>'
  849. );*/
  850. table = $('<table/>', {
  851. 'class': 'table table-striped table-condensed datatable'
  852. }).html('<thead><th>Criterion</th><th>' +
  853. 'Number of Students Assessed </th>' +
  854. '<th>Number of students that achieved the target</th></thead>'
  855. );
  856. tbody = $('<tbody/>')
  857. $.each(course_code.criteria, function(index, criterion) {
  858. tr = $('<tr/>').append(
  859. "<td>" + criterion.name + "</td>" +
  860. "<td>" + criterion.criteria_attempted +
  861. "</td>" +
  862. "<td>" + criterion.criteria_achieved +
  863. "</td>"
  864. );
  865. tbody.append(tr);
  866. });
  867. table.append(tbody);
  868. Course_section = '<h3>' + course_code.code + ' ' +
  869. course_code.number + '</h3><hr>';
  870. div.append(Course_section)
  871. div.append('<h4> Criteria Assessed in ' + course_code.code +
  872. ' ' + course_code.number + '</h4>')
  873. div.append(table);
  874. if (course_code.transforming_actions.length) {
  875. table_for_transformative_actions = $('<table>', {
  876. 'class': 'table table-striped table-condensed datatable'
  877. }).html(
  878. '<thead><th>Transformative Actions Proposed in Annual Plan</th>' +
  879. '<th>Follow up </th>' +
  880. '</thead>'
  881. );
  882. tbody_for_transformative_actions = $('<tbody>');
  883. $.each(course_code.transforming_actions, function(index,
  884. transformative_action) {
  885. button_for_followup = $('<button>', {
  886. 'class': 'btn btn-secondary',
  887. 'onclick': 'give_follow_up_questions(' +
  888. transformative_action.id +
  889. ', "' + outcome.semester_info
  890. .code + '", ' + outcome
  891. .semester_info.id + ')'
  892. }).html('Follow Up Questions');
  893. table_row = "<tr>" +
  894. '<td><p><strong>' + transformative_action
  895. .at_text + ': </strong>' +
  896. transformative_action.description +
  897. '</p></td>' +
  898. '<td>' + button_for_followup.prop(
  899. 'outerHTML') + '</td></tr>';
  900. tbody_for_transformative_actions.append(
  901. table_row)
  902. })
  903. table_for_transformative_actions.append(
  904. tbody_for_transformative_actions);
  905. div.append('<hr><h4>Transformative actions for ' +
  906. course_code.code + ' ' + course_code.number +
  907. '</h4>')
  908. div.append(table_for_transformative_actions);
  909. div.append('<hr>');
  910. //table_for_transformative_actions.DataTable();
  911. }
  912. the_drawn_transformative_future_html =
  913. draw_transformative_future_course(course_code, outcome
  914. .transformative_actions_categories_html);
  915. div.append(the_drawn_transformative_future_html);
  916. $('.selectpicker').selectpicker('refresh');
  917. table.DataTable();
  918. }
  919. })
  920. } else {
  921. div.append('<div class="no-outcome alert alert-info"' +
  922. '<p>No Course in plan has assessed yet</p>' +
  923. '</div>')
  924. }
  925. })
  926. draw_transformative_actions(outcome.transforming_actions, outcome.semester_info.id)
  927. draw_comment_section(typ_semester_outcome_id, outcome.comments);
  928. //$('#a_for_'+first_objective_id).click();
  929. theArray = [];
  930. $('#tableOutcome').html(tableStudent);
  931. //tableStudent.appendTo($('#outcomeInfo'));
  932. tableStudent = tableStudent.DataTable({
  933. dom: 'Bfrtip',
  934. buttons: [
  935. 'csv', 'excel', 'pdf', 'print'
  936. ]
  937. });
  938. students_attempted = 0;
  939. students_achieved = 0;
  940. $.each(wholeDict, function(key, dict) {
  941. if (dict.criteria_attempted) {
  942. students_attempted += 1;
  943. percentage = ((dict.criteria_achieved / dict.criteria_attempted) * 100).toFixed(
  944. 2);
  945. if (parseFloat(percentage) >= parseFloat(outcome.expected_outcome)) {
  946. achieved = "Yes"
  947. students_achieved += 1;
  948. } else achieved = "No"
  949. } else {
  950. percentage = "N/A"
  951. achieved = "N/A"
  952. }
  953. tableStudent.row.add([
  954. dict.student,
  955. dict.criteria_attempted,
  956. dict.criteria_achieved,
  957. percentage,
  958. achieved
  959. ]);
  960. })
  961. tableStudent.draw();
  962. if (students_attempted) {
  963. studentPercentage = ((students_achieved / students_attempted) * 100).toFixed(2);
  964. if (parseFloat(studentPercentage) >= parseFloat(outcome.outcome_program_goal)) {
  965. FinalReport = "<p style = 'margin: 30px; '><strong>Results for " + outcome.name +
  966. ": </strong><em style = 'color: green'>" +
  967. studentPercentage + "% </em></p>";
  968. } else {
  969. FinalReport = "<p style = 'margin: 30px'><strong>Results for " + outcome.name +
  970. ": </strong><em style = 'color: red'>" +
  971. studentPercentage + "% </em></p>";
  972. }
  973. }
  974. else{
  975. FinalReport = "<p style = 'margin: 30px'><strong>Results for " + outcome.name +
  976. ": </strong><em style = 'color: red'>" +
  977. 0+ "% </em></p>";
  978. }
  979. $("#outcomeInfo").append(FinalReport)
  980. /* table.row.add([
  981. objectivesHTML,
  982. courseshtml,
  983. courseTAhtml
  984. ]);
  985. table.draw();
  986. */
  987. } else {
  988. $('table').hide();
  989. }
  990. }
  991. );
  992. }
  993. function give_follow_up_questions(trans_id, semester_code, semester_id) {
  994. $.ajax({
  995. type: 'POST',
  996. url: "{{ URL::action('TransformativeActionsController@fetchStatus') }}",
  997. data: {
  998. trans_id: trans_id,
  999. semester_id: semester_id
  1000. },
  1001. success: function(transformative_action_with_status) {
  1002. transformative_action = transformative_action_with_status[0];
  1003. $('#transformative_modal_title').html('<strong>' + transformative_action.at_text +
  1004. '</strong>: ' + transformative_action.description);
  1005. $('input[name="implemented"]').prop('checked', false);
  1006. $('input[name="useful"]').prop('checked', false);
  1007. $('#comments').val(' ');
  1008. $('#useful_radio_div').hide();
  1009. $('#comment_div').hide();
  1010. if (transformative_action['status']) {
  1011. transformative_action['status'].accomplished;
  1012. $('input[name="implemented"][value="' + transformative_action['status'].accomplished +
  1013. '"]').prop('checked', true);
  1014. if (transformative_action['status'].accomplished) {
  1015. $('#useful_radio_div').show();
  1016. $('input[name="useful"][value="' + transformative_action['status'].it_was_useful +
  1017. '"]').prop('checked', true);
  1018. $('#implement_textarea').html(
  1019. "Explain briefly details about the implementation of this transformative action"
  1020. );
  1021. } else {
  1022. $('#implement_textarea').html(
  1023. "Explain briefly why this transformative action was not implemented")
  1024. }
  1025. $('#comment_div').show();
  1026. $('#comments').val(transformative_action['status'].comments);
  1027. }
  1028. $('#was_it_implemented').html(
  1029. 'Was this transformative action implemented during Semester ' + semester_code);
  1030. $('#modal-status-trans').modal();
  1031. $('#save_transformative_info').attr('onclick', 'saveTransReport(' + trans_id + ',' +
  1032. semester_id + ',"modal")');
  1033. },
  1034. async: true
  1035. });
  1036. }
  1037. function saveTransReport(trans_id, semester_id, type_of_input) {
  1038. $('.alert-dismissible').remove();
  1039. isEverythingOkay = true;
  1040. if (type_of_input == 'modal') {
  1041. comments = $('#comments').val();
  1042. if (comments.trim().length === 0) {
  1043. alert = $('<div/>', {
  1044. 'class': 'alert alert-danger alert-dismissible',
  1045. 'role': 'alert'
  1046. })
  1047. button = $('<button/>', {
  1048. 'type': 'button',
  1049. 'class': 'close',
  1050. 'data-dismiss': 'alert',
  1051. 'alert-label': 'close'
  1052. }).html('<span aria-hidden="true">×</span>');
  1053. alert.append(button);
  1054. alert.append('<strong>Please write a valid comment </strong>')
  1055. $('#implement_texarea').after(alert);
  1056. isEverythingOkay = false;
  1057. $('html, body').animate({
  1058. scrollTop: $(alert).offset().top
  1059. }, 500);
  1060. $(alert).focus();
  1061. }
  1062. accomplished = parseInt($('input[name="implemented"]:checked').val());
  1063. if (accomplished === undefined) {
  1064. alert = $('<div/>', {
  1065. 'class': 'alert alert-danger alert-dismissible',
  1066. 'role': 'alert'
  1067. })
  1068. button = $('<button/>', {
  1069. 'type': 'button',
  1070. 'class': 'close',
  1071. 'data-dismiss': 'alert',
  1072. 'alert-label': 'close'
  1073. }).html('<span aria-hidden="true">×</span>');
  1074. alert.append(button);
  1075. alert.append('<strong>Check if it was implemented </strong>')
  1076. $('#was_it_implemented').after(alert);
  1077. isEverythingOkay = false;
  1078. $('html, body').animate({
  1079. scrollTop: $(alert).offset().top
  1080. }, 500);
  1081. $(alert).focus();
  1082. }
  1083. if (accomplished == 1) {
  1084. was_it_useful = $('input[name="useful"]:checked').val();
  1085. if (was_it_useful === undefined) {
  1086. alert = $('<div/>', {
  1087. 'class': 'alert alert-danger alert-dismissible',
  1088. 'role': 'alert'
  1089. })
  1090. button = $('<button/>', {
  1091. 'type': 'button',
  1092. 'class': 'close',
  1093. 'data-dismiss': 'alert',
  1094. 'alert-label': 'close'
  1095. }).html('<span aria-hidden="true">×</span>');
  1096. alert.append(button);
  1097. alert.append('<strong>Check if it was implemented </strong>')
  1098. $('#useful_radio_div').prepend(alert);
  1099. isEverythingOkay = false;
  1100. $('html, body').animate({
  1101. scrollTop: $(alert).offset().top
  1102. }, 500);
  1103. $(alert).focus();
  1104. }
  1105. } else was_it_useful = 0;
  1106. results = "";
  1107. } else {
  1108. comments = $('#comments_for_' + trans_id).val();
  1109. if (comments.trim().length === 0) {
  1110. alert = $('<div/>', {
  1111. 'class': 'alert alert-danger alert-dismissible',
  1112. 'role': 'alert'
  1113. })
  1114. button = $('<button/>', {
  1115. 'type': 'button',
  1116. 'class': 'close',
  1117. 'data-dismiss': 'alert',
  1118. 'alert-label': 'close'
  1119. }).html('<span aria-hidden="true">×</span>');
  1120. alert.append(button);
  1121. alert.append('<strong>Write a valid comment before saving! </strong>')
  1122. $('#comments_for_' + trans_id).before(alert);
  1123. isEverythingOkay = false;
  1124. $('html, body').animate({
  1125. scrollTop: $(alert).offset().top
  1126. }, 500);
  1127. $(alert).focus();
  1128. }
  1129. accomplished = 1;
  1130. was_it_useful = $('input[name="useful_for_' + trans_id + '"]:checked').val();
  1131. if (was_it_useful === undefined) {
  1132. alert = $('<div/>', {
  1133. 'class': 'alert alert-danger alert-dismissible',
  1134. 'role': 'alert'
  1135. })
  1136. button = $('<button/>', {
  1137. 'type': 'button',
  1138. 'class': 'close',
  1139. 'data-dismiss': 'alert',
  1140. 'alert-label': 'close'
  1141. }).html('<span aria-hidden="true">×</span>');
  1142. alert.append(button);
  1143. alert.append('<strong>Please check if it was helpful </strong>')
  1144. $('input[name="useful_for_' + trans_id + '"]').eq(0).parent().before(alert);
  1145. isEverythingOkay = false;
  1146. $('html, body').animate({
  1147. scrollTop: $(alert).offset().top
  1148. }, 500);
  1149. $(alert).focus();
  1150. }
  1151. results = $('#results_for_' + trans_id).val();
  1152. if (results.trim().length === 0) {
  1153. alert = $('<div/>', {
  1154. 'class': 'alert alert-danger alert-dismissible',
  1155. 'role': 'alert'
  1156. })
  1157. button = $('<button/>', {
  1158. 'type': 'button',
  1159. 'class': 'close',
  1160. 'data-dismiss': 'alert',
  1161. 'alert-label': 'close'
  1162. }).html('<span aria-hidden="true">×</span>');
  1163. alert.append(button);
  1164. alert.append('<strong>Please check if it was helpful </strong>')
  1165. $('#results_for_' + trans_id).before(alert);
  1166. isEverythingOkay = false;
  1167. $('html, body').animate({
  1168. scrollTop: $(alert).offset().top
  1169. }, 2000);
  1170. $(alert).focus();
  1171. }
  1172. }
  1173. if (isEverythingOkay == false) return;
  1174. $.post(
  1175. "{{ URL::action('TransformativeActionsController@saveTransStatus') }}", {
  1176. semester_id: semester_id,
  1177. trans_id: trans_id,
  1178. results: results,
  1179. comments: comments,
  1180. accomplished: accomplished,
  1181. was_it_useful: was_it_useful,
  1182. },
  1183. function(message) {
  1184. if (type_of_input == 'modal') {
  1185. $('#modal-status-trans').modal("toggle");
  1186. } else {
  1187. alert = $('<div/>', {
  1188. 'class': 'alert alert-success alert-dismissible',
  1189. 'role': 'alert'
  1190. })
  1191. button = $('<button/>', {
  1192. 'type': 'button',
  1193. 'class': 'close',
  1194. 'data-dismiss': 'alert',
  1195. 'alert-label': 'close'
  1196. }).html('<span aria-hidden="true">×</span>');
  1197. alert.append(button);
  1198. alert.append('<strong>Saved! </strong>')
  1199. $(type_of_input).parent().prepend(alert);
  1200. }
  1201. }
  1202. )
  1203. }
  1204. $('#allOutcomes').hide();
  1205. function fetchInfo(id) {
  1206. annual_id = $("#" + id).val();
  1207. program_id = {{ $program->id }};
  1208. $.post("{{ URL::action('AnnualPlansController@fetchInfo') }}", {
  1209. id: annual_id,
  1210. program_id: program_id
  1211. },
  1212. function(json) {
  1213. div = $('<div/>', {
  1214. 'class': 'list-group',
  1215. 'id': 'list'
  1216. });
  1217. if (json.outcomes.first) {
  1218. header5 = $('<h5/>', {
  1219. 'style': "padding-left: 10px"
  1220. }).html("First Semester");
  1221. div.append(header5);
  1222. list = '';
  1223. for (outcome in json.outcomes.first) {
  1224. list +=
  1225. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  1226. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.first[
  1227. outcome].typ_semester_outcome_id + "' data-semester-id = '" + json.allSemesterOrder
  1228. .first.id +
  1229. "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" +
  1230. json
  1231. .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[
  1232. outcome]
  1233. .name + " </li>";
  1234. }
  1235. div.append(list);
  1236. }
  1237. if (json.outcomes.second) {
  1238. header4 = $('<h5/>', {
  1239. 'style': "padding-left: 10px"
  1240. }).html("Second Semester");
  1241. div.append(header4);
  1242. list = '';
  1243. for (outcome in json.outcomes.second) {
  1244. list +=
  1245. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  1246. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json.outcomes.second[
  1247. outcome].typ_semester_outcome_id + "'data-semester-id = '" + json.allSemesterOrder
  1248. .second.id +
  1249. "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" +
  1250. json
  1251. .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
  1252. outcome].name + " </li>";
  1253. }
  1254. div.append(list);
  1255. }
  1256. html = div[0].innerHTML;
  1257. $("#allOutcomes").html(div[0].innerHTML);
  1258. $("#allOutcomes").show();
  1259. //create button for print
  1260. div_btn_group = $('<div>', {
  1261. 'class': 'btn-group-vertical',
  1262. 'role': 'group'
  1263. });
  1264. button_save = $('<button>', {
  1265. 'class': ' btn btn-lg btn-primary btn-block',
  1266. 'type': 'button',
  1267. 'onclick': 'check_if_ready(' + annual_id + ')'
  1268. }).html('Submit Annual Report');
  1269. button_print = $("<button>", {
  1270. "class": 'btn btn-lg btn-primary btn-block',
  1271. "type": "button",
  1272. "onclick": "window.location.href = " +
  1273. "'{{ URL::action('AnnualPlansController@printAnnualReport') }}" +
  1274. "/" +
  1275. annual_id + "'",
  1276. }).html("Print Report");
  1277. div_btn_group.append(button_print);
  1278. div_btn_group.append(button_save);
  1279. $('#printButton').html(div_btn_group);
  1280. },
  1281. "json",
  1282. );
  1283. }
  1284. function check_if_ready(annual_id) {
  1285. $.post(
  1286. "{{ URL::action('AnnualPlansController@checkIfReady') }}", {
  1287. annual_id: annual_id
  1288. },
  1289. function(courses_with_missing_data) {
  1290. if (courses_with_missing_data.outcomes.length > 0 || courses_with_missing_data.courses.length > 0) {
  1291. //id="submit-modal">
  1292. //This means there is still data to be filled before submit.
  1293. $('#submit-modal-title').html("There is still some data to be filled. ")
  1294. //close button <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  1295. button = $('<button>', {
  1296. 'class': 'btn btn-secondary',
  1297. 'type': 'button',
  1298. 'data-dismiss': 'modal'
  1299. }).html('Close');
  1300. $('#submit-modal-footer').html(button);
  1301. $('#submit-modal-body').html("These are the following transformative actions");
  1302. if (courses_with_missing_data.courses.length > 0) {
  1303. div_for_courses = $("<div>", {
  1304. 'id': 'courses_ta',
  1305. }).html("<h4>These are the Courses Transformative Actions need to be filled</h4>")
  1306. ol_course_ta = $("<ol>", {
  1307. 'id': 'course_ta',
  1308. 'type': 'I'
  1309. });
  1310. div_for_courses.append(ol_course_ta);
  1311. //"<ol id='course_ta' type='I'>");
  1312. //div_for_outcomes
  1313. $('#submit-modal-body').append(div_for_courses)
  1314. $.each(courses_with_missing_data.courses, function(index, info) {
  1315. /*
  1316. $array_to_be_appended = [
  1317. 'course_name' => $course->code . '-' . $course->number,
  1318. 'objective' => $objective_info,
  1319. 'outcome' => $outcome_info,
  1320. 'transformative_action_title' => $ta->at_text,
  1321. 'transformative_action_description' => $ta->description
  1322. ];
  1323. */
  1324. selector = $('#course_typ_outcome_' + info.outcome.typ_semester_outcome_id);
  1325. if (selector.length === 0) {
  1326. li_outcome = $('<li>').html(info.outcome.name);
  1327. ol = $("<ol>", {
  1328. 'id': 'course_typ_outcome_' + info.outcome
  1329. .typ_semester_outcome_id,
  1330. 'type': 'A'
  1331. });
  1332. li_outcome.append(ol);
  1333. $("#course_ta").append(li_outcome);
  1334. //selector = $('<div>').html(info.outcome.typ_semester_outcome_id);
  1335. //selector.append('<ol type = "A">');
  1336. //objective_li = $("<li>");
  1337. //objective_id = $("<div>",{
  1338. // 'class':'typ-objective-'+info.objective.typ_semester_objective_id,
  1339. //}).html();
  1340. //li.append(selector);
  1341. }
  1342. selector = $("#course_typ_objective_" + info.objective
  1343. .typ_semester_objective_id)
  1344. if (selector.length === 0) {
  1345. li_objective = $("<li>").html(info.objective.text);
  1346. ol_objective = $("<ol>", {
  1347. 'id': 'course_typ_objective_' + info.objective
  1348. .typ_semester_objective_id,
  1349. 'type': '1'
  1350. });
  1351. li_objective.append(ol_objective);
  1352. $('#course_typ_outcome_' + info.outcome.typ_semester_outcome_id).append(
  1353. li_objective);
  1354. }
  1355. selector = $("#course_ul_" + info.typ_semester_course_id)
  1356. if (selector.length === 0) {
  1357. li_course = $("<li>").html(info.course_name);
  1358. ol_course = $("<ul>", {
  1359. 'id': "course_ul_" + info.typ_semester_course_id,
  1360. });
  1361. li_course.append(ol_course);
  1362. $('#course_typ_objective_' + info.objective.typ_semester_objective_id)
  1363. .append(li_course);
  1364. }
  1365. li_ta = $('<li>').html('<p><strong>' + info.transformative_action_title +
  1366. ': </strong>' + info.transformative_action_description + '</p>');
  1367. $("#course_ul_" + info.typ_semester_course_id).append(li_ta);
  1368. });
  1369. //$('#submit-modal-body').append("</ol>")
  1370. //$('#submit-modal-footer').html(button);
  1371. }
  1372. if (courses_with_missing_data.outcomes.length > 0) {
  1373. div_for_outcomes = $("<div>", {
  1374. 'id': 'outcomes_ta',
  1375. }).html("<h4>These are the Program Transformative Actions need to be filled</h4>");
  1376. ol = $('<ol>', {
  1377. 'id': 'list_for_outcomes',
  1378. 'type': 'I'
  1379. });
  1380. ol.appendTo(div_for_outcomes);
  1381. $('#submit-modal-body').append(div_for_outcomes);
  1382. $.each(courses_with_missing_data.outcomes, function(index, info) {
  1383. if ($("#outcome_ta_for_" + info.typ_semester_outcome_id).length === 0) {
  1384. li_outcome = $("<li>").html(info.outcome_name);
  1385. li_outcome.appendTo($("#list_for_outcomes"));
  1386. ol = $('<ol>', {
  1387. 'id': "outcome_ta_for_" + info.typ_semester_outcome_id
  1388. })
  1389. ol.appendTo(li_outcome);
  1390. }
  1391. li = $('<li>').html('<p><strong>' + info.transformative_action_title +
  1392. ': </strong>' + info.transformative_action_description + '</p>');
  1393. $('#outcome_ta_for_' + info.typ_semester_outcome_id).append(li);
  1394. })
  1395. // div_for_outcomes.append(ol);
  1396. }
  1397. } else {
  1398. button = $('<button>', {
  1399. 'class': 'btn btn-secondary',
  1400. 'type': 'button',
  1401. 'data-dismiss': 'modal'
  1402. }).html('Close');
  1403. button_for_save = $("<button>", {
  1404. 'class': 'btn btn-primary',
  1405. 'type': 'button',
  1406. 'onclick': "postAnnualReport(" + annual_id + ")"
  1407. }).html("Submit Annual Report");
  1408. $("#submit-modal-title").html("Are you sure you want to submit this report?");
  1409. $("#submit-modal-body")
  1410. .html(
  1411. "You can submit again later, but may need to give explination to administration on why was it resubmitted." +
  1412. "When submitting, please be patient. It may take a while."
  1413. );
  1414. $('#submit-modal-footer').html(button);
  1415. $("#submit-modal-footer").append(button_for_save);
  1416. }
  1417. $("#submit-modal").modal('toggle');
  1418. }
  1419. )
  1420. }
  1421. function postAnnualReport(annual_id) {
  1422. $.post(
  1423. "{{ URL::action('AnnualPlansController@postAnnualReport') }}/" + annual_id, {},
  1424. function(message) {
  1425. if (message = '200') {
  1426. $("#submit-modal").modal('toggle');
  1427. alert = $('<div/>', {
  1428. 'class': 'alert alert-success alert-dismissible',
  1429. 'role': 'alert'
  1430. })
  1431. button = $('<button/>', {
  1432. 'type': 'button',
  1433. 'class': 'close',
  1434. 'data-dismiss': 'alert',
  1435. 'alert-label': 'close'
  1436. }).html('<span aria-hidden="true">×</span>');
  1437. alert.append(button);
  1438. alert.append(
  1439. '<strong>Report is complete, You can check it out in View Annual Reports or Print Report </strong>'
  1440. )
  1441. alert.appendTo($("#alert-for-save"));
  1442. }
  1443. window.open("{{URL::action('AnnualPlansController@printAnnualReport')}}/"+annual_id+'/1', "_blank");
  1444. });
  1445. }
  1446. </script>
  1447. @stop
  1448. @section('included-js')
  1449. @include('global._datatables_js')
  1450. @stop