Geen omschrijving

annual-plans.blade.php 64KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. @extends('layouts.master-2')
  2. @section('navigation')
  3. @if (Auth::user()->role == 1)
  4. @include('local.managers.admins._navigation')
  5. @elseif(Auth::user()->role == 2)
  6. @include('local.managers.sCoords._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. {{-- <a role="button" class="btn btn-secondary"
  21. href="{{ URL::action('AnnualPlansController@viewAllPlans', [$program->id]) }}">View Plans</a> --}}
  22. <select class="form-control selectpicker" id="annual_plan" onchange="fetchInfo('annual_plan')">
  23. <option value='0'> Nothing Selected</option>
  24. @foreach ($annual_plans as $an_plan)
  25. <option value={{ $an_plan->id }}>Plan {{ $an_plan->academic_year }}</option>
  26. @endforeach
  27. </select>
  28. <br>
  29. <div id='allOutcomes'>
  30. </div>
  31. <hr>
  32. <div id="printButton">
  33. </div>
  34. </div>
  35. <div class="col-md-9">
  36. <div id="expected-outcome" class="panel panel-default" data-semester-id="">
  37. <div class="panel-heading">
  38. <h3 class="panel-title">
  39. Expected Target Outcomes
  40. </h3>
  41. <input style="width: 150px;" min="0" class="form-control" type="number">
  42. </div>
  43. </div>
  44. <div id="outcome-display" class="panel panel-default">
  45. <div class="panel-heading">
  46. <h4 class=" panel-title">
  47. Primer Semestre 2019-2020
  48. </h4>
  49. </div>
  50. <div class="panel-body">
  51. <h3 id='criteria_for_courses'></h3>
  52. <p class="outcome-definition "></p>
  53. <div class="table-responsive">
  54. <table class="table table-striped table-condensed datatable"
  55. style="table-layout: fixed ; width : 100%" id='annual_plan_table'>
  56. <thead>
  57. <tr>
  58. <th>Objectives for courses</th>
  59. <th>Criteria per Course</th>
  60. <th>Transformative Actions to be Implemented</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. </tbody>
  65. </table>
  66. </div>
  67. <h3 id='transformative_title'></h3>
  68. <div id='existing_transformative_actions'>
  69. <div class="table-responsive">
  70. <table class="table table-striped table-condensed datatable"
  71. style="table-layout: fixed ; width : 100%" id='transformative_action_table'>
  72. <thead>
  73. <tr id='transformative_columns'>
  74. <th>Title</th>
  75. <th>Description</th>
  76. <th>Type of Transformative Action</th>
  77. <th>Edit Or Delete</th>
  78. </tr>
  79. </thead>
  80. <tbody>
  81. </tbody>
  82. </table>
  83. </div>
  84. </div>
  85. <input type='hidden' id='typ_semester_outcome_id' value='0'>
  86. <div id='new_transformative_actions_to_outcome'>
  87. </div>
  88. <button class='btn btn-md btn-secondary button-add-transformative' id='add_trans_action'
  89. onclick='addTransToPlan()'>
  90. <span class='glyphicon glyphicon-plus'>
  91. </span>
  92. Add another Transformative Action
  93. </button>
  94. <hr>
  95. {{-- <button type="button" class="btn btn-primary" id="submit_modal" data-toggle="modal"
  96. data-target="#modal-submit" style="float: right">Submit Annual Plan</button> --}}
  97. </div>
  98. </div>
  99. </div>
  100. <div class="col-md-9">
  101. <div class="no-outcome alert alert-info">
  102. <p>Select a Learning Outcome to view its information</p>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="modal fade" id="modal-view-objective">
  107. <div class="modal-dialog modal-lg">
  108. <div class="modal-content">
  109. <div class="modal-header">
  110. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  111. aria-hidden="true">&times;</span></button>
  112. <h3 class="modal-title"></h3>
  113. </div>
  114. <div class="modal-body">
  115. </div>
  116. </div><!-- /.modal-content -->
  117. </div><!-- /.modal-dialog -->
  118. </div><!-- /.modal -->
  119. <div class="modal fade" id="submit-modal">
  120. <div class="modal-dialog modal-lg">
  121. <div class="modal-content">
  122. <div class="modal-header">
  123. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  124. aria-hidden="true">&times;</span></button>
  125. <h3 class="modal-title" id="submit-modal-title"></h3>
  126. </div>
  127. <div class="modal-body" id="submit-modal-body">
  128. </div>
  129. <div class='modal-footer' id='submit-modal-footer'>
  130. </div>
  131. </div><!-- /.modal-content -->
  132. </div><!-- /.modal-dialog -->
  133. </div><!-- /.modal -->
  134. <div class="modal fade" id="modal-submit">
  135. <div class="modal-dialog modal-lg">
  136. <div class="modal-content">
  137. <div class="modal-header">
  138. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  139. aria-hidden="true">&times;</span></button>
  140. <h3 class="modal-title">Are you sure you want to submit plan?</h3>
  141. </div>
  142. <div class="modal-body">
  143. Once submitted, you may not be able to edit the plan unless you ask for permission in the "Feedback"
  144. section.
  145. Make sure to check every learning outcome.
  146. </div>
  147. <div class="modal-footer">
  148. <button type="button" class="btn btn-primary" onclick='submit_annual_plan()'>Submit Annual Plan</button>
  149. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  150. </div>
  151. </div><!-- /.modal-content -->
  152. </div><!-- /.modal-dialog -->
  153. </div><!-- /.modal -->
  154. <script>
  155. function nextChar(c) {
  156. return String.fromCharCode(c.charCodeAt(0) + 1);
  157. }
  158. changed = false;
  159. $(document).ready(function() {
  160. // --------------------------------------------------------------------------
  161. // Page load
  162. // --------------------------------------------------------------------------
  163. $('#transformative_action_table').hide();
  164. // Hide accordion panel contents by default
  165. // $('.panel-group .panel-body').hide();
  166. $('.panel-group .panel-body').hide();
  167. $('#outcome-display').parent().hide();
  168. // --------------------------------------------------------------------------
  169. // Functions
  170. // --------------------------------------------------------------------------
  171. // --------------------------------------------------------------------------
  172. // Events
  173. // --------------------------------------------------------------------------
  174. // When list item is clicked, load corresponding info
  175. });
  176. // function CreateOrEdit(id){
  177. // //send data to the database
  178. // console.log(id);
  179. // annual_id = $("#"+id);
  180. // console.log(console.log(annual_id));
  181. // }
  182. //Submit Plan
  183. /*function submit_annual_plan() {
  184. annual_plan_id = $('#annual_plan').val();
  185. $.post("{{ URL::action('AnnualPlansController@submitAnnualPlan') }}", {
  186. annual_plan_id: annual_plan_id
  187. },
  188. function() {
  189. location.reload();
  190. })
  191. }*/
  192. //fetch after submit
  193. function fetchEverythingSubmitted(li) {
  194. var id = $(li).data('outcome-id');
  195. var name = $(li).data('outcome-name');
  196. var semester = $(li).data('semester-id');
  197. var annual_plan = $(li).data('annual-plan');
  198. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  199. $('#expected-outcome').data('semester-id', semester);
  200. $('#typ_semester_outcome_id').val(typ_semester_outcome_id);
  201. $('#theChange').data('annual-plan', annual_plan);
  202. $.post(
  203. "{{ URL::action('AnnualPlansController@fetchTheAnnualPlan') }}", {
  204. id: id,
  205. semester: semester,
  206. typ_semester_outcome_id: typ_semester_outcome_id,
  207. program_id: program_id
  208. },
  209. function(array) {
  210. objectives = array.typ_objectives;
  211. courses = array.typ_courses;
  212. criteria_for_courses = array.courses_criteria;
  213. courses_transformatives = array.courses_transformative_actions;
  214. transformative_to_outcome = array.transformative_outcome;
  215. var nextLetter = "A";
  216. $('table').show();
  217. $('#outcome-display').parent().show();
  218. $('.no-outcome').parent().hide();
  219. $('#criteria_for_courses').html('Criteria for Courses Associated to ' + name);
  220. $('#transformative_title').html('Transformative Actions for ' + name);
  221. $('#outcome-display .panel-title').html(name);
  222. $('#submit_modal').hide();
  223. var expected_target = array.expected_target;
  224. $('#expected-outcome .form-control').val(expected_target.expected_target);
  225. $('#expected-outcome .form-control').prop('disabled', true);
  226. $('#add_trans_action').hide();
  227. annual_table = $('#annual_plan_table').DataTable();
  228. annual_table.clear();
  229. $.each(objectives, function(index, objective) {
  230. var objectivesHTML = '<div class="criterion-field" data-typ-objective-id = "' +
  231. objective.typ_semester_objective_id + '" onclick = "fetchObjectiveInfo(this)">';
  232. objectivesHTML += '<strong>' + nextLetter + '. ' + objective.text +
  233. '</strong></div>';
  234. courses_cell_html = '<div id="typ_semester_objective_id_' + objective
  235. .typ_semester_objective_id +
  236. '"></div>';
  237. transformative_cell_html = '<div id="transformative_typ_semester_objective_id_' +
  238. objective
  239. .typ_semester_objective_id +
  240. '"></div>'
  241. nextLetter = nextChar(nextLetter);
  242. //$('#annual_plan_table').children().eq(1).append(objectivesHTML);
  243. annual_table.row.add([
  244. objectivesHTML,
  245. courses_cell_html,
  246. transformative_cell_html
  247. ])
  248. });
  249. annual_table.draw();
  250. $.each(courses, function(index, course) {
  251. div_for_course_criteria = $('<div>', {
  252. 'id': 'criteria_for_course_' + course.typ_semester_course_id
  253. });
  254. div_for_course_transformative = $('<div>', {
  255. 'id': 'transformative_for_course_' + course.typ_semester_course_id
  256. });
  257. courseshtml = ' &#8226; [' + course.code + course.number + '] ' +
  258. course.name + '<br>'
  259. courseTAhtml = ' &#8226; [' + course.code + course.number + '] ' +
  260. course.name + '<br>';
  261. div_for_course_criteria.append(courseshtml);
  262. div_for_course_transformative.append(courseTAhtml);
  263. $('#typ_semester_objective_id_' + course.typ_semester_objective_id).append(
  264. div_for_course_criteria);
  265. $('#transformative_typ_semester_objective_id_' + course.typ_semester_objective_id)
  266. .append(
  267. div_for_course_transformative);
  268. })
  269. $.each(criteria_for_courses, function(index, criterion) {
  270. criteriaHTML = '\t&nbsp;&nbsp; ' + (index + 1) + ". " + criterion.name + '\n\n<br>';
  271. $('#criteria_for_course_' + criterion.typ_semester_course_id).append(criteriaHTML);
  272. })
  273. $.each(courses_transformatives, function(index, transformative_action) {
  274. transformativeHTML = '\t&nbsp;&nbsp; ' + (index + 1) + ". " + transformative_action
  275. .description +
  276. '\n\n<br>';
  277. $('#transformative_for_course_' + transformative_action.typ_semester_course_id).append(
  278. transformativeHTML);
  279. })
  280. //remove edit or delete column
  281. transformative_table = $('#transformative_action_table').DataTable();
  282. transformative_table.clear();
  283. $.each(transformative_to_outcome, function(index, transformative_action) {
  284. transformative_table.row.add([
  285. transformative_action.at_text,
  286. transformative_action.description,
  287. transformative_action.type_of_TA,
  288. 'cannot be editted'
  289. ])
  290. })
  291. transformative_table.draw();
  292. transformative_table.column(3).visible(false);
  293. //var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  294. });
  295. }
  296. function fetchObjectiveInfo(objective_div) {
  297. typ_objective_id = $(objective_div).data('typ-objective-id');
  298. objective = $(objective_div).html();
  299. $.ajax({
  300. type: 'POST',
  301. url: "{{ URL::action('AnnualPlansController@fetchObjectiveInfo') }}",
  302. data: {
  303. typ_objective_id: typ_objective_id
  304. },
  305. success: function(courses) {
  306. $('.modal-title').html(objective);
  307. descriptions = '';
  308. $('.modal-body').empty();
  309. $.each(courses, function(index, course) {
  310. $('.modal-body').append('<h4>' + course.code + ' ' + course
  311. .number + ': ' +
  312. course.name + '</h4>')
  313. $('.modal-body').append(
  314. '<br><p>The following course is tied to these criteria: </p>'
  315. )
  316. $.each(course.criteria, function(index, criterion) {
  317. criterion_html =
  318. '<h5 style ="text-indent: 15px;">' + (index +
  319. 1) +
  320. '. ' + criterion.name + '</h5>';
  321. table = $('<table>', {
  322. 'style': 'margin-left:15px',
  323. //'id':'criteria-'+criterion.id,
  324. 'class': "table table-striped table-condensed table-bordered"
  325. });
  326. thead = $('<thead/>');
  327. tr = $('<tr/>');
  328. for (i = 0; i < criterion.num_scales; i++) {
  329. minimumScore = 1 + (i * (criterion.max_score /
  330. criterion
  331. .num_scales));
  332. maximumScore = (1 + i) * (criterion.max_score /
  333. criterion
  334. .num_scales);
  335. th = '<th>Scale ' + (i + 1) + '. (' +
  336. minimumScore + ' - ' +
  337. maximumScore + ')</th>';
  338. tr.append(th);
  339. }
  340. thead.append(tr);
  341. table.append(thead);
  342. tbody = $('<tbody>')
  343. tr_for_body = $('<tr>', {
  344. 'id': 'criterion_' + criterion.id
  345. })
  346. td_for_criteria = '';
  347. $.each(criterion.scales, function(index, scale) {
  348. td_for_criteria += '<td>' + scale
  349. .description + '</td>';
  350. });
  351. tr_for_body.html(td_for_criteria);
  352. tbody.append(tr_for_body);
  353. table.append(tbody);
  354. $('.modal-body').append(criterion_html);
  355. $('.modal-body').append(table);
  356. })
  357. $('.modal-body').append('<hr>')
  358. });
  359. $('#modal-view-objective').modal();
  360. },
  361. async: true
  362. });
  363. }
  364. function fetchEverything(li) {
  365. $('#close_button').click();
  366. var id = $(li).data('outcome-id');
  367. var name = $(li).data('outcome-name');
  368. var semester = $(li).data('semester-id');
  369. var annual_plan = $(li).data('annual-plan');
  370. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  371. $('#expected-outcome').data('semester-id', semester);
  372. $('#typ_semester_outcome_id').val(typ_semester_outcome_id);
  373. $('#theChange').data('annual-plan', annual_plan);
  374. $.post(
  375. "../annual-plan-fetchTYP/{{ $program->id }}", {
  376. id: id,
  377. semester: semester,
  378. typ_semester_outcome_id: typ_semester_outcome_id,
  379. },
  380. function(json) {
  381. var table = $('#annual_plan_table').DataTable();
  382. table.clear();
  383. var optionsForTADict = {};
  384. var objectives = json.objectives;
  385. var courses = json.courses;
  386. var criteria = json.criteria;
  387. var selected_criteria = json.selected_criteria;
  388. var nextLetter = "A";
  389. if (courses) {
  390. $('table').show();
  391. $('#outcome-display').parent().show();
  392. $('.no-outcome').parent().hide();
  393. //Display title and definition
  394. $('#outcome-display .panel-title').html(name);
  395. var expected_target = json.expected_target;
  396. //check the data type of the expected target
  397. //if the expected_target var is an empty array, set default value
  398. $('#expected-outcome .form-control').val(expected_target.expected_target);
  399. $('#criteria_for_courses').html('Criteria for Courses Associated to ' + name);
  400. $('#transformative_title').html('Transformative Actions for ' + name);
  401. //Empty table
  402. table.clear();
  403. var annual_plan = json.annual_plan.id;
  404. for (objective in objectives) {
  405. var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  406. var objectivesHTML =
  407. '<div class="criterion-field" data-typ-objective-id = "' +
  408. typ_objective_id + '" onclick = "fetchObjectiveInfo(this)">';
  409. var courseshtml = '';
  410. var courseTAhtml = '';
  411. var criteriaHTML = '';
  412. objectivesHTML += '<strong>' + nextLetter + '. ' + objectives[objective]
  413. .text +
  414. '</strong></div>';
  415. // courseshtml += "<strong>Objective "+nextLetter+"</strong>";
  416. // courseshtml += '<ul>';
  417. criteriaHTML += "<strong>Objective " + nextLetter + "</strong>";
  418. //criteriaHTML+= '<ol>';
  419. //var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  420. nextLetter = nextChar(nextLetter);
  421. for (course in courses[objectives[objective].id]) {
  422. courseshtml += ' &#8226; ' + courses[objectives[objective].id][course]
  423. .code + courses[objectives[objective].id][course].number + ' ' +
  424. courses[objectives[objective].id][course].name + '<br>'
  425. courseTAhtml += ' &#8226; ' + courses[objectives[objective].id][course]
  426. .code + courses[objectives[objective].id][course].number + ' ' +
  427. courses[objectives[objective].id][course].name + '<br>'
  428. $divForEach = $('<div/>', {
  429. 'id': 'objective-' + objectives[objective].id
  430. });
  431. $divForSelects = $('<div/>', {
  432. 'id': 'forObjective-' + objectives[objective].id +
  433. '-course-' + courses[
  434. objectives[objective].id][course].typ_course_id,
  435. 'data-amount-select': '0',
  436. 'class': 'form-group',
  437. 'data-annual-plan': json.annual_plan.id
  438. });
  439. options = "<option value = '0' >Nothing Selected</option>"
  440. for (criterion in criteria[objectives[objective].id]) {
  441. options += "<option value='" + criteria[objectives[objective].id][
  442. criterion
  443. ].id +
  444. "'>" + criteria[objectives[objective].id][criterion].name +
  445. "</option>";
  446. }
  447. var $button = $('<button/>', {
  448. 'type': 'button',
  449. 'class': 'btn btn-secondary',
  450. 'onclick': 'addCriteriaTest("forObjective-' + objectives[
  451. objective].id +
  452. "-course-" + courses[objectives[objective].id][course]
  453. .typ_course_id +
  454. '", "' + objectives[objective].id + "-course-" +
  455. courses[objectives[
  456. objective].id][course].typ_course_id + '", ' +
  457. courses[objectives[
  458. objective].id][course].typ_course_id + ', null, "' +
  459. options + '")'
  460. });
  461. $button.append("+ Add criteria");
  462. $divForEach.append($divForSelects);
  463. $divForEach.append("<br>")
  464. $divForEach.append($button);
  465. $divForTA = $('<div/>', {
  466. 'id': 'objectiveTA-' + objectives[objective].id
  467. });
  468. $divForTASelects = $('<div/>', {
  469. 'id': 'forTA-objective-' + objectives[objective].id +
  470. '-course-' + courses[
  471. objectives[objective].id][course].typ_course_id,
  472. 'class': 'form-group',
  473. 'data-amount-ta': '0'
  474. });
  475. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  476. transformativeDefault = json.transformative_actions;
  477. optionsForTa += "<optgroup label='Default'>";
  478. for (trans in transformativeDefault) {
  479. optionsForTa += "<option value='" + transformativeDefault[trans]
  480. .id + "'>" +
  481. transformativeDefault[trans].at_text + "</option> ";
  482. }
  483. optionsForTa += '</optgroup>';
  484. course_id = courses[objectives[objective].id][course].id
  485. transformativeDefault = json.custom_transformative[objectives[objective]
  486. .id][course_id];
  487. if (transformativeDefault != undefined) {
  488. optionsForTa += "<optgroup label = 'Custom'>";
  489. for (trans in transformativeDefault) {
  490. optionsForTa += "<option value='" + transformativeDefault[trans]
  491. .ta_id + "'>" +
  492. transformativeDefault[trans].at_text + "</option> ";
  493. }
  494. }
  495. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  496. var $buttonTA = $('<button/>', {
  497. 'type': 'button',
  498. 'class': 'btn btn-secondary',
  499. 'onclick': 'addTAselect("' + optionsForTa +
  500. '", "forTA-objective-' +
  501. objectives[objective].id + '-course-' + courses[
  502. objectives[objective]
  503. .id][course].typ_course_id + '", ' + annual_plan +
  504. ', ' +
  505. objectives[objective].id + ', ' + typ_course_id + ', 0)'
  506. });
  507. $buttonTA.append("+ Add TA");
  508. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  509. optionsForTADict[typ_course_id] = optionsForTa;
  510. $divForTA.append($divForTASelects);
  511. $divForTA.append('<br>');
  512. $divForTA.append($buttonTA)
  513. courseshtml += $divForEach[0].innerHTML + "<br><br>";
  514. courseTAhtml += $divForTA[0].innerHTML + "<br><br>";
  515. }
  516. /*$divForTA = $('<div/>',{
  517. 'id':'objectiveTA-'+objectives[objective].id
  518. });
  519. $divForTASelects = $('<div/>', {
  520. 'id': 'forTA-objective-'+objectives[objective].id,
  521. 'class':'form-group',
  522. 'data-amount-ta':'0'
  523. });
  524. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  525. transformativeDefault = json.transformative_actions;
  526. optionsForTa+= "<optgroup label='Default'>";
  527. for(trans in transformativeDefault){
  528. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  529. }
  530. optionsForTa+='</optgroup>';
  531. transformativeDefault = json.custom_transformative[objectives[objective].id];
  532. if(transformativeDefault!= undefined){
  533. optionsForTa+="<optgroup label = 'Custom'>";
  534. for(trans in transformativeDefault){
  535. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  536. }
  537. }
  538. var $buttonTA = $('<button/>', {
  539. 'type': 'button',
  540. 'class': 'btn btn-secondary',
  541. 'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_objective_id+', 0)'
  542. });
  543. $buttonTA.append("+ Add TA");
  544. $divForTA.append($divForTASelects);
  545. $divForTA.append('<br>');
  546. $divForTA.append($buttonTA)
  547. */
  548. table.row.add([
  549. objectivesHTML,
  550. courseshtml,
  551. courseTAhtml
  552. ]);
  553. table.draw();
  554. for (course in courses[objectives[objective].id]) {
  555. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  556. if (json.annual_plans_transformative[objectives[objective].id][
  557. typ_course_id
  558. ].length) {
  559. for (i = 0; i < json.annual_plans_transformative[objectives[
  560. objective].id][
  561. typ_course_id
  562. ].length; i++) {
  563. selected_ta = json.annual_plans_transformative[objectives[
  564. objective].id][
  565. typ_course_id
  566. ][i].trans_id;
  567. addTAselect(optionsForTADict[typ_course_id],
  568. "forTA-objective-" + objectives[
  569. objective].id + '-course-' + typ_course_id,
  570. annual_plan, objectives[
  571. objective].id, typ_course_id, selected_ta);
  572. }
  573. } else {
  574. $('#')
  575. addTAselect(optionsForTADict[typ_course_id], "forTA-objective-" +
  576. objectives[
  577. objective].id + '-course-' + typ_course_id, annual_plan,
  578. objectives[
  579. objective].id, typ_course_id, 0);
  580. }
  581. if (json.selected_criteria[objectives[objective].id][typ_course_id]
  582. .length) {
  583. for (i = 0; i < json.selected_criteria[objectives[objective].id][
  584. typ_course_id
  585. ]
  586. .length; i++) {
  587. addCriteriaTest("forObjective-" + objectives[objective].id +
  588. "-course-" +
  589. typ_course_id, "" + objectives[objective].id +
  590. "-course-" +
  591. typ_course_id, "" + json.selected_criteria[objectives[
  592. objective].id][
  593. typ_course_id
  594. ][i].typ_course_id + "", i, options);
  595. $('#criteriaFor' + objectives[objective].id + "-course-" +
  596. typ_course_id + '_' +
  597. i).val(json.selected_criteria[objectives[objective].id][
  598. typ_course_id
  599. ][
  600. i
  601. ].criteria_id);
  602. $('#criteriaFor' + objectives[objective].id + "-course-" +
  603. typ_course_id + '_' +
  604. i).data('old-criteria', json.selected_criteria[
  605. objectives[objective].id]
  606. [typ_course_id][i].criteria_id);
  607. $('#criteriaFor' + objectives[objective].id + "-course-" +
  608. typ_course_id + '_' +
  609. i).selectpicker('refresh');
  610. } // Update display
  611. } else {
  612. addCriteriaTest("forObjective-" + objectives[objective].id +
  613. "-course-" +
  614. typ_course_id, "" + objectives[objective].id + "-course-" +
  615. typ_course_id +
  616. "", "" + typ_course_id + "", 0, options);
  617. $('#criteriaFor' + objectives[objective].id + "-course-" +
  618. typ_course_id + '_0')
  619. .val(0);
  620. $('#criteriaFor' + objectives[objective].id + "-course-" +
  621. typ_course_id + '_0')
  622. .data('old-criteria', 0);
  623. $('#criteriaFor' + objectives[objective].id + "-course-" +
  624. typ_course_id + '_0')
  625. .selectpicker('refresh');
  626. }
  627. }
  628. }
  629. table.draw();
  630. //transformative actions in outcome
  631. GlobalTransCategories = json.categories;
  632. trans_table = $('#transformative_action_table').DataTable();
  633. trans_table.clear();
  634. if (json.transformative_actions_for_outcome.length) {
  635. //trans_table.show()
  636. $.each(json.transformative_actions_for_outcome, function(index, ta) {
  637. title = ta.at_text;
  638. description = ta.description;
  639. category = ta.type_of_TA;
  640. inputEdit = $('<input>', {
  641. 'type': 'button',
  642. 'class': 'btn btn-secondary',
  643. 'onclick': 'editTa(this,' + ta.trans_id + ')',
  644. 'id': 'edit_button_for_ta_' + ta.trans_id,
  645. 'value': 'Edit'
  646. }).html('Edit');
  647. inputDelete = $('<input>', {
  648. 'type': 'button',
  649. 'class': 'btn btn-primary',
  650. 'style': 'display: inline',
  651. 'onclick': 'deleteTAFromOutcome(this,' + ta
  652. .trans_id + ')',
  653. 'value': 'Delete'
  654. }).html('Delete');
  655. div = $('<div>');
  656. div.append(inputEdit);
  657. div.append(inputDelete);
  658. trans_table.row.add([
  659. title,
  660. description,
  661. category,
  662. div.html()
  663. ])
  664. })
  665. }
  666. } else {
  667. $('table').hide();
  668. }
  669. trans_table.draw();
  670. //transformative actions in outcome
  671. },
  672. 'json'
  673. );
  674. }
  675. GlobalTransCategories = '';
  676. function editTa(input, trans_id) {
  677. $('#close_button').click()
  678. addTransToPlan();
  679. tableRow = $(input).parent().parent();
  680. title = tableRow.children().eq(0).html();
  681. description = tableRow.children().eq(1).html();
  682. type_of_TA = tableRow.children().eq(2).html();
  683. $('#at_text').val(title);
  684. $('#type_of_ta').val(type_of_TA);
  685. $('#type_of_ta').selectpicker('refresh');
  686. $('#description').val(description);
  687. $('#saveTrans').attr('onclick', 'saveTransToOutcome(' + trans_id + ')');
  688. }
  689. function addTransToPlan() {
  690. $('#saveTrans').attr('onclick', 'saveTransToOutcome()');
  691. div_for_name = $('<div>', {
  692. 'class': 'form-group',
  693. });
  694. input_name = $('<input>', {
  695. 'class': 'form-control',
  696. 'name': 'at_text',
  697. 'id': 'at_text'
  698. });
  699. div_for_name.html("<label> Name</label>");
  700. div_for_name.append(input_name);
  701. $('#new_transformative_actions_to_outcome').append(div_for_name);
  702. div_for_category = $('<div>', {
  703. 'class': 'form-group'
  704. }).html('<label>Type of Transformative Action</label>');
  705. select_for_category = $('<select>', {
  706. 'name': 'type_of_ta',
  707. 'id': 'type_of_ta',
  708. 'class': 'form-control selectpicker',
  709. 'onchange': 'checkIfNew(this)'
  710. }).html(GlobalTransCategories);
  711. div_for_category.append(select_for_category);
  712. $('#new_transformative_actions_to_outcome').append(div_for_category);
  713. select_for_category.selectpicker('refresh');
  714. div_description = $('<div>', {
  715. 'class': 'form-group',
  716. }).html('<label> Description</label>');
  717. textarea = $('<textarea>', {
  718. 'class': 'form-control',
  719. 'id': 'description',
  720. 'name': 'description',
  721. 'rows': '10'
  722. });
  723. div_description.append(textarea);
  724. closeButton = $('<button/>', {
  725. 'class': 'btn btn-secondary',
  726. 'type': "button",
  727. 'id': 'close_button',
  728. 'style': 'float: right',
  729. 'onclick': '$(".editting_action").show(); $(".button-add-transformative").show(); $("#new_transformative_actions_to_outcome").html(" ")'
  730. }).html('Close');
  731. saveButton = $('<button/>', {
  732. 'class': 'btn btn-primary',
  733. 'id': 'saveTrans',
  734. 'type': 'button',
  735. 'style': 'float:right; display:inline-block;',
  736. 'onclick': "saveTransToOutcome()"
  737. }).html('Save');
  738. $('#new_transformative_actions_to_outcome').append(div_description);
  739. $('#new_transformative_actions_to_outcome').append(closeButton);
  740. $('#new_transformative_actions_to_outcome').append(saveButton)
  741. $('#new_transformative_actions_to_outcome').append("<br>")
  742. $('.button-add-transformative').hide();
  743. }
  744. function saveTransToOutcome(edit = null) {
  745. is_new = false;
  746. is_custom = 0;
  747. if ($('.new_type').length !== 0) {
  748. category = $('#new_type').val();
  749. is_custom = 1;
  750. is_new = true;
  751. } else {
  752. is_custom = parseInt($('#type_of_ta').find('option:selected').data('is-custom'));
  753. category = $('#type_of_ta').val();
  754. }
  755. name = $('#at_text').val();
  756. textarea = $('#description').val();
  757. $typ_semester_outcome_id = $('#typ_semester_outcome_id').val();
  758. $.post(
  759. "{{ URL::action('TransformativeActionsController@createTAForOutcome') }}", {
  760. edit: edit,
  761. is_custom: is_custom,
  762. category: category,
  763. name: name,
  764. description: textarea,
  765. is_new: is_new,
  766. program_id: {{ $program->id }},
  767. typ_semester_outcome_id: $typ_semester_outcome_id
  768. },
  769. function(transformative_action_id) {
  770. newTitle = $('#at_text').val();
  771. new_description = $('#description').val();
  772. new_category = $('#type_of_ta').val();
  773. $('#close_button').click();
  774. if ($('#edit_button_for_ta_' + transformative_action_id).length === 0) {
  775. inputEdit = $('<input>', {
  776. 'type': 'button',
  777. 'class': 'btn btn-secondary',
  778. 'onclick': 'editTa(this,' + transformative_action_id + ')',
  779. 'id': 'edit_button_for_ta_' + transformative_action_id,
  780. 'value': 'Edit'
  781. });
  782. inputDelete = $('<input>', {
  783. 'type': 'button',
  784. 'class': 'btn btn-primary',
  785. 'style': 'display: inline',
  786. 'onclick': 'deleteTAFromOutcome(this,' + transformative_action_id +
  787. ')',
  788. 'value': 'Delete'
  789. })
  790. div = $('<div>');
  791. div.append(inputEdit);
  792. div.append(inputDelete);
  793. trans_table = $('#transformative_action_table').DataTable();
  794. trans_table.row.add([
  795. newTitle,
  796. new_description,
  797. category,
  798. div.html()
  799. ]).draw();
  800. } else {
  801. tableRow = $('#edit_button_for_ta_' + transformative_action_id).parent()
  802. .parent();
  803. tableRow.children().eq(0).html(newTitle);
  804. tableRow.children().eq(1).html(new_description);
  805. tableRow.children().eq(2).html(category);
  806. }
  807. }
  808. );
  809. }
  810. function deleteTAFromOutcome(delete_button, trans_id) {
  811. $.post(" {{ URL::action('TransformativeActionsController@deleteTaFromOutcome') }}", {
  812. trans_id: trans_id
  813. },
  814. function() {
  815. $('#edit_button_for_ta_' + trans_id).parent().parent().remove();
  816. }
  817. )
  818. }
  819. function checkIfNew(select) {
  820. if ($(select).val() == "new") {
  821. var new_div = $('<div/>', {
  822. 'class': 'form-group new_type'
  823. }).html("<label>New Type </label>");
  824. var input = $("<input/>", {
  825. 'type': 'text',
  826. 'id': 'new_type',
  827. 'name': "new_type",
  828. 'class': 'form-control'
  829. });
  830. new_div.append(input);
  831. $(select).parent().parent().after(new_div)
  832. } else {
  833. $(select).parent().parent().next('.new_type').remove();
  834. }
  835. }
  836. function posttoTransAnnual(annual_id, selectTransId, typ_course_id) {
  837. ta = $("#" + selectTransId).val();
  838. old_ta = $("#" + selectTransId).data('old-TA');
  839. if (ta == "0") return;
  840. $.post("../annual-plan-postTA", {
  841. annual_id: annual_id,
  842. TA_id: ta,
  843. typ_course_id: typ_course_id,
  844. old_ta: old_ta
  845. },
  846. function(message) {
  847. $("#" + selectTransId).data('old-TA', ta);
  848. }
  849. )
  850. }
  851. function addTAselect(options, master_div, annual_plan_id, objective_id, typ_course_id,
  852. selected_ta) {
  853. var $div = $('<div/>', {
  854. 'class': 'form-group '
  855. });
  856. counter = parseInt($('#' + master_div).data('amount-ta'));
  857. var selectTA = $('<select/>', {
  858. 'class': "selectpicker form-control",
  859. 'data-live-search': 'true',
  860. 'data-old-TA': '0',
  861. 'data-width': '180px',
  862. 'id': 'transformativeForObjective' + master_div + '_' + counter,
  863. 'onchange': 'posttoTransAnnual(' + annual_plan_id +
  864. ', "transformativeForObjective' +
  865. master_div +
  866. '_' + counter + '", ' + typ_course_id + ')'
  867. });
  868. selectTA.append(options);
  869. selectTA.appendTo($div);
  870. selectTA.val(selected_ta);
  871. selectTA.data('old-TA', selected_ta);
  872. selectTA.selectpicker('refresh');
  873. $span = $('<span/>', {
  874. 'id': 'close',
  875. 'onclick': ' postDeleteTA(' + annual_plan_id + ', "transformativeForObjective' +
  876. master_div +
  877. '_' +
  878. counter + '", ' + typ_course_id +
  879. '); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  880. }).html('x');
  881. $span.appendTo($div);
  882. $div.append("<br><br>");
  883. $('#' + master_div).append("<br>");
  884. $div.appendTo($('#' + master_div));
  885. $('#' + master_div).data('amount-ta', counter + 1);
  886. }
  887. function postDeleteTA(annual_id, selectTransId, typ_course_id) {
  888. ta = $("#" + selectTransId).val();
  889. if (ta == "0") return;
  890. $.post("../annual-plan-deleteTA", {
  891. annual_id: annual_id,
  892. TA_id: ta,
  893. typ_id: typ_course_id,
  894. });
  895. parent = $("#" + selectTransId).parent().parent().parent();
  896. counter = parseInt(parent.data('amount-ta'));
  897. parent.data('amount-ta', counter - 1);
  898. }
  899. function postToAnnualPlans(typ_course_id, criteria_select) {
  900. var criteria = $('#' + criteria_select).val();
  901. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  902. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  903. var annual = criteriaNode.dataset.annualPlan;
  904. $.post("../annual-plan-postOnChange", {
  905. criteria: criteria,
  906. typ_course_id: typ_course_id,
  907. annual_plan: annual,
  908. old_criteria: oldCriteria
  909. },
  910. function(message) {
  911. if (message == "Duplicate entry, please choose another criteria.") {
  912. alert(message)
  913. } else {
  914. $('#' + criteria_select).data('old-criteria', criteria);
  915. changed = true;
  916. }
  917. })
  918. }
  919. function addCriteriaTest(div, new_id_for_select, typ_course_id, i = null, options) {
  920. if (!i) amount_select = $('#' + div).data("amount-select");
  921. else amount_select = i;
  922. $select = $('<select/>', {
  923. 'class': "selectpicker form-control",
  924. 'data-live-search': 'true',
  925. 'data-old-criteria': '0',
  926. 'data-width': '180px',
  927. 'id': 'criteriaFor' + new_id_for_select + '_' + amount_select,
  928. 'onchange': 'postToAnnualPlans(' + typ_course_id + ', "criteriaFor' +
  929. new_id_for_select + '_' +
  930. amount_select + '")'
  931. })
  932. var $div = $('<div/>', {
  933. 'id': 'courseSelect_' + new_id_for_select + '_' + amount_select,
  934. 'class': 'form-group '
  935. });
  936. $select.append(options);
  937. $select.appendTo($div);
  938. $span = $('<span/>', {
  939. 'id': 'close',
  940. 'onclick': ' postDelete(' + typ_course_id + ', "criteriaFor' + new_id_for_select +
  941. '_' +
  942. amount_select +
  943. '"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  944. }).html('x');
  945. $div.append($span);
  946. $div.append("<br><br>")
  947. $('#' + div).append("<br>");
  948. $div.appendTo($("#" + div));
  949. $select.selectpicker('refresh');
  950. $("#" + div).data("amount-select", amount_select + 1);
  951. }
  952. $('#allOutcomes').hide();
  953. function postDelete(typ_course_id, criteria_select) {
  954. var criteria = $('#' + criteria_select).val();
  955. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  956. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  957. var annual = criteriaNode.dataset.annualPlan;
  958. $.post("../annual-plan-deleteCriteria", {
  959. criteria: criteria,
  960. typ_course_id: typ_course_id,
  961. annual_plan: annual,
  962. old_criteria: oldCriteria
  963. });
  964. }
  965. function fetchInfo(id) {
  966. annual_id = $("#" + id).val();
  967. program_id = {{ $program->id }};
  968. $.post("{{ URL::action('AnnualPlansController@fetchInfo') }}", {
  969. id: annual_id,
  970. program_id: program_id
  971. },
  972. function(json) {
  973. div = $('<div/>', {
  974. 'class': 'list-group',
  975. 'id': 'list'
  976. });
  977. var onclick = "";
  978. //TODO CHange this
  979. if (json.annual_plans.is_submitted != 2)
  980. onclick = "fetchEverything(this)";
  981. else onclick = "fetchEverything(this)";
  982. if (json.outcomes.first) {
  983. header5 = $('<h5/>', {
  984. 'style': "padding-left: 10px"
  985. }).html("First Semester");
  986. div.append(header5);
  987. list = '';
  988. for (outcome in json.outcomes.first) {
  989. list +=
  990. "<li style='padding-left: 25px' onclick = '" + onclick +
  991. "' data-annual-plan = '" +
  992. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json
  993. .outcomes.first[
  994. outcome].typ_semester_outcome_id + "' data-semester-id = '" + json
  995. .allSemesterOrder
  996. .first.id +
  997. "' data-outcome-id='" + json.outcomes.first[outcome].id +
  998. "' data-outcome-name ='" +
  999. json
  1000. .outcomes.first[outcome].name + "' class='list-group-item' >" + json
  1001. .outcomes.first[
  1002. outcome]
  1003. .name + " </li>";
  1004. }
  1005. div.append(list);
  1006. }
  1007. if (json.outcomes.second) {
  1008. header4 = $('<h5/>', {
  1009. 'style': "padding-left: 10px"
  1010. }).html("Second Semester");
  1011. div.append(header4);
  1012. list = '';
  1013. for (outcome in json.outcomes.second) {
  1014. list +=
  1015. "<li style='padding-left: 25px' onclick = '" + onclick +
  1016. "' data-annual-plan = '" +
  1017. json.annual_plans.id + "' data-typ-semester-outcome-id ='" + json
  1018. .outcomes.second[
  1019. outcome].typ_semester_outcome_id + "'data-semester-id = '" + json
  1020. .allSemesterOrder
  1021. .second.id +
  1022. "' data-outcome-id='" + json.outcomes.second[outcome].id +
  1023. "' data-outcome-name ='" +
  1024. json
  1025. .outcomes.second[outcome].name + "' class='list-group-item' >" + json
  1026. .outcomes
  1027. .second[
  1028. outcome].name + " </li>";
  1029. }
  1030. div.append(list);
  1031. }
  1032. html = div[0].innerHTML;
  1033. $("#allOutcomes").html(div[0].innerHTML);
  1034. $("#allOutcomes").show();
  1035. // Create button to print report
  1036. div_btn_group = $('<div>', {
  1037. 'class': 'btn-group-vertical',
  1038. 'role': 'group'
  1039. });
  1040. button_save = $('<button>', {
  1041. 'class': 'btn btn-lg btn-primary btn-block',
  1042. 'type': 'button',
  1043. 'onclick': 'check_if_ready(' + annual_id + ')'
  1044. }).html('Submit Annual Plan');
  1045. button_print = $("<button>", {
  1046. "class": 'btn btn-lg btn-primary btn-block',
  1047. "type": "button",
  1048. "onclick": "window.location.href = " +
  1049. "'{{ URL::action('AnnualPlansController@printAnnualPlan') }}" +
  1050. "/" +
  1051. annual_id + "'",
  1052. }).html("Print Plan");
  1053. div_btn_group.append(button_print);
  1054. div_btn_group.append(button_save);
  1055. $('#printButton').html(div_btn_group);
  1056. },
  1057. "json",
  1058. );
  1059. }
  1060. function deleteObjective(objectiveSelectDiv, closeObj) {
  1061. $('#' + objectiveSelectDiv).remove();
  1062. $('#' + closeObj).remove();
  1063. $('#' + div).data("amount-select", $('#' + div).data("amount-select") - 1);
  1064. }
  1065. function check_if_ready(annual_id) {
  1066. $.post(
  1067. "{{ URL::action('AnnualPlansController@checkIfPlanReady') }}", {
  1068. annual_id: annual_id
  1069. },
  1070. function(courses_with_missing_data) {
  1071. if (courses_with_missing_data.length > 0) {
  1072. //id="submit-modal">
  1073. //This means there is still data to be filled before submit.
  1074. $('#submit-modal-title').html("There is still some data to be filled. ")
  1075. //close button <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  1076. button = $('<button>', {
  1077. 'class': 'btn btn-secondary',
  1078. 'type': 'button',
  1079. 'data-dismiss': 'modal'
  1080. }).html('Close');
  1081. $('#submit-modal-footer').html(button);
  1082. div_for_courses = $("<div>", {
  1083. 'id': 'courses_criteria',
  1084. }).html("<h4>These are the Courses that need at least one Criteria paired</h4>")
  1085. ol_course_ta = $("<ol>", {
  1086. 'id': 'course_criteria',
  1087. 'type': 'I'
  1088. });
  1089. div_for_courses.append(ol_course_ta);
  1090. //"<ol id='course_ta' type='I'>");
  1091. //div_for_outcomes
  1092. $('#submit-modal-body').html(div_for_courses)
  1093. $.each(courses_with_missing_data, function(index, info) {
  1094. selector = $('#course_typ_outcome_' + info.typ_semester_outcome_id);
  1095. if (selector.length === 0) {
  1096. li_outcome = $('<li>').html(info.outcome_name);
  1097. ol = $("<ol>", {
  1098. 'id': 'course_typ_outcome_' + info
  1099. .typ_semester_outcome_id,
  1100. 'type': 'A'
  1101. });
  1102. li_outcome.append(ol);
  1103. $("#course_criteria").append(li_outcome);
  1104. //selector = $('<div>').html(info.outcome.typ_semester_outcome_id);
  1105. //selector.append('<ol type = "A">');
  1106. //objective_li = $("<li>");
  1107. //objective_id = $("<div>",{
  1108. // 'class':'typ-objective-'+info.objective.typ_semester_objective_id,
  1109. //}).html();
  1110. //li.append(selector);
  1111. }
  1112. selector = $("#course_typ_objective_" + info.typ_semester_objective_id)
  1113. if (selector.length === 0) {
  1114. li_objective = $("<li>").html(info.objective_text);
  1115. ol_objective = $("<ol>", {
  1116. 'id': 'course_typ_objective_' + info.typ_semester_objective_id,
  1117. 'type': '1'
  1118. });
  1119. li_objective.append(ol_objective);
  1120. $('#course_typ_outcome_' + info.typ_semester_outcome_id).append(
  1121. li_objective);
  1122. }
  1123. selector = $("#course_ul_" + info.typ_semester_course_id)
  1124. if (selector.length === 0) {
  1125. li_course = $("<li>").html(info.course_code);
  1126. ol_course = $("<ul>", {
  1127. 'id': "course_ul_" + info.typ_semester_course_id,
  1128. });
  1129. li_course.append(ol_course);
  1130. $('#course_typ_objective_' + info.typ_semester_objective_id)
  1131. .append(li_course);
  1132. }
  1133. });
  1134. //$('#submit-modal-body').append("</ol>")
  1135. //$('#submit-modal-footer').html(button);
  1136. } else {
  1137. button = $('<button>', {
  1138. 'class': 'btn btn-secondary',
  1139. 'type': 'button',
  1140. 'data-dismiss': 'modal'
  1141. }).html('Close');
  1142. button_for_save = $("<button>", {
  1143. 'class': 'btn btn-primary',
  1144. 'type': 'button',
  1145. 'onclick': "postAnnualPlan(" + annual_id + ")"
  1146. }).html("Submit Annual Plan");
  1147. $("#submit-modal-title").html("Are you sure you want to submit this report?");
  1148. $("#submit-modal-body")
  1149. .html(
  1150. "You can submit again later, but may need to give explination to administration on why was it resubmitted." +
  1151. "When submitting, please be patient. It may take a while. "
  1152. );
  1153. $('#submit-modal-footer').html(button);
  1154. $("#submit-modal-footer").append(button_for_save);
  1155. }
  1156. $("#submit-modal").modal('toggle');
  1157. }
  1158. )
  1159. }
  1160. function postAnnualPlan(annual_id) {
  1161. $.post(
  1162. "{{ URL::action('AnnualPlansController@submitAnnualPlan') }}/" + annual_id, {},
  1163. function(message) {
  1164. if (message = '200') {
  1165. $("#submit-modal").modal('toggle');
  1166. alert = $('<div/>', {
  1167. 'class': 'alert alert-success alert-dismissible',
  1168. 'role': 'alert'
  1169. })
  1170. button = $('<button/>', {
  1171. 'type': 'button',
  1172. 'class': 'close',
  1173. 'data-dismiss': 'alert',
  1174. 'alert-label': 'close'
  1175. }).html('<span aria-hidden="true">×</span>');
  1176. alert.append(button);
  1177. alert.append(
  1178. '<strong>The Annual Plan was submitted. You can check it out in View Annual Plans or Print Plan </strong>'
  1179. )
  1180. alert.appendTo($("#alert-for-save"));
  1181. }
  1182. });
  1183. }
  1184. </script>
  1185. @stop
  1186. @section('included-js')
  1187. @include('global._datatables_js')
  1188. @stop