Ingen beskrivning

annual-plans.blade.php 68KB

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