Nessuna descrizione

new-activity-create.blade.php 9.0KB

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