No Description

annual-plans.blade.php 64KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  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. {{-- <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('Activities Assessment and Program 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('Activities Assessment and Program 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. //open new window to save html
  1182. window.open("{{URL::action('AnnualPlansController@printAnnualPlan')}}/"+annual_id+'/1', "_blank");
  1183. }
  1184. });
  1185. }
  1186. </script>
  1187. @stop
  1188. @section('included-js')
  1189. @include('global._datatables_js')
  1190. @stop