No Description

new-activity-create.blade.php 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @include('local.managers.admins._new_navigation')
  4. @stop
  5. @section('main')
  6. <!-- New Rubric Modal -->
  7. <div class="modal fade" id="newRubricModal" tabindex="-1" role="dialog" aria-labelledby="newRubricModalLabel"
  8. aria-hidden="true">
  9. <div class="modal-dialog modal-sm">
  10. <div class="modal-content">
  11. <div class="modal-header">
  12. <button type="button" class="close" data-dismiss="modal"><span
  13. aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  14. <h4 class="modal-title" id="newRubricModalLabel">New Instrument</h4>
  15. </div>
  16. <div class="modal-body">
  17. {{ Form::open(['action' => ['RubricsController@create']]) }}
  18. <div class="form-group">
  19. {{ Form::label('name', 'Name') }}
  20. {{ Form::text('name', Input::old('name'), ['class' => 'form-control']) }}
  21. </div>
  22. <div class="form-group">
  23. {{ Form::label('criteria', 'Criteria') }}
  24. <select id="criteria" name="criteria" class="form-control" multiple required>
  25. </select>
  26. {{ Form::textarea('criteria', Input::old('description'), ['class' => 'form-control', 'rows' => 5, 'placeholder' => 'Minimum 10 characters']) }}
  27. </div>
  28. <div class="btn-group" role="group">
  29. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  30. <button type="submit" class="btn btn-default btn-primary">Submit</button>
  31. </div>
  32. {{ Form::close() }}
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="row">
  38. <div class="col-md-12">
  39. <div class="panel panel-default panel-button">
  40. <div class="panel-heading">
  41. Create new activity
  42. </div>
  43. <div class="panel-body">
  44. {{ Form::open(['action' => 'ActivitiesController@update']) }}
  45. <div class="form-group">
  46. {{ Form::label('activity_type', 'Activity Type') }}
  47. <select id="activity_type" name="activity_type" class="form-control">
  48. @foreach ($activity_types as $activity_type)
  49. {{-- @if (Input::old('activity_type') != $activity_type) --}}
  50. {{-- <option value="{{ $activity_type }}">{{ $activity_type }} ({{ $program->school->name }})</option> --}}
  51. {{-- @else --}}
  52. {{-- <option selected value="{{ $program->id }}">{{ $program->name }} ({{ $program->school->name }})</option> --}}
  53. {{-- @endif --}}
  54. @endforeach
  55. </select>
  56. {{-- {{ Form::text('activity_type', Input::old('activity_Type'), array('class' => 'form-control', 'placeholder'=>'TEST', 'maxLength'=>5)) }} --}}
  57. </div>
  58. <div class="form-group">
  59. {{ Form::label('outcome', 'Learning Outcome') }}
  60. <select id="outcome" name="outcome" class="form-control">
  61. @foreach ($outcomes as $outcome)
  62. @if (Input::old('outcome') != $outcome->id)
  63. <option value="{{ $outcome->id }}">{{ $outcome->name }}</option>
  64. @else
  65. <option selected value="{{ $outcome->id }}">{{ $outcome->name }}</option>
  66. @endif
  67. @endforeach
  68. </select>
  69. </div>
  70. <div class="form-group">
  71. {{ Form::label('objective', 'Learning Objective') }}
  72. <select id="objective" name="objective[]" class="form-control" multiple required>
  73. @if (Input::old('outcome') != null)
  74. @foreach ($objectives_by_outcome[Input::old('outcome')] as $objective)
  75. @if (Input::old('objective') != $objective->id)
  76. <option value="{{ $objective->id }}">{{ $objective->text }}</option>
  77. @else
  78. <option selected value="{{ $objective->id }}">{{ $objective->text }}</option>
  79. @endif
  80. @endforeach
  81. @else
  82. @foreach ($objectives_by_outcome[$outcomes->first()->id] as $objective)
  83. <option value="{{ $objective->id }}">{{ $objective->text }}</option>
  84. @endforeach
  85. @endif
  86. </select>
  87. </div>
  88. <div class="form-group">
  89. {{ Form::label('instrument', 'Instrument') }}
  90. <select id="instrument" name="instrument" class="form-control">
  91. @foreach ($instruments as $instrument)
  92. @if (Input::old('instrument') != $instrument->id)
  93. <option value="{{ $instrument->id }}">{{ $instrument->name }}</option>
  94. @else
  95. <option selected value="{{ $instrument->id }}">{{ $instrument->name }}</option>
  96. @endif
  97. @endforeach
  98. </select>
  99. </div>
  100. <div class="form-group">
  101. <button type="button" data-toggle="modal" data-target="#newRubricModal"
  102. class="btn btn-sm btn-default">New Instrument</button>
  103. </div>
  104. <div class="form-group">
  105. {{ Form::label('transforming_action', 'Transformative Actions') }}
  106. <select id="transforming_action" name="transforming_action[]" class="form-control" multiple>
  107. @foreach ($transforming_actions as $transforming_action)
  108. {{-- @if (Input::old('transforming_action') != $transforming_action->id) --}}
  109. {{-- <option value="{{ $transforming_action->id }}">{{ $transforming_action->name }}</option> --}}
  110. {{-- @else --}}
  111. {{-- <option selected value="{{ $transforming_action->id }}">{{ $transforming_action->name }}</option> --}}
  112. {{-- @endif --}}
  113. @endforeach
  114. </select>
  115. </div>
  116. <br>
  117. {{ Form::submit('Submit', ['class' => 'btn btn-primary btn-block', 'name' => 'create_activity']) }}
  118. {{ Form::close() }}
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. @stop
  124. @section('javascript')
  125. // --------------------------------------------------------------------------
  126. // Page load
  127. // --------------------------------------------------------------------------
  128. const objectives = {{ $objectives_by_outcome->toJson() }};
  129. const criteria = {{ $criteria_by_objective->toJson() }};
  130. const outcomesSelect = document.getElementById('outcome');
  131. const objectivesSelect = document.getElementById('objective');
  132. const criteriaSelect = document.getElementById('criteria');
  133. // --------------------------------------------------------------------------
  134. // Functions
  135. // --------------------------------------------------------------------------
  136. // --------------------------------------------------------------------------
  137. // Events
  138. // --------------------------------------------------------------------------
  139. outcomesSelect.addEventListener('change', (event) => {
  140. var objectivesSelectOptions = [];
  141. objectives[event.target.value].forEach((objective) => {
  142. objectivesSelectOptions.push(`<option value="${objective.id}">${objective.text}</option>`);
  143. });
  144. objectivesSelect.innerHTML = objectivesSelectOptions.join();
  145. });
  146. objectivesSelect.addEventListener('change', (event) => {
  147. var criteriaSelectOptions = [];
  148. var selectedObjectives = Array.from(objectivesSelect.selectedOptions).map(v => value);
  149. selectedObjectives.forEach((objectiveId) => {
  150. criteria[objectiveId].forEach((criteriaArray) => {
  151. criteriaArray.forEach((criteria) => {
  152. criteriaSelectOptions.push(`<option value="${criteria.id}">${criteria.name}</option>`);
  153. });
  154. });
  155. });
  156. criteriaSelect.innerHTML = criteriaSelectOptions.join();
  157. });
  158. @stop