Нет описания

annual-plans.blade.php 55KB

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