No Description

transformativeAction.blade.php 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if ($role == 2)
  4. @include('local.managers.sCoords._new_navigation')
  5. @elseif($role == 3)
  6. @include('local.managers.pCoords._new_navigation')
  7. @else
  8. @include('local.professors._navigation')
  9. @endif
  10. @stop
  11. @section('main')
  12. <div class="row">
  13. <div class="col-md-6">
  14. <!-- Form to add a new criterion -->
  15. <div class="panel panel-default panel-button">
  16. <div class="panel-heading">
  17. Create a TA
  18. </div>
  19. <div class="panel-body" id="createPanel">
  20. {{ Form::open(['action' => 'TransformativeActionsController@createTA']) }}
  21. <div class="form-group">
  22. {{ Form::label('text', 'Name') }}
  23. {{ Form::text('text', '', ['class' => 'form-control', 'id' => 'text2']) }}
  24. </div>
  25. <div class="form-group">
  26. {{ Form::label('description', 'Description') }}
  27. {{ Form::textarea('description', '', ['class' => 'form-control', 'id' => 'description2']) }}
  28. </div>
  29. <div class="form-group"> </div>
  30. <div class="form-group" id='dummyApproval'>
  31. <label>Availability</label>
  32. <select name="approval" class="form-control">
  33. <option value="1">Recommended</option>
  34. <option value="0">To be implemented</option>
  35. </select>
  36. </div>
  37. <label>Courses being Transformed by the Action</label>
  38. <div class="" id="">
  39. <div class="form-group col-md-11">
  40. <select name="courseid" class="form-control createCourses selectpicker">
  41. @foreach ($courses_create as $course)
  42. <option value="({{ $course->code }},{{ $course->number }})">
  43. {{ $course->code }}{{ $course->number }} {{ $course->name }}</option>
  44. @endforeach
  45. </select>
  46. </div>
  47. <!--<button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
  48. X
  49. </button>-->
  50. </div>
  51. <!--<button type="button" class='btn btn-md btn-secondary add-course'>
  52. <span class='glyphicon glyphicon-plus'>
  53. </span>
  54. Add another Course
  55. </button>-->
  56. <div class="form-group"> </div>
  57. <div class="form-group" id='createOutcome'>
  58. <label>Outcome </label>
  59. <select name="outcome" class="form-control selectpicker">
  60. @foreach ($outcomes as $outcome)
  61. <option value="{{ $outcome->id }}">{{ $outcome->name }}</option>
  62. @endforeach
  63. </select>
  64. </div>
  65. <label>Associated Objectives</label>
  66. <div class="" id="">
  67. <div class="form-group col-md-11">
  68. <select name="objectiveid[]" class="form-control createObjectives">
  69. <option value="">First, select an Outcome</option>
  70. </select>
  71. </div>
  72. <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
  73. X
  74. </button>
  75. </div>
  76. <button type="button" class='btn btn-md btn-secondary add-objective'>
  77. <span class='glyphicon glyphicon-plus'>
  78. </span>
  79. Add another Objective
  80. </button>
  81. <br>
  82. <br>
  83. <div class="form-group">
  84. <label>Type of Transformative Action</label>
  85. <select name='type_of_ta' class="form-control selectpicker">
  86. @foreach ($types as $type)
  87. <option value='{{ $type->type_of_TA }}'>{{ $type->type_of_TA }}</option>
  88. @endforeach
  89. <option value="new"> New Type of Transformative Action</option>
  90. </select>
  91. </div>
  92. {{ Form::submit('Create', ['class' => 'btn btn-primary btn-block']) }}
  93. {{ Form::close() }}
  94. </div>
  95. </div>
  96. <!--<div class="panel panel-default panel-button">
  97. <div class="panel-heading">
  98. Approve a Recommended TA
  99. </div>
  100. <div class="panel-body" id="approvePanel">
  101. <div class="">
  102. <button class="btn btn-md btn-secondary filterButton">
  103. <span class="glyphicon glyphicon-plus">
  104. </span>
  105. Filters
  106. </button>
  107. </div>
  108. <div class="filterSection">
  109. <br>
  110. <div class="">
  111. <div class="">
  112. <label>Professor that created the TA</label>
  113. <select class="form-control filterProfessor selectpicker">
  114. <option value="0">Show All</option>
  115. {{-- @foreach ($professor_filter_approvePanel as $ta)
  116. <option value="{{$ta->id}}">Prof. {{$ta->first_name}} {{$ta->surnames}}</option>
  117. @endforeach --}}
  118. </select>
  119. </div>
  120. <br>
  121. <div class="">
  122. <label>Course evaluated by an Objective of the TA</label>
  123. <select class="form-control filterCourse selectpicker">
  124. <option value="0">Show All</option>
  125. {{-- @foreach ($course_filter_approvePanel as $course)
  126. <option value="({{$course->code}},{{$course->number}})">{{$course->code}} {{$course->number}}</option>
  127. @endforeach --}}
  128. </select>
  129. </div>
  130. <br>
  131. <div class="">
  132. <label>Outcome of the TA</label>
  133. <select class="form-control filterOutcome selectpicker">
  134. <option value="0">Show All</option>
  135. {{-- @foreach ($outcome_filter_approvePanel as $outcome)
  136. <option value="{{$outcome->id}}">{{$outcome->name}}</option>
  137. @endforeach --}}
  138. </select>
  139. </div>
  140. </div>
  141. </div>
  142. <hr>
  143. {{-- Form::open(array('action' => 'TransformativeActionsController@approveTA')) --}}
  144. <div>
  145. <div class="form-group col-md-11">
  146. <label>Select Transformative Action</label>
  147. <select name="ta" class="form-control SelectTA selectpicker" id='approvalSelectTA'>
  148. {{-- @if (count($ta_approval_panel) == 0)
  149. <option value="0">No TAs available</option>
  150. @else
  151. @endif
  152. @foreach ($ta_approval_panel as $ta)
  153. <option value="{{$ta->id}}">{{$ta->at_text}}</option>
  154. @endforeach --}}
  155. </select>
  156. </div>
  157. </div>
  158. <div class="form-group">
  159. {{-- {{ Form::label('approvalDescription', 'Description') }}
  160. {{ Form::textarea('approvalDescription', '', array('class' => 'form-control')) }} --}}
  161. </div>
  162. <label>Associated Courses</label>
  163. <div class="approveCourses">
  164. <div class="form-group col-md-11 approveCourse">
  165. <select name="courseid" id ="approval_course" class="form-control selectpicker disabled">
  166. </select>
  167. </div>
  168. <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
  169. X
  170. </button>
  171. </div>
  172. <button type="button" class='btn btn-md btn-secondary add-course'>
  173. <span class='glyphicon glyphicon-plus'>
  174. </span>
  175. Add another Course
  176. </button>
  177. <label>Associated Objectives</label>
  178. <div class="approveObjectives">
  179. <div class="form-group col-md-11">
  180. <select name="objectiveid[]" class="form-control">
  181. {{-- @foreach ($objectives as $id => $text)
  182. <option value="{{$id}}">{{$text}}</option>
  183. @endforeach --}}
  184. </select>
  185. </div>
  186. <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
  187. X
  188. </button>
  189. </div>
  190. <button type="button" class='btn btn-md btn-secondary add-objective'>
  191. <span class='glyphicon glyphicon-plus'>
  192. </span>
  193. Add another Objective
  194. </button>
  195. <br><br>
  196. <div class="form-group">
  197. <label>Type of Transformative Action</label>
  198. <select name='type_of_ta' class="form-control selectpicker">
  199. <option value ='0'>Select a Type</option>
  200. {{-- @foreach ($types as $type)
  201. <option value = '{{$type->type_of_TA}}'>{{$type->type_of_TA}}</option>
  202. @endforeach --}}
  203. <option value ="new"> New Type of Transformative Action</option>
  204. </select>
  205. </div>
  206. <input type='hidden' name='at_text' class="approvalText">
  207. <input type='hidden' name='ta_id' class='updateTA'>
  208. {{-- Form::submit('Approve', array('class' => 'btn btn-primary btn-block')) }}
  209. {{ Form::close() --}}
  210. </div>
  211. </div> -->
  212. </div>
  213. <div class="col-md-6">
  214. <div class="panel panel-default panel-button">
  215. <div class="panel-heading">
  216. Edit a TA
  217. </div>
  218. <div class="panel-body" id="editPanel">
  219. <div class="">
  220. <button class="btn btn-md btn-secondary filterButton">
  221. <span class="glyphicon glyphicon-minus">
  222. </span>
  223. Filters
  224. </button>
  225. </div>
  226. <div class="filterSection">
  227. <br>
  228. <div class="">
  229. <div class="">
  230. <label>Professor that created the TA</label>
  231. <select class="form-control filterProfessor selectpicker">
  232. <option value="0">Show All</option>
  233. @foreach ($professor_filter_editPanel as $user)
  234. <option value="{{ $user->id }}">Prof. {{ $user->first_name }}
  235. {{ $user->surnames }}</option>
  236. @endforeach
  237. </select>
  238. </div>
  239. <br>
  240. <div class="">
  241. <label>Course evaluated by an Objective of the TA</label>
  242. <select class="form-control filterCourse selectpicker">
  243. <option value="0">Show All</option>
  244. @foreach ($course_filter_editPanel as $course)
  245. <option value="({{ $course->code }},{{ $course->number }})">
  246. {{ $course->code }}{{ $course->number }} {{ $course->name }}</option>
  247. @endforeach
  248. </select>
  249. </div>
  250. <br>
  251. <div class="">
  252. <label>Outcome of the TA</label>
  253. <select class="form-control filterOutcome selectpicker">
  254. <option value="0">Show All</option>
  255. @foreach ($outcome_filter_editPanel as $outcome)
  256. <option value="{{ $outcome->id }}">{{ $outcome->name }}</option>
  257. @endforeach
  258. </select>
  259. </div>
  260. </div>
  261. </div>
  262. <hr>
  263. {{ Form::open(['action' => 'TransformativeActionsController@updateTA']) }}
  264. <div>
  265. <div class="form-group col-md-12">
  266. <label>Select Transformative Action</label>
  267. <select name="ta" class="form-control SelectTA selectpicker" id='editSelectTA'>
  268. @if (count($ta_edit_panel) == 0)
  269. <option value="0">No TAs available</option>
  270. @else
  271. @endif
  272. @foreach ($ta_edit_panel as $ta)
  273. <option value="{{ $ta->id }}">{{ $ta->at_text }}</option>
  274. @endforeach
  275. </select>
  276. </div>
  277. </div>
  278. <div class="form-group" id="editName">
  279. {{ Form::label('text', 'Name') }}
  280. {{ Form::text('text', '', ['class' => 'form-control']) }}
  281. </div>
  282. <input type='hidden' name='ta_id' class='updateTA' value="0">
  283. <div class="form-group">
  284. {{ Form::label('description', 'Description') }}
  285. {{ Form::textarea('description', '', ['class' => 'form-control']) }}
  286. </div>
  287. <div class="form-group"> </div>
  288. <div class="form-group" id='editApproval'>
  289. <label>Availability</label>
  290. <select name="approval" class="form-control selectpicker">
  291. <option value="1">Recommended</option>
  292. <option value="0">To be implemented</option>
  293. </select>
  294. </div>
  295. <label>Associated Courses</label>
  296. <div class="editCourses">
  297. <div class="form-group col-md-11 editCourse">
  298. <select name="courseid" id="edit_course" class="form-control selectpicker">
  299. @foreach ($courses_create as $course)
  300. <option value="({{ $course->code }},{{ $course->number }})">
  301. {{ $course->code }}{{ $course->number }} {{ $course->name }}</option>
  302. @endforeach
  303. </select>
  304. </div>
  305. <!--<button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
  306. X
  307. </button>-->
  308. </div>
  309. <!--<button type="button" class='btn btn-md btn-secondary add-course'>
  310. <span class='glyphicon glyphicon-plus'>
  311. </span>
  312. Add another Course
  313. </button>-->
  314. <div class="form-group"> </div>
  315. <label>Associated Objectives</label>
  316. <div class="editObjectives">
  317. <div class="form-group col-md-11">
  318. {{-- <select class="form-control selectpicker"> --}}
  319. <select name="objectiveid[]" class="form-control">
  320. @foreach ($objectives as $id => $text)
  321. <option value="{{ $id }}">{{ $text }}</option>
  322. @endforeach
  323. </select>
  324. </div>
  325. <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
  326. X
  327. </button>
  328. </div>
  329. <button type="button" class='btn btn-md btn-secondary add-objective'>
  330. <span class='glyphicon glyphicon-plus'>
  331. </span>
  332. Add another Objective
  333. </button>
  334. <br><br>
  335. <div class="form-group">
  336. <label>Type of Transformative Action</label>
  337. <select name='type_of_ta' class="form-control selectpicker">
  338. @foreach ($types as $type)
  339. <option value='{{ $type->type_of_TA }}'>{{ $type->type_of_TA }}</option>
  340. @endforeach
  341. <option value="new"> New Type of Transformative Action</option>
  342. </select>
  343. </div>
  344. {{ Form::submit('Update', ['class' => 'btn btn-primary btn-block']) }}
  345. {{ Form::close() }}
  346. {{ Form::open(['action' => 'TransformativeActionsController@deleteTA']) }}
  347. <input type='hidden' name='ta_id' id='deleteTA'>
  348. {{ Form::submit('Delete', ['class' => 'btn btn-primary btn-block', 'id' => 'DeleteButton']) }}
  349. </div>
  350. </div>
  351. </div>
  352. </div>
  353. <script>
  354. // --------------------------------------------------------------------------
  355. // Page load
  356. // --------------------------------------------------------------------------
  357. $("select[name='type_of_ta']").on('change', function() {
  358. if ($(this).val() == "new") {
  359. var new_div = $('<div/>', {
  360. 'class': 'form-group new_type'
  361. }).html("<label>New Type </label>");
  362. var input = $("<input/>", {
  363. 'type': 'text',
  364. 'name': "new_type",
  365. 'class': 'form-control'
  366. });
  367. new_div.append(input);
  368. $(this).parent().parent().after(new_div)
  369. } else {
  370. $(this).parent().parent().next('.new_type').remove();
  371. }
  372. })
  373. // Hide accordion panel contents by default
  374. $('.panel-group .panel-body').hide();
  375. $('#outcome-display').parent().hide();
  376. $('.remove-objective').hide();
  377. $('.remove-course').hide();
  378. ////createPanel
  379. // remove TA approval section if the user isnt a program coordinator
  380. var dummyApproval = $('#dummyApproval');
  381. dummyApproval.find('select').prop('disabled', 'disabled');
  382. dummyApproval.find('option').remove();
  383. var role = {{ Auth::user()['role'] }};
  384. if (role != 4) {
  385. dummyApproval.find('select').append('<option value="0">To be implemented</option>');
  386. $('#approvePanel .add-course').hide();
  387. }
  388. /* else if (role == 4){
  389. dummyApproval.find('select').append('<option value="1">Recommended</option>');
  390. $('#approvePanel').parent().hide();
  391. //hide the select for changin Availability
  392. $('#editApproval').find('select').prop('disabled', 'disabled');
  393. //add an input since disabled the form wont recognize it
  394. $('#editApproval').append('<input type="text" name="approval" value="1" hidden />')
  395. // in edit panel, hide the professor filter
  396. $('.filterProfessor').parent().hide();
  397. $('.filterProfessor').parent().next().hide(); // hide <br>
  398. }*/
  399. $('.createObjectives').prop('disabled', 'disabled');
  400. $('#createPanel .add-objective').prop('disabled', 'disabled');
  401. ////editPanel
  402. // disable the buttons of the edit section if there are no TA for selection
  403. if (($('#editSelectTA').val() === "")) {
  404. $('#editPanel').find('select').prop('disabled', 'disabled');
  405. $('#editPanel').find('button').prop('disabled', 'disabled');
  406. $('#editPanel').find('input').prop('disabled', 'disabled');
  407. } else {
  408. var ta_id = $('#editSelectTA').val();
  409. if (ta_id != 0) {
  410. load_ta_info_for_edit(ta_id);
  411. }
  412. }
  413. ////approvePanel
  414. $('#approvePanel .add-objective').hide();
  415. // disable the buttons of the approval section if there are no TA for selection
  416. if (($('#approvalSelectTA').val() === "")) {
  417. $('#approvePanel').find('select').prop('disabled', 'disabled');
  418. $('#approvePanel').find('button').prop('disabled', 'disabled');
  419. $('#approvePanel').find('input').prop('disabled', 'disabled');
  420. $('#approvalDescription').prop('disabled', 'disabled');
  421. } else {
  422. var ta_id = $('#approvalSelectTA').val();
  423. //if(ta_id != 0){
  424. // load_ta_info_for_approval(ta_id);
  425. //}
  426. }
  427. //
  428. //$('.filterSection').hide();
  429. $('.filterSection').show();
  430. // --------------------------------------------------------------------------
  431. // Functions
  432. // --------------------------------------------------------------------------
  433. function load_objectives_from_outcome(outcome_id) {
  434. $.post(
  435. "{{ URL::action('TransformativeActionsController@objectivesFromOutcome') }}", {
  436. outcome_id: (outcome_id),
  437. },
  438. function(data) {
  439. var panel = $('#createPanel');
  440. //
  441. var objectives = data.objectives;
  442. //delete al current select
  443. panel.find('.remove-objective').parent().remove();
  444. //create select
  445. var new_div = $('<div/>', {
  446. 'class': 'createObjectives'
  447. });
  448. var new_inner_div = $('<div/>', {
  449. 'class': 'form-group col-md-11'
  450. });
  451. var new_select = $('<select/>', {
  452. 'class': 'form-control createObjectives selectpicker',
  453. 'data-live-search': 'true',
  454. 'name': 'objectiveid[]'
  455. });
  456. var new_button = $('<button/>', {
  457. 'class': 'btn btn-md btn-primary col-md-1 remove-objective',
  458. 'type': 'button',
  459. 'html': 'X'
  460. });
  461. new_button.hide();
  462. $.each(objectives, function(index, objective) {
  463. new_select.append('<option value="' + objective.id + '">' + objective.text +
  464. '</option>');
  465. });
  466. panel.find('.add-objective').before(new_div);
  467. new_div.append(new_button);
  468. new_div.append(new_inner_div);
  469. new_inner_div.append(new_select);
  470. new_select.selectpicker('refresh');
  471. //activate the button for adding more objectives
  472. $('#createPanel .add-objective').prop('disabled', false);
  473. }
  474. );
  475. }
  476. function load_ta_info_for_edit(ta_id) {
  477. $.post(
  478. "{{ URL::action('TransformativeActionsController@selectTA') }}", {
  479. ta_id: (ta_id),
  480. },
  481. function(data) {
  482. //
  483. var selected_course = data.selected_courses;
  484. var objectives = data.objectives;
  485. var objectives_from_outcome = data.objectives_from_outcome;
  486. var status = data.status;
  487. var name = data.name[0];
  488. var description = data.description[0];
  489. var can_be_deleted = data.can_be_deleted;
  490. //add objectives button
  491. var add_button = $('#editPanel .add-objective');
  492. //set if the TA is approved or not
  493. $('#editApproval select').val(status);
  494. //delete objectives select
  495. $('.editObjectives').remove();
  496. //create one objective select and populate it
  497. var panel = $('#editPanel');
  498. //
  499. var objectives = data.objectives;
  500. //delete al current select
  501. panel.find('.remove-objective').parent().remove();
  502. //create select
  503. var new_div = $('<div/>', {
  504. 'class': 'editObjectives'
  505. });
  506. var new_inner_div = $('<div/>', {
  507. 'class': 'form-group col-md-11'
  508. });
  509. var new_select = $('<select/>', {
  510. 'class': 'form-control editObjectives selectpicker',
  511. 'data-live-search': 'true',
  512. 'name': 'objectiveid[]'
  513. });
  514. var new_button = $('<button/>', {
  515. 'class': 'btn btn-md btn-primary col-md-1 remove-objective',
  516. 'type': 'button',
  517. 'html': 'X'
  518. });
  519. new_button.hide();
  520. $.each(objectives_from_outcome, function(index, objective) {
  521. new_select.append('<option value="' + objective.id + '">' + objective.text +
  522. '</option>');
  523. });
  524. panel.find('.add-objective').before(new_div);
  525. new_div.append(new_button);
  526. new_div.append(new_inner_div);
  527. new_inner_div.append(new_select);
  528. new_select.selectpicker('refresh');
  529. //change de value of the select
  530. //add the other selects
  531. var prev_select = new_div;
  532. $.each(objectives, function(index, objective) {
  533. prev_select.find('select').val(objective.id);
  534. add_objective_select(add_button);
  535. {{-- add_button; --}}
  536. prev_select = add_button.prev();
  537. });
  538. add_button.prev().remove();
  539. //set the text box
  540. $('#editName').find('input').val(name);
  541. $('#editPanel #description').val(description);
  542. //
  543. $('#deleteTA').val(ta_id);
  544. $('#editPanel .updateTA').val(ta_id);
  545. if (can_be_deleted == false) {
  546. $('#DeleteButton').prop('disabled', 'disabled');
  547. } else {
  548. $('#DeleteButton').prop('disabled', false);
  549. }
  550. /*
  551. //locate de "add course" button on edit panel
  552. var add_course_button = $('#editPanel .add-course')
  553. //save current course selectpickers, add a new one, and delete old ones
  554. var current_course_selects = $('#editPanel .editCourse');
  555. add_course_button.click();
  556. current_course_selects.remove();
  557. //populate edit panel with courses previusly selected
  558. var prev_select = add_course_button.prev();
  559. prev_select.find('.remove-course').hide();
  560. $.each(selected_courses, function(index, course)
  561. {
  562. prev_select.find('select').val(course.id);
  563. add_course_button.click();
  564. prev_select = add_course_button.prev();
  565. });
  566. prev_select.remove();
  567. */
  568. $('#edit_course').val('(' + selected_course[0].code + ',' + selected_course[0].number + ')');
  569. $('#edit_course').selectpicker('refresh');
  570. }
  571. );
  572. }
  573. /*function load_ta_info_for_approval(ta_id) {
  574. $.post(
  575. "{{ URL::action('TransformativeActionsController@selectTA') }}",
  576. {
  577. ta_id: (ta_id),
  578. },
  579. function(data)
  580. {
  581. //
  582. var selected_course = data.selected_courses;
  583. var objectives = data.objectives;
  584. var status = data.status[0];
  585. var name = data.name[0];
  586. var description = data.description[0];
  587. //clear the objectives of ony prevoius TA selected for approve
  588. var add_button = $('#approvePanel .add-objective');
  589. var select = add_button.prev().clone(true);
  590. var first_select = select.clone(true);
  591. first_select.find('button').hide();
  592. $('.approveObjectives').remove();
  593. add_button.before(first_select);
  594. var prev_select = first_select;
  595. $.each(objectives, function(index, objective)
  596. {
  597. // save the new select in a var
  598. var new_select = select.clone(true);
  599. // set only one option on the select
  600. prev_select.find('option').remove();
  601. prev_select.find('select').append('<option value="'+ objective.id +'">'+objective.text +'</option>');
  602. prev_select = new_select;
  603. // add the copy of the select
  604. add_button.before(new_select);
  605. });
  606. // remove the last objective select, since it isnt one of the saved objectives
  607. add_button.prev().remove();
  608. //
  609. $('#approvalDescription').val(description);
  610. $('.approvalText').val(name);
  611. $('#approvePanel .updateTA').val(ta_id);
  612. //locate de "add course" button on approve panel
  613. var add_course_button = $('#approvePanel .add-course')
  614. //save current course selectpickers, add a new one, and delete old ones
  615. var current_course_selects = $('#approvePanel .approveCourse');
  616. add_course_button.click();
  617. current_course_selects.remove();
  618. //populate approve panel with courses previusly selected
  619. var prev_select = add_course_button.prev();
  620. prev_select.find('.remove-course').hide();
  621. $.each(selected_courses, function(index, course)
  622. {
  623. var new_option = $('<option/>',{
  624. 'value': course.id,
  625. 'type': 'button',
  626. 'html': course.name+' ['+course.code+']'
  627. });
  628. prev_select.find('select option').remove();
  629. prev_select.find('select').append(new_option);
  630. prev_select.find('.remove-course').hide();
  631. add_course_button.click();
  632. prev_select = add_course_button.prev();
  633. });
  634. prev_select.remove();
  635. course = selected_course[0];
  636. var new_option = $('<option/>',{
  637. 'value': '('+course.code+','+course.number+')',
  638. 'type': 'button',
  639. 'html': course.name+' ['+course.code+']'
  640. });
  641. $('#approval_course').html(new_option);
  642. $('#approval_course').selectpicker('refresh');
  643. $('#approval_course').val('('+selected_course[0].code+','+selected_course[0].number+')');
  644. $('#approval_course').selectpicker('refresh');
  645. }
  646. );
  647. }*/
  648. function add_objective_select(element) {
  649. var prev_select = $(element).prev();
  650. var parent_panel = $(element).parent().parent().attr('id');
  651. var select_class = '';
  652. if (parent_panel == 'editPanel') {
  653. select_class = 'editObjectives';
  654. } else {
  655. select_class = 'createObjectives';
  656. }
  657. //create select
  658. var new_div = $('<div/>', {
  659. 'class': select_class
  660. });
  661. var new_inner_div = $('<div/>', {
  662. 'class': 'form-group col-md-11'
  663. });
  664. var new_select = $('<select/>', {
  665. 'class': 'form-control createObjectives selectpicker',
  666. 'data-live-search': 'true',
  667. 'name': 'objectiveid[]'
  668. });
  669. var new_button = $('<button/>', {
  670. 'class': 'btn btn-md btn-primary col-md-1 remove-objective',
  671. 'type': 'button',
  672. 'html': 'X'
  673. });
  674. $.each(prev_select.find('option'), function(index, option) {
  675. var new_option = $('<option/>', {
  676. 'value': $(option).val(),
  677. 'html': $(option).html()
  678. });
  679. new_select.append(new_option);
  680. });
  681. $(element).before(new_div);
  682. new_div.append(new_inner_div);
  683. new_div.append(new_button);
  684. new_inner_div.append(new_select);
  685. $(element).parent().find('.selectpicker').selectpicker('refresh');
  686. new_select.selectpicker('refresh');
  687. }
  688. function add_course_select(element) {
  689. var prev_select = $(element).prev();
  690. var parent_panel = $(element).parent().parent().attr('id');
  691. var select_class = '';
  692. if (parent_panel == 'editPanel') {
  693. select_class = 'editCourse';
  694. } else {
  695. select_class = 'createCourse';
  696. }
  697. //create select
  698. var new_div = $('<div/>', {
  699. 'class': select_class + ' approveCourse'
  700. });
  701. var new_inner_div = $('<div/>', {
  702. 'class': 'form-group col-md-11'
  703. });
  704. var new_select = $('<select/>', {
  705. 'class': 'form-control createCourses selectpicker',
  706. 'data-live-search': 'true',
  707. 'name': 'courseid[]'
  708. });
  709. var new_button = $('<button/>', {
  710. 'class': 'btn btn-md btn-primary col-md-1 remove-course',
  711. 'type': 'button',
  712. 'html': 'X'
  713. });
  714. $.each(prev_select.find('option'), function(index, option) {
  715. var new_option = $('<option/>', {
  716. 'value': $(option).val(),
  717. 'html': $(option).html()
  718. });
  719. new_select.append(new_option);
  720. });
  721. $(element).before(new_div);
  722. new_div.append(new_inner_div);
  723. new_div.append(new_button);
  724. new_inner_div.append(new_select);
  725. $(element).parent().find('.selectpicker').selectpicker('refresh');
  726. new_select.selectpicker('refresh');
  727. }
  728. // --------------------------------------------------------------------------
  729. // Events
  730. // --------------------------------------------------------------------------
  731. // When a TA is selected for edit, load the TA info
  732. $('#createOutcome').on('change', function() {
  733. var outcome_id = $(this).find('select').val();
  734. load_objectives_from_outcome(outcome_id);
  735. });
  736. $('#createOutcome').trigger("change");
  737. // When a TA is selected for edit, load the TA info
  738. $('#editSelectTA').parent().on('change', function() {
  739. var ta_id = $(this).find('select').val();
  740. if (ta_id != 0) {
  741. load_ta_info_for_edit(ta_id);
  742. }
  743. });
  744. // When a TA is selected for approval, load the TA info
  745. $('#approvalSelectTA').parent().on('change', function() {
  746. var ta_id = $(this).find('select').val();
  747. //if(ta_id != 0){
  748. // load_ta_info_for_approval(ta_id);
  749. // }
  750. });
  751. // Add an objective Select picker
  752. $('.add-objective').on('click', function() {
  753. add_objective_select(this);
  754. });
  755. // Add an course Select picker
  756. $('.add-course').on('click', function() {
  757. add_course_select(this);
  758. });
  759. // Remove an objective Select picker
  760. $('.panel').on('click', '.remove-objective', function() {
  761. $(this).parent().remove();
  762. });
  763. // Remove an course Select picker
  764. $('.panel').on('click', '.remove-course', function() {
  765. $(this).parent().remove();
  766. });
  767. // Remove an objective Select picker
  768. $('.filterButton').on('click', function() {
  769. var span = $(this).find('span');
  770. if (span.attr('class') == 'glyphicon glyphicon-plus') {
  771. span.attr('class', 'glyphicon glyphicon-minus');
  772. } else {
  773. span.attr('class', 'glyphicon glyphicon-plus');
  774. }
  775. $(this).parent().next().toggle(533);
  776. });
  777. //
  778. $('.filterSection').on('change', function() {
  779. var professor_id = $(this).find('.filterProfessor select').val();
  780. var course_id = $(this).find('.filterCourse select').val();
  781. var outcome_id = $(this).find('.filterOutcome select').val();
  782. var panel_id = $(this).parent().attr('id');
  783. var select = $('#' + panel_id + ' .SelectTA select');
  784. $.post(
  785. "{{ URL::action('TransformativeActionsController@filterTA') }}", {
  786. professor_id: (professor_id),
  787. course_id: (course_id),
  788. outcome_id: (outcome_id),
  789. panel_id: (panel_id),
  790. },
  791. function(data) {
  792. //
  793. select.find('option').remove();
  794. $.each(data, function(index, ta) {
  795. var ta_id = ta.id;
  796. var ta_text = ta.at_text;
  797. var new_option = '<option value="' + ta_id + '">' + ta_text + '</option>';
  798. select.append(new_option);
  799. });
  800. select.selectpicker('refresh');
  801. if (data.length != 0) {
  802. var ta_id = data[0].id;
  803. if (panel_id == 'editPanel') {
  804. load_ta_info_for_edit(ta_id);
  805. }
  806. // if(panel_id=='approvePanel'){
  807. // load_ta_info_for_approval(ta_id);
  808. // }
  809. }
  810. }
  811. );
  812. });
  813. </script>
  814. @stop
  815. @section('javascript')
  816. @stop