Ei kuvausta

annual-plans.blade.php 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. @extends('layouts.master-2')
  2. @section('navigation')
  3. @if (Auth::user()->role == 1)
  4. @include('local.managers.admins._navigation')
  5. @elseif(Auth::user()->role == 2)
  6. @include('local.managers.sCoords._navigation')
  7. @elseif(Auth::user()->role == 3)
  8. @include('local.managers.pCoords._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. </div>
  32. <div class="col-md-9">
  33. <div id="expected-outcome" class="panel panel-default" data-semester-id="">
  34. <div class="panel-heading">
  35. <h3 class="panel-title">
  36. Expected Target Outcomes
  37. </h3>
  38. <input style="width: 150px;" min="0" class="form-control" type="number">
  39. </div>
  40. </div>
  41. <div id="outcome-display" class="panel panel-default">
  42. <div class="panel-heading">
  43. <h4 class=" panel-title">
  44. Primer Semestre 2019-2020
  45. </h4>
  46. </div>
  47. <div class="panel-body">
  48. <p class="outcome-definition "></p>
  49. <div class="table-responsive">
  50. <table class="table table-striped table-condensed datatable"
  51. style="table-layout: fixed ; width : 100%">
  52. <thead>
  53. <tr>
  54. <th>Objectives for courses</th>
  55. <th>Criteria per Course</th>
  56. <th>Transformative Actions to be Implemented</th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. </tbody>
  61. </table>
  62. </div>
  63. <hr>
  64. <div id='transformative_actions_to_outcome'>
  65. </div>
  66. <hr>
  67. <button class='btn btn-md btn-secondary button-add-objective'
  68. onclick='addTransToPlan()'>
  69. <span class='glyphicon glyphicon-plus'>
  70. </span>
  71. Add another Transformative Action
  72. </button>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="col-md-9">
  77. <div class="no-outcome alert alert-info">
  78. <p>Select a Learning Outcome to view its information</p>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="modal fade" id="modal-view-objective">
  83. <div class="modal-dialog modal-lg">
  84. <div class="modal-content">
  85. <div class="modal-header">
  86. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  87. <h3 class="modal-title"></h3>
  88. </div>
  89. <div class="modal-body">
  90. </div>
  91. </div><!-- /.modal-content -->
  92. </div><!-- /.modal-dialog -->
  93. </div><!-- /.modal -->
  94. <script>
  95. function nextChar(c) {
  96. return String.fromCharCode(c.charCodeAt(0) + 1);
  97. }
  98. changed = false;
  99. $(document).ready(function() {
  100. // --------------------------------------------------------------------------
  101. // Page load
  102. // --------------------------------------------------------------------------
  103. // Hide accordion panel contents by default
  104. // $('.panel-group .panel-body').hide();
  105. $('.panel-group .panel-body').hide();
  106. $('#outcome-display').parent().hide();
  107. // --------------------------------------------------------------------------
  108. // Functions
  109. // --------------------------------------------------------------------------
  110. // --------------------------------------------------------------------------
  111. // Events
  112. // --------------------------------------------------------------------------
  113. // When list item is clicked, load corresponding info
  114. });
  115. // function CreateOrEdit(id){
  116. // //send data to the database
  117. // console.log(id);
  118. // annual_id = $("#"+id);
  119. // console.log(console.log(annual_id));
  120. // }
  121. function fetchObjectiveInfo(objective_div){
  122. typ_objective_id = $(objective_div).data('typ-objective-id');
  123. objective = $(objective_div).html();
  124. $.ajax({
  125. type: 'POST',
  126. url: "{{ URL::action('AnnualPlansController@fetchObjectiveInfo') }}",
  127. data: {
  128. typ_objective_id: typ_objective_id
  129. },
  130. success: function(courses)
  131. {
  132. $('.modal-title').html(objective);
  133. descriptions = '';
  134. $('.modal-body').empty();
  135. $.each(courses, function(index, course){
  136. $('.modal-body').append('<h4>'+course.code+' '+course.number+': '+course.name+'</h4>')
  137. $('.modal-body').append('<br><p>The following course is tied to these criteria: </p>')
  138. $.each(course.criteria, function(index,criterion){
  139. criterion_html = '<h5 style ="text-indent: 15px;">'+(index+1)+'. '+criterion.name+'</h5>';
  140. table = $('<table>', {
  141. 'style':'margin-left:15px',
  142. //'id':'criteria-'+criterion.id,
  143. 'class':"table table-striped table-condensed table-bordered"
  144. });
  145. thead = $('<thead/>');
  146. tr = $('<tr/>');
  147. for(i=0; i<criterion.num_scales;i++){
  148. minimumScore = 1+(i*(criterion.max_score/criterion.num_scales));
  149. maximumScore = (1+i)*(criterion.max_score/criterion.num_scales);
  150. th = '<th>Scale '+(i+1)+'. ('+minimumScore+' - '+maximumScore+')</th>';
  151. tr.append(th);
  152. }
  153. thead.append(tr);
  154. table.append(thead);
  155. tbody = $('<tbody>')
  156. tr_for_body = $('<tr>', {
  157. 'id':'criterion_'+criterion.id
  158. })
  159. td_for_criteria = '';
  160. $.each(criterion.scales, function(index, scale){
  161. td_for_criteria += '<td>'+scale.description+'</td>';
  162. });
  163. tr_for_body.html(td_for_criteria);
  164. tbody.append(tr_for_body);
  165. table.append(tbody);
  166. $('.modal-body').append(criterion_html);
  167. $('.modal-body').append(table);
  168. })
  169. $('.modal-body').append('<hr>')
  170. });
  171. $('#modal-view-objective').modal();
  172. },
  173. async:true
  174. });
  175. }
  176. function fetchEverything(li) {
  177. var id = $(li).data('outcome-id');
  178. var name = $(li).data('outcome-name');
  179. var semester = $(li).data('semester-id');
  180. var annual_plan = $(li).data('annual-plan');
  181. var typ_semester_outcome_id = $(li).data('typ-semester-outcome-id');
  182. $('#expected-outcome').data('semester-id', semester);
  183. $('#theChange').data('annual-plan', annual_plan);
  184. $.post(
  185. "../annual-plan-fetchTYP/{{ $program->id }}", {
  186. id: id,
  187. semester: semester,
  188. typ_semester_outcome_id: typ_semester_outcome_id,
  189. },
  190. function(json) {
  191. var table = $('.datatable').DataTable();
  192. table.clear();
  193. var optionsForTADict = {};
  194. var objectives = json.objectives;
  195. var courses = json.courses;
  196. var criteria = json.criteria;
  197. var selected_criteria = json.selected_criteria;
  198. var nextLetter = "A";
  199. if (courses) {
  200. $('table').show();
  201. $('#outcome-display').parent().show();
  202. $('.no-outcome').parent().hide();
  203. //Display title and definition
  204. $('#outcome-display .panel-title').html(name);
  205. var expected_target = json.expected_target;
  206. //check the data type of the expected target
  207. //if the expected_target var is an empty array, set default value
  208. $('#expected-outcome .form-control').val(expected_target.expected_target);
  209. //Empty table
  210. table.clear();
  211. var annual_plan = json.annual_plan.id;
  212. for (objective in objectives) {
  213. var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  214. var objectivesHTML = '<div class="criterion-field" data-typ-objective-id = "'+typ_objective_id+'" onclick = "fetchObjectiveInfo(this)">';
  215. var courseshtml = '';
  216. var courseTAhtml = '';
  217. var criteriaHTML = '';
  218. objectivesHTML += '<strong>' + nextLetter + '. ' + objectives[objective].text +
  219. '</strong></div>';
  220. // courseshtml += "<strong>Objective "+nextLetter+"</strong>";
  221. // courseshtml += '<ul>';
  222. criteriaHTML += "<strong>Objective " + nextLetter + "</strong>";
  223. //criteriaHTML+= '<ol>';
  224. //var typ_objective_id = json.typ_objective_id[objectives[objective].id].id;
  225. nextLetter = nextChar(nextLetter);
  226. for (course in courses[objectives[objective].id]) {
  227. courseshtml += ' &#8226; ' + courses[objectives[objective].id][course].code + ' ' +
  228. courses[objectives[objective].id][course].name + '<br>'
  229. courseTAhtml += ' &#8226; ' + courses[objectives[objective].id][course].code + ' ' +
  230. courses[objectives[objective].id][course].name + '<br>'
  231. $divForEach = $('<div/>', {
  232. 'id': 'objective-' + objectives[objective].id
  233. });
  234. $divForSelects = $('<div/>', {
  235. 'id': 'forObjective-' + objectives[objective].id + '-course-' + courses[
  236. objectives[objective].id][course].typ_course_id,
  237. 'data-amount-select': '0',
  238. 'class': 'form-group',
  239. 'data-annual-plan': json.annual_plan.id
  240. });
  241. options = "<option value = '0' >Nothing Selected</option>"
  242. for (criterion in criteria[objectives[objective].id]) {
  243. options += "<option value='" + criteria[objectives[objective].id][criterion].id +
  244. "'>" + criteria[objectives[objective].id][criterion].name + "</option>";
  245. }
  246. var $button = $('<button/>', {
  247. 'type': 'button',
  248. 'class': 'btn btn-secondary',
  249. 'onclick': 'addCriteriaTest("forObjective-' + objectives[objective].id +
  250. "-course-" + courses[objectives[objective].id][course].typ_course_id +
  251. '", "' + objectives[objective].id + "-course-" + courses[objectives[
  252. objective].id][course].typ_course_id + '", ' + courses[objectives[
  253. objective].id][course].typ_course_id + ', null, "' + options + '")'
  254. });
  255. $button.append("+ Add criteria");
  256. $divForEach.append($divForSelects);
  257. $divForEach.append("<br>")
  258. $divForEach.append($button);
  259. $divForTA = $('<div/>', {
  260. 'id': 'objectiveTA-' + objectives[objective].id
  261. });
  262. $divForTASelects = $('<div/>', {
  263. 'id': 'forTA-objective-' + objectives[objective].id + '-course-' + courses[
  264. objectives[objective].id][course].typ_course_id,
  265. 'class': 'form-group',
  266. 'data-amount-ta': '0'
  267. });
  268. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  269. transformativeDefault = json.transformative_actions;
  270. optionsForTa += "<optgroup label='Default'>";
  271. for (trans in transformativeDefault) {
  272. optionsForTa += "<option value='" + transformativeDefault[trans].id + "'>" +
  273. transformativeDefault[trans].at_text + "</option> ";
  274. }
  275. optionsForTa += '</optgroup>';
  276. course_id = courses[objectives[objective].id][course].id
  277. transformativeDefault = json.custom_transformative[objectives[objective].id][course_id];
  278. if (transformativeDefault != undefined) {
  279. optionsForTa += "<optgroup label = 'Custom'>";
  280. for (trans in transformativeDefault) {
  281. optionsForTa += "<option value='" + transformativeDefault[trans].ta_id + "'>" +
  282. transformativeDefault[trans].at_text + "</option> ";
  283. }
  284. }
  285. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  286. var $buttonTA = $('<button/>', {
  287. 'type': 'button',
  288. 'class': 'btn btn-secondary',
  289. 'onclick': 'addTAselect("' + optionsForTa + '", "forTA-objective-' +
  290. objectives[objective].id + '-course-' + courses[objectives[objective]
  291. .id][course].typ_course_id + '", ' + annual_plan + ', ' +
  292. objectives[objective].id + ', ' + typ_course_id + ', 0)'
  293. });
  294. $buttonTA.append("+ Add TA");
  295. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  296. optionsForTADict[typ_course_id] = optionsForTa;
  297. $divForTA.append($divForTASelects);
  298. $divForTA.append('<br>');
  299. $divForTA.append($buttonTA)
  300. courseshtml += $divForEach[0].innerHTML + "<br><br>";
  301. courseTAhtml += $divForTA[0].innerHTML + "<br><br>";
  302. }
  303. /*$divForTA = $('<div/>',{
  304. 'id':'objectiveTA-'+objectives[objective].id
  305. });
  306. $divForTASelects = $('<div/>', {
  307. 'id': 'forTA-objective-'+objectives[objective].id,
  308. 'class':'form-group',
  309. 'data-amount-ta':'0'
  310. });
  311. var optionsForTa = "<option value = '0'>Nothing Selected</option>";
  312. transformativeDefault = json.transformative_actions;
  313. optionsForTa+= "<optgroup label='Default'>";
  314. for(trans in transformativeDefault){
  315. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  316. }
  317. optionsForTa+='</optgroup>';
  318. transformativeDefault = json.custom_transformative[objectives[objective].id];
  319. if(transformativeDefault!= undefined){
  320. optionsForTa+="<optgroup label = 'Custom'>";
  321. for(trans in transformativeDefault){
  322. optionsForTa+= "<option value='"+transformativeDefault[trans].id+"'>"+transformativeDefault[trans].at_text+"</option> ";
  323. }
  324. }
  325. var $buttonTA = $('<button/>', {
  326. 'type': 'button',
  327. 'class': 'btn btn-secondary',
  328. 'onclick': 'addTAselect("'+optionsForTa+'", "forTA-objective-'+objectives[objective].id+'", '+annual_plan+', '+objectives[objective].id+', '+typ_objective_id+', 0)'
  329. });
  330. $buttonTA.append("+ Add TA");
  331. $divForTA.append($divForTASelects);
  332. $divForTA.append('<br>');
  333. $divForTA.append($buttonTA)
  334. */
  335. table.row.add([
  336. objectivesHTML,
  337. courseshtml,
  338. courseTAhtml
  339. ]);
  340. table.draw();
  341. for (course in courses[objectives[objective].id]) {
  342. typ_course_id = courses[objectives[objective].id][course].typ_course_id
  343. if (json.annual_plans_transformative[objectives[objective].id][typ_course_id].length) {
  344. for (i = 0; i < json.annual_plans_transformative[objectives[objective].id][
  345. typ_course_id
  346. ].length; i++) {
  347. selected_ta = json.annual_plans_transformative[objectives[objective].id][
  348. typ_course_id
  349. ][i].trans_id;
  350. addTAselect(optionsForTADict[typ_course_id], "forTA-objective-" + objectives[
  351. objective].id + '-course-' + typ_course_id, annual_plan, objectives[
  352. objective].id, typ_course_id, selected_ta);
  353. }
  354. } else {
  355. $('#')
  356. addTAselect(optionsForTADict[typ_course_id], "forTA-objective-" + objectives[
  357. objective].id + '-course-' + typ_course_id, annual_plan, objectives[
  358. objective].id, typ_course_id, 0);
  359. }
  360. if (json.selected_criteria[objectives[objective].id][typ_course_id].length) {
  361. for (i = 0; i < json.selected_criteria[objectives[objective].id][typ_course_id]
  362. .length; i++) {
  363. addCriteriaTest("forObjective-" + objectives[objective].id + "-course-" +
  364. typ_course_id, "" + objectives[objective].id + "-course-" +
  365. typ_course_id, "" + json.selected_criteria[objectives[objective].id][
  366. typ_course_id
  367. ][i].typ_course_id + "", i, options);
  368. $('#criteriaFor' + objectives[objective].id + "-course-" + typ_course_id + '_' +
  369. i).val(json.selected_criteria[objectives[objective].id][typ_course_id][
  370. i
  371. ].criteria_id);
  372. $('#criteriaFor' + objectives[objective].id + "-course-" + typ_course_id + '_' +
  373. i).data('old-criteria', json.selected_criteria[objectives[objective].id]
  374. [typ_course_id][i].criteria_id);
  375. $('#criteriaFor' + objectives[objective].id + "-course-" + typ_course_id + '_' +
  376. i).selectpicker('refresh');
  377. } // Update display
  378. } else {
  379. addCriteriaTest("forObjective-" + objectives[objective].id + "-course-" +
  380. typ_course_id, "" + objectives[objective].id + "-course-" + typ_course_id +
  381. "", "" + typ_course_id + "", 0, options);
  382. $('#criteriaFor' + objectives[objective].id + "-course-" + typ_course_id + '_0')
  383. .val(0);
  384. $('#criteriaFor' + objectives[objective].id + "-course-" + typ_course_id + '_0')
  385. .data('old-criteria', 0);
  386. $('#criteriaFor' + objectives[objective].id + "-course-" + typ_course_id + '_0')
  387. .selectpicker('refresh');
  388. }
  389. }
  390. }
  391. table.draw();
  392. //transformative actions in outcome
  393. } else {
  394. $('table').hide();
  395. }
  396. //transformative actions in outcome
  397. if(!json.transformative_actions_for_outcome.length){
  398. div_for_name = $('<div>',{
  399. 'class':'form-group',
  400. });
  401. input_name = $('<input>', {
  402. 'class':'form-control',
  403. 'name':'at_text[]'
  404. });
  405. div_for_name.html("<label> Name</label>");
  406. div_for_name.append(input_name);
  407. $('#transformative_actions_to_outcome').append(div_for_name);
  408. div_for_category=$('<div>',{
  409. 'class':'form-group'
  410. }).html('<label>Type of Transformative Action</label>');
  411. select_for_category = $('<select>',{
  412. 'name':'type_of_ta[]',
  413. 'class':'form-control selectpicker',
  414. 'onchange':'checkIfNew(this)'
  415. }).html(json.categories);
  416. GlobalTransCategories = json.categories;
  417. div_for_category.append(select_for_category);
  418. $('#transformative_actions_to_outcome').append(div_for_category);
  419. select_for_category.selectpicker('refresh');
  420. div_description = $('<div>',{
  421. 'class':'form-group',
  422. }).html('<label> Description</label>');
  423. textarea = $('<textarea>', {
  424. 'class':'form-control',
  425. 'name':'description[]',
  426. 'rows':'10'
  427. });
  428. div_description.append(textarea);
  429. $('#transformative_actions_to_outcome').append(div_description);
  430. }
  431. },
  432. 'json'
  433. );
  434. }
  435. GlobalTransCategories = '';
  436. function addTransToPlan(){
  437. div_for_name = $('<div>',{
  438. 'class':'form-group',
  439. });
  440. input_name = $('<input>', {
  441. 'class':'form-control',
  442. 'name':'at_text[]'
  443. });
  444. div_for_name.html("<label> Name</label>");
  445. div_for_name.append(input_name);
  446. $('#transformative_actions_to_outcome').append(div_for_name);
  447. div_for_category=$('<div>',{
  448. 'class':'form-group'
  449. }).html('<label>Type of Transformative Action</label>');
  450. select_for_category = $('<select>',{
  451. 'name':'type_of_ta[]',
  452. 'class':'form-control selectpicker',
  453. 'onchange':'checkIfNew(this)'
  454. }).html(GlobalTransCategories);
  455. div_for_category.append(select_for_category);
  456. $('#transformative_actions_to_outcome').append(div_for_category);
  457. select_for_category.selectpicker('refresh');
  458. div_description = $('<div>',{
  459. 'class':'form-group',
  460. }).html('<label> Description</label>');
  461. textarea = $('<textarea>', {
  462. 'class':'form-control',
  463. 'name':'description[]',
  464. 'rows':'10'
  465. });
  466. div_description.append(textarea);
  467. $('#transformative_actions_to_outcome').append(div_description);
  468. }
  469. function checkIfNew(select){
  470. if($(select).val()=="new"){
  471. var new_div = $('<div/>',{
  472. 'class':'form-group new_type'
  473. }).html("<label>New Type </label>");
  474. var input = $("<input/>", {
  475. 'type': 'text',
  476. 'name':"new_type",
  477. 'class':'form-control'
  478. });
  479. new_div.append(input);
  480. $(select).parent().parent().after(new_div)
  481. }
  482. else{
  483. $(select).parent().parent().next('.new_type').remove();
  484. }
  485. }
  486. function posttoTransAnnual(annual_id, selectTransId, typ_course_id) {
  487. ta = $("#" + selectTransId).val();
  488. old_ta = $("#" + selectTransId).data('old-TA');
  489. if (ta == "0") return;
  490. $.post("../annual-plan-postTA", {
  491. annual_id: annual_id,
  492. TA_id: ta,
  493. typ_course_id: typ_course_id,
  494. old_ta: old_ta
  495. },
  496. function(message) {
  497. $("#" + selectTransId).data('old-TA', ta);
  498. }
  499. )
  500. }
  501. function addTAselect(options, master_div, annual_plan_id, objective_id, typ_course_id, selected_ta) {
  502. var $div = $('<div/>', {
  503. 'class': 'form-group '
  504. });
  505. counter = parseInt($('#' + master_div).data('amount-ta'));
  506. var selectTA = $('<select/>', {
  507. 'class': "selectpicker form-control",
  508. 'data-live-search': 'true',
  509. 'data-old-TA': '0',
  510. 'data-width': '180px',
  511. 'id': 'transformativeForObjective' + master_div + '_' + counter,
  512. 'onchange': 'posttoTransAnnual(' + annual_plan_id + ', "transformativeForObjective' + master_div +
  513. '_' + counter + '", ' + typ_course_id + ')'
  514. });
  515. selectTA.append(options);
  516. selectTA.appendTo($div);
  517. selectTA.val(selected_ta);
  518. selectTA.data('old-TA', selected_ta);
  519. selectTA.selectpicker('refresh');
  520. $span = $('<span/>', {
  521. 'id': 'close',
  522. 'onclick': ' postDeleteTA(' + annual_plan_id + ', "transformativeForObjective' + master_div + '_' +
  523. counter + '", ' + typ_course_id +
  524. '); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  525. }).html('x');
  526. $span.appendTo($div);
  527. $div.append("<br><br>");
  528. $('#' + master_div).append("<br>");
  529. $div.appendTo($('#' + master_div));
  530. $('#' + master_div).data('amount-ta', counter + 1);
  531. }
  532. function postDeleteTA(annual_id, selectTransId, typ_course_id) {
  533. ta = $("#" + selectTransId).val();
  534. if (ta == "0") return;
  535. $.post("../annual-plan-deleteTA", {
  536. annual_id: annual_id,
  537. TA_id: ta,
  538. typ_id: typ_course_id,
  539. });
  540. parent = $("#" + selectTransId).parent().parent().parent();
  541. counter = parseInt(parent.data('amount-ta'));
  542. parent.data('amount-ta', counter - 1);
  543. }
  544. function postToAnnualPlans(typ_course_id, criteria_select) {
  545. var criteria = $('#' + criteria_select).val();
  546. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  547. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  548. var annual = criteriaNode.dataset.annualPlan;
  549. $.post("../annual-plan-postOnChange", {
  550. criteria: criteria,
  551. typ_course_id: typ_course_id,
  552. annual_plan: annual,
  553. old_criteria: oldCriteria
  554. },
  555. function(message) {
  556. if (message == "Duplicate entry, please choose another criteria.") {
  557. alert(message)
  558. } else {
  559. $('#' + criteria_select).data('old-criteria', criteria);
  560. changed = true;
  561. }
  562. })
  563. }
  564. function addCriteriaTest(div, new_id_for_select, typ_course_id, i = null, options) {
  565. if (!i) amount_select = $('#' + div).data("amount-select");
  566. else amount_select = i;
  567. $select = $('<select/>', {
  568. 'class': "selectpicker form-control",
  569. 'data-live-search': 'true',
  570. 'data-old-criteria': '0',
  571. 'data-width': '180px',
  572. 'id': 'criteriaFor' + new_id_for_select + '_' + amount_select,
  573. 'onchange': 'postToAnnualPlans(' + typ_course_id + ', "criteriaFor' + new_id_for_select + '_' +
  574. amount_select + '")'
  575. })
  576. var $div = $('<div/>', {
  577. 'id': 'courseSelect_' + new_id_for_select + '_' + amount_select,
  578. 'class': 'form-group '
  579. });
  580. $select.append(options);
  581. $select.appendTo($div);
  582. $span = $('<span/>', {
  583. 'id': 'close',
  584. 'onclick': ' postDelete(' + typ_course_id + ', "criteriaFor' + new_id_for_select + '_' +
  585. amount_select + '"); this.parentNode.parentNode.removeChild(this.parentNode);return false;'
  586. }).html('x');
  587. $div.append($span);
  588. $div.append("<br><br>")
  589. $('#' + div).append("<br>");
  590. $div.appendTo($("#" + div));
  591. $select.selectpicker('refresh');
  592. $("#" + div).data("amount-select", amount_select + 1);
  593. }
  594. $('#allOutcomes').hide();
  595. function postDelete(typ_course_id, criteria_select) {
  596. var criteria = $('#' + criteria_select).val();
  597. var oldCriteria = $('#' + criteria_select).data('old-criteria');
  598. var criteriaNode = document.getElementById(criteria_select).parentNode.parentNode.parentNode;
  599. var annual = criteriaNode.dataset.annualPlan;
  600. $.post("../annual-plan-deleteCriteria", {
  601. criteria: criteria,
  602. typ_course_id: typ_course_id,
  603. annual_plan: annual,
  604. old_criteria: oldCriteria
  605. });
  606. }
  607. function fetchInfo(id) {
  608. annual_id = $("#" + id).val();
  609. program_id = {{ $program->id }};
  610. $.post("{{ URL::action('AnnualPlansController@fetchInfo') }}", {
  611. id: annual_id,
  612. program_id: program_id
  613. },
  614. function(json) {
  615. div = $('<div/>', {
  616. 'class': 'list-group',
  617. 'id': 'list'
  618. });
  619. if(json.outcomes.first){
  620. header5 = $('<h5/>', {
  621. 'style': "padding-left: 10px"
  622. }).html("First Semester");
  623. div.append(header5);
  624. list = '';
  625. for (outcome in json.outcomes.first) {
  626. list +=
  627. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  628. json.annual_plans.id + "' data-typ-semester-outcome-id ='"+json.outcomes.first[outcome].typ_semester_outcome_id+"' data-semester-id = '" + json.allSemesterOrder.first.id +
  629. "' data-outcome-id='" + json.outcomes.first[outcome].id + "' data-outcome-name ='" + json
  630. .outcomes.first[outcome].name + "' class='list-group-item' >" + json.outcomes.first[outcome]
  631. .name + " </li>";
  632. }
  633. div.append(list);
  634. }
  635. if(json.outcomes.second){
  636. header4 = $('<h5/>', {
  637. 'style': "padding-left: 10px"
  638. }).html("Second Semester");
  639. div.append(header4);
  640. list = '';
  641. for (outcome in json.outcomes.second) {
  642. list +=
  643. "<li style='padding-left: 25px' onclick = 'fetchEverything(this)' data-annual-plan = '" +
  644. json.annual_plans.id + "' data-typ-semester-outcome-id ='"+json.outcomes.second[outcome].typ_semester_outcome_id+"'data-semester-id = '" + json.allSemesterOrder.second.id +
  645. "' data-outcome-id='" + json.outcomes.second[outcome].id + "' data-outcome-name ='" + json
  646. .outcomes.second[outcome].name + "' class='list-group-item' >" + json.outcomes.second[
  647. outcome].name + " </li>";
  648. }
  649. div.append(list);
  650. }
  651. html = div[0].innerHTML;
  652. $("#allOutcomes").html(div[0].innerHTML);
  653. $("#allOutcomes").show();
  654. },
  655. "json",
  656. );
  657. }
  658. function deleteObjective(objectiveSelectDiv, closeObj) {
  659. $('#' + objectiveSelectDiv).remove();
  660. $('#' + closeObj).remove();
  661. $('#' + div).data("amount-select", $('#' + div).data("amount-select") - 1);
  662. }
  663. </script>
  664. @stop
  665. @section('included-js')
  666. @include('global._datatables_js')
  667. @stop