No Description

course_edit.blade.php 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @include('local.managers.admins._new_navigation')
  4. @stop
  5. @section('main')
  6. <div class="row">
  7. <div class="col-md-6">
  8. <div class="panel panel-default panel-button">
  9. <div class="panel-heading">
  10. Create a Course
  11. </div>
  12. <div class="panel-body">
  13. {{ Form::open(['action' => 'CoursesController@create','enctype'=>"multipart/form-data"]) }}
  14. <div class="form-group">
  15. {{ Form::label("name",'Name')}}
  16. {{ Form::text('name', Input::old('name'), ['class'=>'form-control', 'placeholder' => "Introducción a la ..."])}}
  17. </div>
  18. <div class="form-group">
  19. {{ Form::label('code', 'Code') }}
  20. {{ Form::text('code', Input::old('code'), ['class' => 'form-control', 'placeholder' => 'TEST', 'maxLength' => 4]) }}
  21. </div>
  22. <div class="form-group">
  23. {{ Form::label('number', 'Number') }}
  24. {{ Form::text('number', Input::old('number'), ['class' => 'form-control', 'placeholder' => '3001', 'maxLength' => 4]) }}
  25. </div>
  26. <div class="form-group">
  27. {{ Form::label('section', 'Section') }}
  28. {{ Form::text('section', Input::old('section'), ['class' => 'form-control', 'placeholder' => '001', 'maxLength' => 3]) }}
  29. </div>
  30. <!-- Program -->
  31. <div class="form-group">
  32. {{ Form::label('program', 'Program') }}
  33. <select id="program" name="program" class="form-control selectpicker">
  34. @foreach ($programs as $program)
  35. @if (Input::old('program') != $program->id)
  36. <option value="{{ $program->id }}">{{ $program->name }}
  37. ({{ $program->school->name }})</option>
  38. @else
  39. <option selected value="{{ $program->id }}">{{ $program->name }}
  40. ({{ $program->school->name }})</option>
  41. @endif
  42. @endforeach
  43. </select>
  44. </div>
  45. <div class="form-group">
  46. {{ Form::label('user_id', 'Professor') }}
  47. <select id="professor_id" name="professor_id" class="form-control selectpicker">
  48. @foreach ($professors as $professor)
  49. @if (Input::old('professor_id') != $professor->id )
  50. <option value="{{$professor->id}}">{{ $professor->surnames }}, {{$professor->first_name}}
  51. {{-- $professor->program->name --}}</option>
  52. @else
  53. <option selected value="{{ $professor->id }}">{{ $professor->name }}
  54. {{-- $professor->program->name --}}</option>
  55. @endif
  56. @endforeach
  57. </select>
  58. </div>
  59. <div class ="form-group">
  60. {{ Form::label("semester_id",'Semester')}}
  61. <select id ="semester_id" name="semester_id" class="form-control selectpicker">
  62. @foreach ($semesters as $semester)
  63. @if (Input::old('semester_id') != $semester->id)
  64. <option value="{{ $semester->id }}">{{ $semester->name }}</option>
  65. @else
  66. <option selected value="{{ $semester->id }}">{{ $semester->name }}</option>
  67. @endif
  68. @endforeach
  69. </select>
  70. </div>
  71. <div class = "form-group">
  72. {{Form::label('modality','Course Modality')}}
  73. <select id="modality" name = "modality" class= "form-control selectpicker">
  74. @foreach($modalities as $modality)
  75. @if (Input::old('modality') != $modality)
  76. <option value="{{ $modality }}">{{ $modality }}</option>
  77. @else
  78. <option selected value="{{ $modality }}">{{ $modality }}</option>
  79. @endif
  80. @endforeach
  81. </select>
  82. </div>
  83. <div class ="form-group">
  84. <label for="file">Choose student text file</label>
  85. <input type="file"
  86. id="students" class="form-control" name="students"
  87. accept=".txt">
  88. </div>
  89. <br>
  90. {{ Form::submit('Create Course', ['class' => 'btn btn-primary btn-block', 'name' => 'create_course']) }}
  91. {{ Form::close() }}
  92. <br>
  93. @if (Session::has('courses'))
  94. <p><strong>The following courses were updated:</strong></p>
  95. <ul>
  96. @foreach (json_decode(Session::get('courses')) as $course)
  97. <li>
  98. @if (Session::has('show_sections'))
  99. {{ $course->code }}{{ $course->number }}-{{ $course->section }}
  100. @else
  101. {{ $course->code }}{{ $course->number }}
  102. @endif
  103. </li>
  104. @endforeach
  105. </ul>
  106. @endif
  107. </div>
  108. </div>
  109. </div>
  110. <div class="col-md-6">
  111. <div class="panel panel-default panel-button">
  112. <div class="panel-heading">
  113. Edit Course
  114. </div>
  115. <div class="panel-body">
  116. <p>You can enroll students in this setting, by choosing the course and uploading a .txt file with the students numbers</p>
  117. {{ Form::open(['action' => 'CoursesController@updateCourseInfo', 'enctype'=>"multipart/form-data"]) }}
  118. <button class="btn btn-md btn-secondary filterButton">
  119. <span class="glyphicon glyphicon-minus">
  120. </span>
  121. Filters
  122. </button>
  123. <div class="filterSection">
  124. <br>
  125. <div class="form-group">
  126. {{ Form::label('program_id2', 'Associated Program') }}
  127. <select id='select-program' class="form-control selectpicker"
  128. onchange='fetchCourses("#select-program", "#select-semester")'>
  129. @foreach ($programs as $program)
  130. <option value='{{ $program->id }}' data-subtext="{{ $program->code }}">
  131. {{ $program->name }}</option>
  132. @endforeach
  133. </select>
  134. </div>
  135. <div class="form-group">
  136. {{ Form::label('semester_assoc', 'Course Semester') }}
  137. <select id='select-semester' class="form-control selectpicker"
  138. onchange='fetchCourses("#select-program", "#select-semester")'>
  139. @foreach ($semesters as $semester)
  140. <option value='{{ $semester->id }}' data-subtext="{{ $semester->code }}">
  141. {{ $semester->name }}</option>
  142. @endforeach
  143. </select>
  144. </div>
  145. </div>
  146. <hr>
  147. <div class = "form-group">
  148. {{Form::label('select_course', "Course")}}
  149. <select id = "select-course" name = "select-course" class ='form-control selectpicker'
  150. onchange = "fetchCourseInfo('#select-course')">
  151. </select>
  152. </div>
  153. <div class="form-group">
  154. {{ Form::label("name",'Name')}}
  155. {{ Form::text('name', Input::old('name'), ['class'=>'form-control', 'placeholder' => "Introducción a la ...", 'id'=> 'edit_name'])}}
  156. </div>
  157. <div class="form-group">
  158. {{ Form::label('code', 'Code') }}
  159. {{ Form::text('code', Input::old('code'), ['class' => 'form-control', 'placeholder' => 'TEST', 'maxLength' => 4, 'id'=> 'edit_code']) }}
  160. </div>
  161. <div class="form-group">
  162. {{ Form::label('number', 'Number') }}
  163. {{ Form::text('number', Input::old('number'), ['class' => 'form-control', 'placeholder' => '3001', 'maxLength' => 4, 'id'=> 'edit_number']) }}
  164. </div>
  165. <div class="form-group">
  166. {{ Form::label('section', 'Section') }}
  167. {{ Form::text('section', Input::old('section'), ['class' => 'form-control', 'placeholder' => '001', 'maxLength' => 3, 'id'=> 'edit_section']) }}
  168. </div>
  169. <!-- Program -->
  170. <div class="form-group">
  171. {{ Form::label('program', 'Program') }}
  172. <select id="edit_program" name="program" class="form-control selectpicker">
  173. @foreach ($programs as $program)
  174. @if (Input::old('program') != $program->id)
  175. <option value="{{ $program->id }}">{{ $program->name }}
  176. ({{ $program->school->name }})</option>
  177. @else
  178. <option selected value="{{ $program->id }}">{{ $program->name }}
  179. ({{ $program->school->name }})</option>
  180. @endif
  181. @endforeach
  182. </select>
  183. </div>
  184. <div class="form-group">
  185. {{ Form::label('user_id', 'Professor') }}
  186. <select id="edit_professor_id" name="professor_id" class="form-control selectpicker">
  187. @foreach ($professors as $professor)
  188. @if (Input::old('professor_id') != $professor->id )
  189. <option value="{{$professor->id}}">{{ $professor->surnames }}, {{$professor->first_name}}
  190. {{-- $professor->program->name --}}</option>
  191. @else
  192. <option selected value="{{ $professor->id }}">{{ $professor->name }}
  193. {{-- $professor->program->name --}}</option>
  194. @endif
  195. @endforeach
  196. </select>
  197. </div>
  198. <div class ="form-group">
  199. {{ Form::label("semester_id",'Semester')}}
  200. <select id ="edit_semester_id" name="semester_id" class="form-control selectpicker">
  201. @foreach ($semesters as $semester)
  202. @if (Input::old('semester_prof') != $semester->id)
  203. <option value="{{ $semester->id }}">{{ $semester->name }}</option>
  204. @else
  205. <option selected value="{{ $semester->id }}">{{ $semester->name }}</option>
  206. @endif
  207. @endforeach
  208. </select>
  209. </div>
  210. <div class = "form-group">
  211. {{Form::label('modality','Course Modality')}}
  212. <select id="edit_modality" name = "modality" class= "form-control selectpicker">
  213. @foreach($modalities as $modality)
  214. @if (Input::old('modality') != $modality)
  215. <option value="{{ $modality }}">{{ $modality }}</option>
  216. @else
  217. <option selected value="{{ $modality }}">{{ $modality }}</option>
  218. @endif
  219. @endforeach
  220. </select>
  221. </div>
  222. <div class ="form-group">
  223. <label for="file">Choose student text file</label>
  224. <input type="file"
  225. id="edit_students" class="form-control" name="students"
  226. accept=".txt">
  227. </div>
  228. <br>
  229. {{ Form::submit('Edit Course', ['class' => 'btn btn-primary btn-block', 'name' => 'edit_course_info']) }}
  230. {{ Form::close() }}
  231. </div>
  232. </div>
  233. </div>
  234. </div>
  235. <script>
  236. $('.filterSection').show();
  237. $('.filterButton').on('click', function() {
  238. var span = $(this).find('span');
  239. if (span.attr('class') == 'glyphicon glyphicon-plus') {
  240. span.attr('class', 'glyphicon glyphicon-minus');
  241. } else {
  242. span.attr('class', 'glyphicon glyphicon-plus');
  243. }
  244. $('.filterSection').toggle(533);
  245. });
  246. $('.filterButton').on('click', function(e) {
  247. // Prevent the default action of the clicked item. In this case that is submit
  248. e.preventDefault();
  249. return false;
  250. });
  251. function fetchCourses(select, semester){
  252. program_id = $(select).val();
  253. semester_id = $(semester).val();
  254. $.post(
  255. "{{URL::action('CoursesController@fetchCourses')}}",
  256. {
  257. program_id:program_id,
  258. semester_id:semester_id
  259. },
  260. function(courses){
  261. $('#select-course').html(
  262. " "
  263. )
  264. $.each(courses, function(ind, course){
  265. option = "<option value= '"+course.id+"' data-subtext ='"+course.code+course.number+"'"+
  266. "data-code='"+course.code+"' data-number='"+course.number+"' data-program-id='"+course.program_id+"'"+
  267. "data-section='"+course.section+"' data-user-id='"+course.user_id+"' data-semester-id = '"+course.semester_id+"'"+
  268. "data-modality='"+course.modality+"' "+
  269. ">"+course.name+"</option>";
  270. $("#select-course").append(option);
  271. });
  272. $("#select-course").trigger('change');
  273. $("#select-course").selectpicker('refresh');
  274. }
  275. )
  276. }
  277. function fetchCourseInfo(course_select){
  278. course_option = $(course_select).find(':selected');
  279. $('#edit_name').val($(course_option).html())
  280. $('#edit_code').val($(course_option).data('code'))
  281. $('#edit_number').val($(course_option).data('number'))
  282. $('#edit_section').val($(course_option).data('section'))
  283. $('#edit_program').val($(course_option).data('program-id'))
  284. $("#edit_program").selectpicker('refresh');
  285. $('#edit_professor_id').val($(course_option).data('user-id'))
  286. $("#edit_professor_id").selectpicker('refresh');
  287. $('#edit_semester_id').val($(course_option).data('semester-id'))
  288. $("#edit_semester_id").selectpicker('refresh');
  289. $('#edit_modality').val($(course_option).data('modality'))
  290. $("#edit_modality").selectpicker('refresh');
  291. $(course_select).selectpicker('refresh');
  292. }
  293. </script>
  294. @stop
  295. @section('javascript')
  296. // --------------------------------------------------------------------------
  297. // Page load
  298. // --------------------------------------------------------------------------
  299. // --------------------------------------------------------------------------
  300. // Functions
  301. // --------------------------------------------------------------------------
  302. // --------------------------------------------------------------------------
  303. // Events
  304. // --------------------------------------------------------------------------
  305. @stop