No Description

rubrics_new.blade.php 69KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if(Auth::user()->role==1)
  4. @include('local.managers.admins._new_navigation')
  5. @elseif(Auth::user()->role==2)
  6. @include('local.managers.sCoords._new_navigation')
  7. @elseif(Auth::user()->role==3)
  8. @include('local.managers.pCoords._new_navigation')
  9. @elseif(Auth::user()->role==4)
  10. @include('local.professors._navigation')
  11. @endif
  12. @stop
  13. @section('main')
  14. <!-- Update Rubric Modal -->
  15. <div class="modal fade" id="modal-confirm-update">
  16. <div class="modal-dialog modal-sm">
  17. <div class="modal-content">
  18. <div class="modal-header">
  19. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  20. <h4 class="modal-title">Update Rubric</h4>
  21. </div>
  22. <div class="modal-body">
  23. <p>Speak to any coordinators and/or professors in your School or
  24. Program that may be affected when you update this rubric. <strong>Professors
  25. that have already used this rubric will keep a copy of it as
  26. they used it, not an updated one.</strong></p>
  27. <p>Do you want to update this rubric?</p>
  28. </div>
  29. <div class="modal-footer">
  30. <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
  31. <button id="button-update-rubric" class="btn btn-primary save">Update</button>
  32. </div>
  33. </div><!-- /.modal-content -->
  34. </div><!-- /.modal-dialog -->
  35. </div><!-- /.modal -->
  36. <!-- Delete Rubric Modal -->
  37. <div class="modal fade" id="modal-confirm-delete">
  38. <div class="modal-dialog modal-sm">
  39. <div class="modal-content">
  40. <div class="modal-header">
  41. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  42. <h4 class="modal-title">Delete Rubric</h4>
  43. </div>
  44. <div class="modal-body">
  45. <p>Please note: By deleting this rubric, it will no longer be available
  46. to your school's or program's professors. However, professors that
  47. have already used it will keep a copy in their activities. Speak to
  48. any coordinators and/or professors in your School or Program that may be affected.</p>
  49. <p>Are you sure you want to delete this rubric?</p>
  50. </div>
  51. <div class="modal-footer">
  52. <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
  53. <button id="button-delete-rubric" class="btn btn-primary">Delete</button>
  54. </div>
  55. </div><!-- /.modal-content -->
  56. </div><!-- /.modal-dialog -->
  57. </div><!-- /.modal -->
  58. <div class="row">
  59. <div class="col-md-12">
  60. <div class="panel panel-default ">
  61. <div class="panel-heading">
  62. <span class="glyphicon glyphicon-triangle-bottom"></span>
  63. General Information
  64. </div>
  65. <div class="panel-body">
  66. <form>
  67. <div class="form-group">
  68. <label>Select a template, or create your own rubric</label>
  69. <select id="select-template" class="form-control selectpicker" data-live-search='true' data-live-search='true'>
  70. <option data-template-id="0">Custom</option>
  71. @foreach ($templates_dentro as $template)
  72. @if($template->school_id==NULL && $template->program_id==NULL)
  73. <option
  74. data-template-id="{{ $template->id }}"
  75. data-template-program-id="{{ $template->program_id }}"
  76. data-admin="1"
  77. >
  78. {{{ $template->name }}}
  79. </option>
  80. @else
  81. <option
  82. data-template-id="{{ $template->id }}"
  83. data-template-program-id="{{ $template->program_id }}"
  84. >
  85. {{{ $template->name }}}
  86. </option>
  87. @endif
  88. @endforeach
  89. @foreach ($templates_fuera as $template)
  90. @if($template->school_id==NULL && $template->program_id==NULL)
  91. <option
  92. data-template-id="{{ $template->id }}"
  93. data-template-program-id="{{ $template->program_id }}"
  94. data-admin="1"
  95. data-unmatch-criteria="1"
  96. >
  97. ## {{{ $template->name }}}
  98. </option>
  99. @else
  100. <option
  101. data-template-id="{{ $template->id }}"
  102. data-template-program-id="{{ $template->program_id }}"
  103. data-unmatch-criteria="1"
  104. >
  105. ## {{{ $template->name }}}
  106. </option>
  107. @endif
  108. @endforeach
  109. </select>
  110. <!--
  111. <span style="color: red;">Rubrics with "##" at the beginning contain criteria that are not associated with your program or school. You will not be able to use them until your criteria is matched with your program or school.
  112. </span>
  113. -->
  114. </div>
  115. <!-- If user is admin s/he can pick which schools can view the rubric -->
  116. @if(Auth::user()->role==1)
  117. <div class="form-group">
  118. <label>Select the School this rubric will be visible from</label>
  119. <select id="select-school" class="form-control selectpicker" data-live-search='true' data-live-search="true">
  120. <option data-school-id="0">All</option>
  121. @foreach ($schools as $school)
  122. <option data-school-id="{{ $school->id }}">
  123. {{ $school->name }}
  124. </option>
  125. @endforeach
  126. </select>
  127. </div>
  128. @endif
  129. <!-- If user is admin or school coordinator, s/he can pick which programs -->
  130. @if(Auth::user()->role==1 || Auth::user()->role==2 || Auth::user()->role==3)
  131. <div class="form-group">
  132. <label>Select the Program this rubric belongs to</label>
  133. <select id="select-program" class="form-control selectpicker" data-live-search='true'>
  134. @if(Auth::user()->role != 3)
  135. <option data-program-id="0">All</option>
  136. @endif
  137. @foreach ($programs as $program)
  138. <option
  139. data-program-id="{{ $program->id }}"
  140. data-program-program-id="{{ $program->program_id }}"
  141. >
  142. {{ $program->name }}
  143. </option>
  144. @endforeach
  145. </select>
  146. </div>
  147. @endif
  148. </form>
  149. <label for="">Select the lower bound for passing criteria</label>
  150. <form class="form-inline">
  151. <div class="form-group">
  152. <!-- Select percentage. If there is a rubric, select the saved value -->
  153. <select id="expected_percentage" class="form-control selectpicker" data-live-search='true'>
  154. @for($i = 50; $i <= 100; $i++)
  155. @if($i==70)
  156. <option selected="selected" value="{{ $i }}">{{ $i }}</option>
  157. @else
  158. <option value="{{ $i }}">{{ $i }}</option>
  159. @endif
  160. @endfor
  161. </select>
  162. % of all students must score at least
  163. <!-- Select points. If there is a rubric, select the saved value -->
  164. <select id="expected_points" class="form-control selectpicker" data-live-search='true'>
  165. @for($i = 0; $i <= 8; $i++)
  166. @if($i==5)
  167. <option selected="selected" value="{{ $i }}">{{ $i }}</option>
  168. @else
  169. <option value="{{ $i }}">{{ $i }}</option>
  170. @endif
  171. @endfor
  172. </select>
  173. point(s) in a criterion for it to pass.
  174. </div>
  175. </form>
  176. <br>
  177. <form>
  178. <div class="form-group">
  179. <label>Select the Maximum Score</label>
  180. <select id="max_score" class="form-control selectpicker" data-live-search='true'>
  181. @for($i = 1; $i <= 100; $i++)
  182. @if($i==8)
  183. <option selected="selected" value="{{ $i }}">{{ $i }}</option>
  184. @else
  185. <option value="{{ $i }}">{{ $i }}</option>
  186. @endif
  187. @endfor
  188. </select>
  189. </div>
  190. <div class="form-group">
  191. <label>Select the Type of Rubric</label>
  192. <select id="number_of_scales" class="form-control selectpicker" data-live-search='true' >
  193. @for($i = 1; $i <= 20; $i++)
  194. @if(8%$i == 0)
  195. @if($i==1)
  196. <option value="{{ $i }}">Cuantitative Rubric</option>
  197. @elseif($i==4)
  198. <option selected="selected" value="{{ $i }}">{{ $i }}-Scale Rubric</option>
  199. @else
  200. <option value="{{ $i }}">{{ $i }}-Scale Rubric</option>
  201. @endif
  202. @endif
  203. @endfor
  204. </select>
  205. </div>
  206. </form>
  207. <br>
  208. <form>
  209. <div class="form-group">
  210. <label>Select Status (you can change this later)</label>
  211. <div class="radio">
  212. <label>
  213. <input type="radio" name="is_visible" id="is_visible0" value="0" checked>
  214. This rubric is <strong>not complete</strong> yet and will not be available to professors.
  215. </label>
  216. </div>
  217. <div class="radio">
  218. <label>
  219. <input type="radio" name="is_visible" id="is_visible1" value="1">
  220. This rubric is <strong>complete</strong> and will be available to professors.
  221. </label>
  222. </div>
  223. </div>
  224. </form>
  225. <div>
  226. <p class="small">Note: You can hide or show this section by clicking on its heading. You may want to hide it to have more space. </p>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="panel panel-default">
  231. <div class="panel-heading panel-annual-plans">
  232. <span class="glyphicon glyphicon-triangle-bottom"></span>
  233. Import Criteria From Annual Plans
  234. </div>
  235. <div class="panel-body">
  236. <form>
  237. <div class="form-group">
  238. <label>Select Annual Plan to Import From</label>
  239. <select id="select-annual-plans" class="form-control selectpicker" onchange="fetchSemesters(this)" data-live-search='true' data-live-search='true'>
  240. <option value = '0'>Nothing Selected</option>
  241. @foreach($annual_plans as $annual_plan)
  242. <option value = "{{$annual_plan->annual_plan_id}}">Annual Plan for {{$annual_plan->program_name}} on {{$annual_plan->academic_year}}</option>
  243. @endforeach
  244. </select>
  245. </div>
  246. <!-- If user is admin s/he can pick which schools can view the rubric -->
  247. </form>
  248. <label for="">Select a Semester</label>
  249. <form >
  250. <div class="form-group">
  251. <!-- Select percentage. If there is a rubric, select the saved value -->
  252. <select id="select-semester-plans" class="form-control selectpicker" onchange = "fetchCourses('#select-annual-plans', '#select-semester-plans')" data-live-search='true'>
  253. </select>
  254. </div>
  255. </form>
  256. <br>
  257. <form>
  258. <div class="form-group">
  259. <label>Select Course</label>
  260. <select id="select-courses-plans" class="form-control selectpicker" onchange = " fetchCriteriaFromPlan('#select-courses-plans','#select-annual-plans', '#max_score', '#number_of_scales');" data-live-search='true'>
  261. </select>
  262. </div>
  263. </form>
  264. <form>
  265. <div class="form-group">
  266. <label>Select Criteria</label>
  267. <select id="select-criteria-plans" class="form-control selectpicker" onchange = "" data-live-search='true'>
  268. </select>
  269. </div>
  270. </form>
  271. <div class="text-center">
  272. <div class="btn-group" role="group" aria-label="...">
  273. <button id="button-add-criterion-plan" onclick = 'putToTemplateSingle("#select-criteria-plans")'class="btn btn-md btn-primary add-criterion-plan">
  274. <span class="glyphicon glyphicon-plus"></span>
  275. Add Criterion
  276. </button>
  277. <button id="button-add-all-criterion-plan" onclick = 'putToTemplateMultiple("#select-criteria-plans")'class="btn btn-md btn-primary add-criterion-plan">
  278. <span class="glyphicon glyphicon-plus"></span>
  279. Add All Criterion From Course
  280. </button>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. <div class="well">
  286. <form>
  287. <div class="form-group">
  288. <label>Select a Learning Outcome</label>
  289. <select id="select-outcome" class="form-control selectpicker" data-live-search='true' >
  290. @foreach ($outcomes as $outcome)
  291. <option data-outcome-id="{{ $outcome->id }}">{{ $outcome->name }}</option>
  292. @endforeach
  293. </select>
  294. </div>
  295. <div class="form-group">
  296. <label>Select an Objective</label>
  297. <select id="select-objective" class="form-control selectpicker" data-live-search='true' >
  298. </select>
  299. </div>
  300. @if(Auth::user()->role != '1')
  301. <label>Filter Criteria</label>
  302. <div class="form-group">
  303. <label class="radio-inline">
  304. <input type="radio" checked name="criteria-filter" id="criteria-all" value="all"> All Criteria
  305. </label>
  306. <label class="radio-inline">
  307. <input type="radio" name="criteria-filter" id="criteria-school" value="school"> Criteria from my School
  308. </label>
  309. @if(Auth::user()->role == '3')
  310. <label class="radio-inline">
  311. <input type="radio" name="criteria-filter" id="criteria-program" value="program"> Criteria from my Program(s)
  312. </label>
  313. @endif
  314. </div>
  315. @endif
  316. <div class="form-group">
  317. <label>Select a Criterion</label><span id="updated-text" class="text-success small"> updated</span>
  318. <select id="select-criterion" class="form-control selectpicker" data-live-search='true'>
  319. </select>
  320. </div>
  321. <button id="button-add-criterion" class="btn btn-md btn-primary center-block"> <span class="glyphicon glyphicon-plus"></span> Add Criterion to Rubric</button>
  322. </form>
  323. </div>
  324. </div>
  325. </div>
  326. <div id="rubric-container" class="row">
  327. <div class="col-md-12">
  328. <table class="table table-striped table-condensed" style="table-layout: fixed">
  329. <thead id="theHead"><tr><th colspan="7 "><input id="rubric-name" type="text" class="form-control input-lg" placeholder="Rubric Name"></th></tr></thead>
  330. <thead id = "theScaleTitles">
  331. </thead>
  332. <thead>
  333. <tr id ="criterion-header">
  334. <th></th>
  335. <th></th>
  336. </tr>
  337. </thead>
  338. <tbody id = "allCriteria">
  339. </tbody>
  340. </table>
  341. <div id="copyright-info">
  342. <hr>
  343. <p class="small"><strong>Copyright</strong></p>
  344. <ul id="copyright-list" class="list-unstyled small">
  345. </ul>
  346. <hr>
  347. </div>
  348. <div class="text-center">
  349. <div class="btn-group" role="group" aria-label="...">
  350. <button id="button-create-rubric" class="btn btn-lg btn-primary save">
  351. <span class="glyphicon glyphicon-floppy-disk"></span>
  352. Create
  353. </button>
  354. <button id="button-confirm-update-rubric" data-toggle="modal" data-target="#modal-confirm-update" class="btn btn-lg btn-primary">
  355. <span class="glyphicon glyphicon-pencil"></span>
  356. Update
  357. </button>
  358. <button id="button-confirm-delete-rubric" data-toggle="modal" data-target="#modal-confirm-delete" class="btn btn-lg btn-primary">
  359. <span class="glyphicon glyphicon-remove"></span>
  360. Delete
  361. </button>
  362. <button id="button-print-rubric" class="btn btn-lg btn-primary"><span class="glyphicon glyphicon-print"></span> Print <span class="small">(saved version)</span></button>
  363. <button id = "button-get-criteria-objectives" class = "btn btn-lg btn-primary" onclick = 'fetchObjectivesForTemplate("#allCriteria")'><span class='glyphicon glyphicon-eye-open'></span> View Objectives</button>
  364. </div>
  365. </div>
  366. </div>
  367. </div>
  368. <div class="modal fade" id="rubric-modal">
  369. <div class="modal-dialog modal-md">
  370. <div class="modal-content">
  371. <div class="modal-header">
  372. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  373. <h4 class="modal-title text-center" id ="modal-title-rubric">You are adding criteria to your program</h4>
  374. </div>
  375. <div class="modal-body" id ="modal-body-rubric">
  376. </div>
  377. <div class="modal-footer">
  378. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  379. <button type="button" class="btn btn-primary" id ="saveButton" data-button-id = '' value="Save" type="button" onclick = "saveTemplate()" >Save</button>
  380. </div>
  381. </div><!-- /.modal-content -->
  382. </div><!-- /.modal-dialog -->
  383. </div>
  384. <div class="modal fade" id="objectives-crit-modal">
  385. <div class="modal-dialog modal-md">
  386. <div class="modal-content">
  387. <div class="modal-header">
  388. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  389. <h4 class="modal-title text-center" id ="modal-title-rubric">These are the objectives in each Criterion in this Rubric</h4>
  390. </div>
  391. <div class="modal-body" id ="objectives-crit-modal-body">
  392. </div>
  393. <div class="modal-footer">
  394. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  395. </div>
  396. </div><!-- /.modal-content -->
  397. </div><!-- /.modal-dialog -->
  398. </div>
  399. <script>
  400. </script>
  401. @stop
  402. @section('included-js')
  403. <!-- jQuery Sortable Tables -->
  404. <script>
  405. function putToTemplateSingle(select){
  406. addCriterion(select);
  407. }
  408. function putToTemplateMultiple(select){
  409. options = $(select).children('option');
  410. $.each(options, function(ind, opt){
  411. $(select).val($(opt).data('criterion-id'))
  412. $('.selectpicker').selectpicker('refresh');
  413. putToTemplateSingle(select);
  414. })
  415. }
  416. function fetchSemesters(select){
  417. $.post("{{URL::action('AnnualPlansController@fetchSemestersFromPlan')}}",
  418. {
  419. annual_plan_id:$(select).val()
  420. },
  421. function(semesters){
  422. //console.log(semesters);
  423. options_for_semesters = makeOptionsForSemesters(semesters);
  424. $("#select-semester-plans").html(options_for_semesters);
  425. $('.selectpicker').selectpicker('refresh');
  426. fetchCourses('#select-annual-plans', '#select-semester-plans')
  427. }
  428. )
  429. }
  430. function makeOptionsForSemesters(semesters){
  431. options = '';
  432. $.each(semesters, function(ind, semesters){
  433. options += "<option value = '"+semesters.id+"'>"+semesters.name+" ("+semesters.code+")</option>";
  434. })
  435. return options;
  436. }
  437. function fetchCourses(annual_plan, semesters){
  438. annual_plan_id= $(annual_plan).val(),
  439. semester_id= $(semesters).val()
  440. $.post(
  441. "{{URL::action('AnnualPlansController@fetchCoursesFromPlanForTemplate')}}",
  442. {
  443. annual_plan_id:$(annual_plan).val(),
  444. semester_id:$(semesters).val()
  445. },
  446. function(courses){
  447. //console.log(courses);
  448. options = makeOptionsForCourses(courses);
  449. $("#select-courses-plans").html(options);
  450. $('.selectpicker').selectpicker('refresh');
  451. fetchCriteriaFromPlan("#select-courses-plans","#select-annual-plans", '#max_score', '#number_of_scales');
  452. }
  453. )
  454. }
  455. function makeOptionsForCourses(courses){
  456. options = '';
  457. $.each(courses, function(ind, courses){
  458. options += "<option value= '"+courses.id+"'>"+courses.code+"["+courses.number+"] "+courses.name+"</option>";
  459. })
  460. return options;
  461. }
  462. function fetchCriteriaFromPlan(courses, annual_plan, max_score, number_of_scales){
  463. $.post(
  464. "{{URL::action('AnnualPlansController@fetchCriteriaFromPlan')}}",
  465. {
  466. course_id: $(courses).val(),
  467. annual_plan:$(annual_plan).val(),
  468. max_score:$(max_score).val(),
  469. number_of_scales:$(number_of_scales).val()
  470. },
  471. function(criteria){
  472. //console.log(criteria);
  473. options_criteria = makeOptionsForCriteria(criteria)
  474. $('#select-criteria-plans').html(options);
  475. $('.selectpicker').selectpicker('refresh');
  476. //if options is empty, disable add button
  477. if(options == ''){
  478. $('.add-criterion-plan').prop('disabled',true)
  479. }
  480. //if options is empty, disable add button
  481. else{
  482. $('.add-criterion-plan').prop('disabled',false)
  483. }
  484. }
  485. )
  486. }
  487. function makeOptionsForCriteria(criteria){
  488. options = '';
  489. $.each(criteria, function (ind, cri){
  490. options +='<option value = "'+cri.id+'" data-criterion-id ="'+cri.id+'">'+cri.name+'</option>';
  491. })
  492. return options;
  493. }
  494. function fetchObjectivesForTemplate(tbody){
  495. allCriteria = [];
  496. $(tbody).children('tr').each(function (index){
  497. allCriteria.push($(this).data('criterion-id'));
  498. })
  499. program_id = $("#select-program").val();
  500. $.post(
  501. "{{URL::action('TemplatesController@fetchObjectivesForTemplate')}}",
  502. {
  503. allCriteria:allCriteria,
  504. program_id:program_id
  505. },
  506. function(crit){
  507. modal_name = '#objectives-crit-modal';
  508. $(modal_name+'-body').html(' ');
  509. ol_crit = $("<ol>")
  510. $(modal_name+'-body').append(ol_crit);
  511. $.each(crit, function(index, cri){
  512. li = $("<li>").html("<strong>"+cri.name+"</strong>");
  513. ul_for_ob = $("<ul>");
  514. $.each(cri.all_objectives, function(ind, obj){
  515. li2 = $("<li>").html(obj.text)
  516. ul_for_ob.append(li2);
  517. })
  518. li.append(ul_for_ob);
  519. ol_crit.append(li);
  520. })
  521. $(modal_name).modal('show');
  522. }
  523. )
  524. }
  525. options_for_select = '';
  526. function fetchOutcomes(annual_plan_id){
  527. $.post(
  528. "{{URL::action('AnnualPlansController@fetchOutcomesFromPlan')}}",
  529. {
  530. annual_plan_id:annual_plan_id
  531. },
  532. function(outcomes){
  533. //console.log(outcomes);
  534. options_for_select = makeOptionsForOutcomes(outcomes);
  535. $("#select-outcomes-plans").html(options_for_select);
  536. $('.selectpicker').selectpicker('refresh');
  537. $("#select-outcomes-plans").trigger('change');
  538. }
  539. );
  540. }
  541. function fetchObjectives(select_outcome){
  542. //console.log($(select_outcome).find('option:selected').html())
  543. option_selected = $(select_outcome).find('option:selected');
  544. //console.log($(select_outcome).find('option:selected').data('objectives'))
  545. //console.log($(select_outcome).val())
  546. //console.log(option_selected.val())
  547. $.post(
  548. "{{URL::action('AnnualPlansController@fetchObjectivesFromPlan')}}",
  549. {
  550. program_id: option_selected.data('program-id'),
  551. typ_semester_outcome_id: option_selected.data('typ-semester-outcome-id'),
  552. semester_id:option_selected.data('semester-id'),
  553. outcome_id: $(select_outcome).val()
  554. },
  555. function(objectives){
  556. options_for_objective = makeOptionsForObjectives(objectives)
  557. }
  558. )
  559. }
  560. function makeOptionsForObjectives(objectives){
  561. //console.log(objectives);
  562. option_selected = '';
  563. }
  564. function makeOptionsForOutcomes(outcomes){
  565. options_for_select = '<optgroup label ="First Semester">';
  566. semester_id = outcomes[0].semester_id
  567. $.each(outcomes, function(ind, out){
  568. if(semester_id != out.semester_id){
  569. semester_id = out.semester_id
  570. options_for_select += '<optgroup label ="Second Semester">';
  571. }
  572. options_for_select +="<option value= '"+out.id+"' data-typ-semester-outcome-id ='"+out.typ_semester_outcome_id+"' data-program-id= '"+out.program_id+"' data-semester-id = '"+out.semester_id+"'>"+out.name+"</option>";
  573. });
  574. return options_for_select;
  575. }
  576. function saveTemplate(){
  577. //Prevent page refresh
  578. var criterionObject = new Object();
  579. var criteriaArray = new Array();
  580. var criteria = [];
  581. var titles = [];
  582. var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
  583. var max = parseInt($('#max_score').find(':selected').val());
  584. // For each criterion in the rubric, get its value and put it into an array
  585. $('tbody tr').each(function( index )
  586. {
  587. criteria.push($(this).data('criterion-id'));
  588. });
  589. $('.editable').each(function(index){
  590. titles.push($(this).text());
  591. })
  592. button_id = $("#saveButton").data('button-id');
  593. //console.log('school', $('#select-school').find(':selected').data('school-id') );
  594. //console.log('program', $('#select-program').find(':selected').data('program-id') );
  595. if(button_id=='button-create-rubric')
  596. {
  597. // Create
  598. $.post
  599. (
  600. "{{ URL::to('saveTemplate') }}",
  601. {
  602. name: $('#rubric-name').val(),
  603. school_id: $('#select-school').find(':selected').data('school-id'),
  604. program_id: $('#select-program').find(':selected').data('program-id'),
  605. expected_percentage: $('#expected_percentage').find(':selected').val(),
  606. expected_points: $('#expected_points').find(':selected').val(),
  607. is_visible: $('input[name=is_visible]:checked').val(),
  608. criteria : criteria,
  609. //scales: scales,
  610. max_score : max,
  611. /*copyright : copyright,
  612. notes :notes*/
  613. titles: titles
  614. },
  615. function(data)
  616. {
  617. location.reload(true);
  618. }
  619. );
  620. }
  621. else
  622. {
  623. //console.log('school', $('#select-school').find(':selected').data('school-id') );
  624. //console.log('program', $('#select-program').find(':selected').data('program-id') );
  625. // Update database
  626. $.post
  627. (
  628. "{{ URL::to('updateTemplate') }}",
  629. {
  630. id: $('#select-template').find(':selected').data('template-id'),
  631. name: $('#rubric-name').val(),
  632. school_id: $('#select-school').find(':selected').data('school-id'),
  633. program_id: $('#select-program').find(':selected').data('program-id'),
  634. expected_percentage: $('#expected_percentage').find(':selected').val(),
  635. expected_points: $('#expected_points').find(':selected').val(),
  636. is_visible: $('input[name=is_visible]:checked').val(),
  637. criteria : criteria,
  638. //scales: scales,
  639. max_score : max,
  640. /*copyright : copyright,
  641. notes :notes*/
  642. titles: titles
  643. },
  644. function(data)
  645. {
  646. location.reload(true);
  647. }
  648. );
  649. }
  650. }
  651. // Add a new criterion to the rubric
  652. function addCriterion(select)
  653. {
  654. // Show the rubric container
  655. if(!$('tbody').children().length)
  656. {
  657. $('#rubric-container').show();
  658. }
  659. // Get the selected criterion's id
  660. var id= parseInt($(select).find(':selected').data('criterion-id'));
  661. var program_ids = $(select).find(':selected').data('program-ids');
  662. //var objectives = $(select).find(':selected').data('assoc-objectives');
  663. // Check for duplicates
  664. var duplicates=false;
  665. numberOfScale = $('#number_of_scales').find(':selected').val();
  666. $('tbody tr').each(function()
  667. {
  668. if ($(this).data('criterion-id') == id)
  669. {
  670. duplicates=true;
  671. }
  672. });
  673. // If there are any, display an error
  674. if(duplicates)
  675. {
  676. $('#js-error-row').show();
  677. $('#js-error-row').find('#error-message').text('Error: The selected criterion was already added.');
  678. return;
  679. }
  680. // Otherwise, hide the error container
  681. else
  682. {
  683. $('#js-error-row').hide();
  684. }
  685. // Fetch information of the criterion selected
  686. $.post
  687. (
  688. "{{ URL::route('fetchCriterionWithTemplate') }}",
  689. { id: id,
  690. },
  691. function(data)
  692. {
  693. // Append the fetched data
  694. copyright = null;
  695. notes = null;
  696. if(data.criterion.copyright){
  697. copyright = data.criterion.copyright;
  698. }
  699. if(data.criterion.notes){
  700. notes = data.criterion.notes;
  701. }
  702. //objectives = JSON.stringify(objectives);
  703. var str ='<tr data-criterion-name ="'+data.criterion.name+'" data-program-ids = "['+program_ids+']" data-criterion-id="'+data.criterion.id+'" data-criterion-copyright="'+copyright+'" data-criterion-notes="'+notes+'" data-outcomes = "'+data.outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
  704. // console.log(str);
  705. var subcriteria = '';
  706. if(data.criterion.subcriteria){
  707. var subcriteria_array = JSON.parse(data.criterion.subcriteria);
  708. subcriteria = '<ul class="subcriteria list-unstyled">';
  709. subcriteria_array.forEach(function (value) {
  710. subcriteria += '<li>'+value+'</li>';
  711. });
  712. subcriteria += '</ul>';
  713. }
  714. if(notes)
  715. {
  716. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+notes+'">'+data.criterion.name+'</em></span><sup></sup>'+subcriteria+'</td>';
  717. }
  718. else
  719. {
  720. str+='<span>'+data.criterion.name+'</span><sup></sup>'+subcriteria+'</td>';
  721. }
  722. numberOfScale = $('#number_of_scales').find(':selected').val();
  723. for(i=0; i<numberOfScale; i++){
  724. str+='<td>'+data.scales[i].description+'</td>';
  725. }
  726. str+= '<td>'+data.outcomes+'</td>'
  727. str +='<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
  728. //console.log(str);
  729. $('table tbody').append(str);
  730. // Build copyright list
  731. buildCopyrightList();
  732. // Enable X-Edtable on this new row
  733. $('.editable').editable({
  734. unsavedclass: null,
  735. rows: 4
  736. });
  737. // Turn on tooltips again (because content is dynamic)
  738. $('[data-toggle="tooltip"]').tooltip();
  739. // Sortable rows
  740. $('.table').sortable({
  741. handle: 'span.glyphicon.glyphicon-move',
  742. containerSelector: 'table',
  743. itemPath: '> tbody',
  744. itemSelector: 'tr',
  745. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  746. });
  747. },
  748. 'json',
  749. );
  750. }
  751. // Build list from copyright info in rubric
  752. function buildCopyrightList()
  753. {
  754. // Empty the copyright list
  755. $('#copyright-list').empty();
  756. $('tbody tr').each(function( index )
  757. {
  758. var criterion = $(this);
  759. // If there's copyright info
  760. if(criterion.data('criterion-copyright')!=null){
  761. var copyright = criterion.data('criterion-copyright');
  762. if($('#copyright-list li').length>0)
  763. {
  764. var found = false;
  765. $('#copyright-list li').each(function()
  766. {
  767. // If found, give the string its number
  768. if(copyright==$(this).find('span').text())
  769. {
  770. copyrightNumber = Number.parseInt($(this).find('sup').text());
  771. //console.log('a: '+copyrightNumber);
  772. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  773. found =true;
  774. //to break
  775. return false;
  776. }
  777. });
  778. // Otherwise, give it the next number and append a new item to the
  779. // list
  780. if(!found)
  781. {
  782. var copyrightNumber = $('#copyright-list li').length+1;
  783. //console.log('b: '+copyrightNumber);
  784. //console.log(criterion.children('td:nth-child(2)').find('sup').length);
  785. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  786. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  787. }
  788. }
  789. else
  790. {
  791. criterion.children('td:nth-child(2)').find('sup').text('1');
  792. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  793. }
  794. }
  795. });
  796. if($('#copyright-info li').length>0)
  797. {
  798. $('#copyright-info').show();
  799. }
  800. else
  801. {
  802. $('#copyright-info').hide();
  803. }
  804. }
  805. </script>
  806. <!-- X-Editable js -->
  807. <script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
  808. <script src="{{app_path().'/scripts/rubric_scripts/scripts_for_annual_plan_export.js'}}"></script>
  809. @stop
  810. @section('javascript')
  811. $('#select-outcome').on('change',function(){
  812. fetchObjective(this);
  813. })
  814. // --------------------------------------------------------------------------
  815. // Functions
  816. // --------------------------------------------------------------------------
  817. function fetchObjective(outcome){
  818. $.post(
  819. "{{URL::route('fetchObjectivesForSelect')}}",
  820. {
  821. outcomeID:$(outcome).find(':selected').data('outcome-id'),
  822. },
  823. function(data){
  824. options = '';
  825. for(objective_index in data){
  826. options += '<option value = "'+data[objective_index].objective_id+'">'+data[objective_index].text+'</option>';
  827. }
  828. $('#select-objective').html(options);
  829. $('#select-objective').selectpicker('refresh');
  830. fetchCriteria($('#select-outcome'), $('#select-objective'));
  831. }, 'json',
  832. );
  833. }
  834. // Fetch criteria associated to a specific learning outcome
  835. function fetchCriteria(outcome, objective)
  836. {
  837. amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
  838. maximum = parseInt($('#max_score').find(":selected").val());
  839. $.post
  840. (
  841. "{{ URL::route('fetchCriteria') }}",
  842. {
  843. outcome_id: outcome.find(':selected').data('outcome-id'),
  844. objective_id: objective.find(':selected').val(),
  845. num_scales: amount_of_scales,
  846. maximum: maximum,
  847. filter: $('input[name=criteria-filter]:checked').val()
  848. },
  849. function(data)
  850. {
  851. $('#select-criterion').empty();
  852. //console.log(data);
  853. // Append criteria
  854. data.forEach( function (arrayItem)
  855. {
  856. objectives = JSON.stringify(arrayItem.objectives);
  857. $('#select-criterion')
  858. .append('<option data-criterion-id="'+arrayItem.id+'" data-program-ids = '+"'"+arrayItem.program_ids+"'"+' data-assoc-objectives= '+"'"+objectives+"'"+'>'+arrayItem.name+'</option>');
  859. });
  860. // If there are no criteria assigned to the selected outcome, disable the
  861. // input and the button used to add criteria.
  862. if(!$('#select-criterion').children().length)
  863. {
  864. $('#select-criterion').prop('disabled', true);
  865. $('#button-add-criterion').prop('disabled', true);
  866. }
  867. // Otherwise, enable both the input and the button
  868. else
  869. {
  870. $('#select-criterion').prop('disabled', false);
  871. $('#button-add-criterion').prop('disabled', false);
  872. }
  873. $('#updated-text').fadeIn('slow').fadeOut('slow');
  874. refreshSelects();
  875. }
  876. );
  877. }
  878. // Fetch single criterion
  879. function fetchCriterion(criterion)
  880. {
  881. $.post
  882. (
  883. "{{ URL::route('fetchCriterion') }}",
  884. { id: outcome.find(':selected').data('outcome-id')},
  885. function(data)
  886. {
  887. $('#select-criterion').empty();
  888. data.forEach( function (arrayItem)
  889. {
  890. $('#select-criterion')
  891. .append('<option data-criterion-id="'+arrayItem.id+'" >'+arrayItem.name+'</option>');
  892. });
  893. $('#select-criterion').append('<option data-criterion-id="0">Custom</option>');
  894. refreshSelects();
  895. }
  896. );
  897. }
  898. /* if(criterion.data('criterion-copyright')!=null)
  899. {
  900. var copyright = criterion.data('criterion-copyright');
  901. // If there is anything in the copyright list
  902. if($('#copyright-list li').length>0)
  903. {
  904. // Check copyright list for the same copyright text
  905. var found = false;
  906. $('#copyright-list li').each(function()
  907. {
  908. // If found, give the string its number
  909. if(copyright==$(this).find('span').text())
  910. {
  911. copyrightNumber = Number.parseInt($(this).find('sup').text());
  912. //console.log('a: '+copyrightNumber);
  913. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  914. found =true;
  915. //to break
  916. return false;
  917. }
  918. });
  919. // Otherwise, give it the next number and append a new item to the
  920. // list
  921. if(!found)
  922. {
  923. var copyrightNumber = $('#copyright-list li').length+1;
  924. //console.log('b: '+copyrightNumber);
  925. //console.log(criterion.children('td:nth-child(2)').find('sup').length);
  926. criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
  927. $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
  928. }
  929. }
  930. // Otherwise, give it number 1 and append it
  931. else
  932. {
  933. criterion.children('td:nth-child(2)').find('sup').text('1');
  934. $('#copyright-list').append('<li><sup>1 </sup><span>'+copyright+'<span></li>');
  935. }
  936. }
  937. });
  938. if($('#copyright-info li').length>0)
  939. {
  940. $('#copyright-info').show();
  941. }
  942. else
  943. {
  944. $('#copyright-info').hide();
  945. }
  946. }
  947. */
  948. function refreshSelects()
  949. {
  950. $('#select-template').selectpicker('refresh');
  951. $('#select-school').selectpicker('refresh');
  952. $('#select-program').selectpicker('refresh');
  953. $('#select-outcome').selectpicker('refresh');
  954. $('#select-criterion').selectpicker('refresh');
  955. $('#expected_percentage').selectpicker('refresh');
  956. $('#expected_points').selectpicker('refresh');
  957. $('#number_of_scales').selectpicker('refresh');
  958. $('#select-objective').selectpicker('refresh');
  959. }
  960. // Fetch programs associated to a specific school
  961. function fetchPrograms(school)
  962. {
  963. //console.log(school.find(':selected'));
  964. $.ajax({
  965. type: 'POST',
  966. url: "{{ URL::action('ProgramsController@fetch') }}",
  967. data: { id: school.find(':selected').data('school-id')},
  968. success: function(data)
  969. {
  970. $('#select-program').empty();
  971. $('#select-program').append('<option data-program-id="0">All</option>');
  972. data.forEach( function (program)
  973. {
  974. $('#select-program')
  975. .append('<option data-program-id="'+program.id+'" >'+program.name+'</option>');
  976. });
  977. },
  978. async:false
  979. });
  980. if($('#select-school').find(':selected').data('school-id')!=0)
  981. $('#select-program').prop('disabled', false);
  982. else
  983. $('#select-program').prop('disabled', true);
  984. refreshSelects();
  985. }
  986. // Load a template. This function is different from the one for professors
  987. function loadTemplate()
  988. {
  989. $.post
  990. (
  991. "{{ URL::to('loadTemplate') }}",
  992. { id: $('#select-template').find(':selected').data('template-id')},
  993. function(data)
  994. {
  995. // Show the container and empty all rows
  996. $('#rubric-container').show();
  997. $('tbody').empty();
  998. //Set the name of the rubric
  999. $('#rubric-name').val(data.template.name);
  1000. //console.log($('#select-school'));
  1001. // Set school id to 0, then to the saved value if it exists
  1002. $('#select-school option[data-school-id="0"]').prop('selected', true);
  1003. $('#select-school option[data-school-id="'+data.template.school_id+'"]').prop('selected', true);
  1004. console.log("name"+data.template.name);
  1005. console.log("school"+data.template.school_id);
  1006. console.log("name"+data.template.name);
  1007. // Fetch programs associated to that school
  1008. fetchPrograms($('#select-school'));
  1009. // fetchPrograms(data.template.school_id);
  1010. // Set program id to 0, then to the saved value if it exists
  1011. $('#select-program option[data-program-id="0"]').prop('selected', true);
  1012. $('#select-program option[data-program-id="'+data.template.program_id+'"]').prop('selected', true);
  1013. // Set expected values
  1014. // console.log(data.template.expected_percentage);
  1015. // console.log(data.template.expected_points);
  1016. // console.log(data.template.max_score);
  1017. $('#max_score').val(data.template.max_score);
  1018. $('#max_score').trigger("change");
  1019. $('#expected_percentage').val(data.template.expected_percentage);
  1020. $('#expected_points').val(data.template.expected_points);
  1021. $('#number_of_scales').val(data.template.num_scales);
  1022. refreshSelects();
  1023. changeTable();
  1024. // Set visibility
  1025. var is_visible = data.template.is_visible;
  1026. console.log("is_visible",is_visible);
  1027. if(is_visible==1)
  1028. {
  1029. console.log("entro?")
  1030. $('#is_visible0').prop('checked', false);
  1031. $('#is_visible1').prop('checked', true);
  1032. }
  1033. else
  1034. {
  1035. $('#is_visible0').prop('checked', true);
  1036. $('#is_visible1').prop('checked', false);
  1037. }
  1038. // Set the contents of the rubric
  1039. var temp_criterion = data.criterion;
  1040. // console.log(temp_criterion);
  1041. for(temp_c in temp_criterion){
  1042. current_criterion = temp_criterion[temp_c]
  1043. // console.log(current_criterion.program_ids);
  1044. objectives = JSON.stringify(current_criterion.objectives);
  1045. //var str = '<tr data-assoc-objectives= '+"'"+objectives+"'"+' data-program_ids = "'+current_criterion.program_ids+'" data-criterion-name = "'+current_criterion.name+'" data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'" data-outcomes = "'+temp_criterion[temp_c].outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
  1046. var str = "<tr data-program_ids = '"+current_criterion.program_ids+"' data-criterion-name = '"+current_criterion.name+"' data-criterion-id='"+temp_criterion[temp_c].criterion_id+"' data-criterion-copyright='"+temp_criterion[temp_c].copyright+"' data-criterion-notes='"+temp_criterion[temp_c].notes+"' data-outcomes = '"+temp_criterion[temp_c].outcomes+"'><th><span class='glyphicon glyphicon-move'></span></th><td>";
  1047. // console.log(str);
  1048. var subcriteria ='';
  1049. if(current_criterion.subcriteria){
  1050. var subcriteria_array = JSON.parse(current_criterion.subcriteria);
  1051. subcriteria = '<ul class="subcriteria list-unstyled">';
  1052. subcriteria_array.forEach(function (value) {
  1053. subcriteria += '<li>'+value+'</li>';
  1054. });
  1055. subcriteria += '</ul>';
  1056. }
  1057. if(current_criterion.notes)
  1058. {
  1059. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+current_criterion.notes+'">'+current_criterion.name+'</em></span><sup></sup>'+subcriteria;
  1060. }
  1061. else
  1062. {
  1063. str+='<span>'+current_criterion.name+'</span><sup></sup>'+subcriteria;
  1064. }
  1065. str+= '</td>';
  1066. for(scaleIndex in current_criterion.scales){
  1067. scale = current_criterion.scales[scaleIndex];
  1068. str+='<td>'+scale.description+'</td>';
  1069. }
  1070. str+= '<td>'+current_criterion.outcomes+'</td>'
  1071. str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  1072. // console.log(str);
  1073. $('table tbody').append(str);
  1074. // Enable X-Edtable on this new row
  1075. $('.editable').editable({
  1076. unsavedclass: null,
  1077. rows: 4
  1078. });
  1079. // Turn on tooltips again (because content is dynamic)
  1080. $('[data-toggle="tooltip"]').tooltip();
  1081. refreshSelects();
  1082. }
  1083. /*
  1084. var contents = JSON.parse(data.contents);
  1085. contents.forEach(function (data)
  1086. {
  1087. // Append the fetched data
  1088. var str ='<tr data-criterion-id="'+data.id+'" data-criterion-copyright="'+data.copyright+'" data-criterion-notes="'+data.notes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
  1089. var subcriteria = '';
  1090. if(data.subcriteria){
  1091. var subcriteria_array = data.subcriteria;
  1092. subcriteria = '<ul class="subcriteria list-unstyled">';
  1093. subcriteria_array.forEach(function (value) {
  1094. subcriteria += '<li>'+value+'</li>';
  1095. });
  1096. subcriteria += '</ul>';
  1097. }
  1098. if(data.notes)
  1099. {
  1100. str+='<span><em data-toggle="tooltip" data-placement="top" title="'+data.notes+'">'+data.name+'</em></span><sup></sup>'+subcriteria;
  1101. }
  1102. else
  1103. {
  1104. str+='<span>'+data.name+'</span><sup></sup>'+subcriteria;
  1105. }
  1106. str+='</td><td class="editable" data-type="textarea">'+data.description12+'</td>'
  1107. +'<td class="editable" data-type="textarea">'+data.description34+'</td>'
  1108. +'<td class="editable" data-type="textarea">'+data.description56+'</td>'
  1109. +'<td class="editable" data-type="textarea">'+data.description78+'</td>'
  1110. +'<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
  1111. $('table tbody').append(str);
  1112. // Build copyright list
  1113. buildCopyrightList();
  1114. // Enable X-Edtable on this new row
  1115. $('.editable').editable({
  1116. unsavedclass: null,
  1117. rows: 4
  1118. });
  1119. // Turn on tooltips again (because content is dynamic)
  1120. $('[data-toggle="tooltip"]').tooltip();
  1121. refreshSelects();
  1122. }); */
  1123. // Sortable rows
  1124. $('.table').sortable({
  1125. handle: 'span.glyphicon.glyphicon-move',
  1126. containerSelector: 'table',
  1127. itemPath: '> tbody',
  1128. itemSelector: 'tr',
  1129. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  1130. });
  1131. // Build Copyright List
  1132. buildCopyrightList();
  1133. $('.editable').each(function (index){
  1134. $(this).text(data.titles[index].text);
  1135. })
  1136. var selected = $('#select-template').find(':selected');
  1137. var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
  1138. var template_program = selected.data('template-program-id');
  1139. // console.log(selected.data('template-program-id'));
  1140. console.log("**"+programs.indexOf(selected.data('template-program-id').toString()));
  1141. if(
  1142. {{ Auth::user()->role }}==1
  1143. || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
  1144. || ({{ Auth::user()->role }}==3
  1145. && programs.indexOf(selected.data('template-program-id'))
  1146. && selected.data('admin')!=1
  1147. )
  1148. )
  1149. {
  1150. $('#button-confirm-delete-rubric').prop('disabled', false);
  1151. $('#button-confirm-update-rubric').prop('disabled', false);
  1152. }
  1153. else
  1154. {
  1155. // Disable update and edit
  1156. $('#button-confirm-delete-rubric').prop('disabled', true);
  1157. $('#button-confirm-update-rubric').prop('disabled', true);
  1158. }
  1159. // Enable print button
  1160. $('#button-print-rubric').prop('disabled', false);
  1161. fetchCriteria($('#select-outcome'), $('#select-objective'));
  1162. },
  1163. 'json',
  1164. );
  1165. }
  1166. // Checks whether the user wants to save a rubric with a name that already exists
  1167. function nameExists()
  1168. {
  1169. var duplicates = false;
  1170. $('#select-template option').each(function()
  1171. {
  1172. var optionName = $(this).text().trim();
  1173. if($('#rubric-name').val().trim()===optionName)
  1174. {
  1175. duplicates = true;
  1176. }
  1177. });
  1178. refreshSelects();
  1179. return duplicates;
  1180. }
  1181. //Enable disable program select
  1182. function toggleProgramSelect(school)
  1183. {
  1184. if(school.find(':selected').data('school-id') <1)
  1185. {
  1186. $('#select-program option[data-program-id="0"]').prop('selected', true);
  1187. $('#select-program').prop('disabled', true);
  1188. }
  1189. else
  1190. {
  1191. console.log(school);
  1192. fetchPrograms(school);
  1193. $('#select-program').prop('disabled', false);
  1194. }
  1195. refreshSelects();
  1196. }
  1197. fetchObjective($('#select-outcome'));
  1198. // --------------------------------------------------------------------------
  1199. // Events
  1200. // --------------------------------------------------------------------------
  1201. // Toggle visibility for accordion panels
  1202. $('.panel-heading').on('click', function()
  1203. {
  1204. if($(this).find('.glyphicon').hasClass('glyphicon-triangle-right'))
  1205. {
  1206. $(this).find('.glyphicon').removeClass('glyphicon-triangle-right');
  1207. $(this).find('.glyphicon').addClass('glyphicon-triangle-bottom');
  1208. }
  1209. else if($(this).find('.glyphicon').hasClass('glyphicon-triangle-bottom'))
  1210. {
  1211. $(this).find('.glyphicon').removeClass('glyphicon-triangle-bottom');
  1212. $(this).find('.glyphicon').addClass('glyphicon-triangle-right');
  1213. }
  1214. $(this).siblings('.panel-body').stop().slideToggle();
  1215. });
  1216. $('.panel-annual-plans').trigger('click');
  1217. $('.add-criterion-plan').prop('disabled',true)
  1218. // Fetch criteria everytime something changes
  1219. $('#select-objective').on('change', function(){
  1220. fetchCriteria($('#select-outcome'), $('#select-objective'));
  1221. })
  1222. $("#number_of_scales").on('change', function(){
  1223. fetchCriteria($('#select-outcome'), $('#select-objective'));
  1224. })
  1225. // When trying to change the template, ask the user to confirm and reset the
  1226. // rubric if s/he does
  1227. $('#select-template').on('change', function()
  1228. {
  1229. // If changing to custom template, reset
  1230. if($('#select-template').find(':selected').data('template-id')=='0')
  1231. {
  1232. $('#rubric-container').hide();
  1233. $('#rubric-name').val('');
  1234. $('tbody').empty();
  1235. // Disable delete, update and print buttons
  1236. $('#button-confirm-delete-rubric').prop('disabled', true);
  1237. $('#button-confirm-update-rubric').prop('disabled', true);
  1238. $('#button-print-rubric').prop('disabled', true);
  1239. }
  1240. // Otherwise, load the selected template
  1241. else
  1242. {
  1243. loadTemplate();
  1244. //If user is admin, or the templates id matches user's, or the template
  1245. // id's school matches user, allow editing
  1246. var selected = $('#select-template').find(':selected');
  1247. var programs = {{ json_encode(Auth::user()->programs->lists('id')) }};
  1248. var template_program = selected.data('template-program-id');
  1249. <!-- var dataset = selected.dataSet.templateProgramId; -->
  1250. // console.log("***"+({{ Auth::user()->role }}==3
  1251. // && programs.indexOf(selected.data('template-program-id'))
  1252. // && selected.data('admin')!=1
  1253. // )+programs+template_program+{{ json_encode(Auth::user()->programs->lists('id')) }});
  1254. if(
  1255. {{ Auth::user()->role }}==1
  1256. || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
  1257. || ({{ Auth::user()->role }}==3
  1258. && programs.indexOf(selected.data('template-program-id'))
  1259. && selected.data('admin')!=1
  1260. )
  1261. )
  1262. {
  1263. $('#button-confirm-delete-rubric').prop('disabled', false);
  1264. $('#button-confirm-update-rubric').prop('disabled', false);
  1265. }
  1266. else
  1267. {
  1268. // Disable update and edit
  1269. $('#button-confirm-delete-rubric').prop('disabled', true);
  1270. $('#button-confirm-update-rubric').prop('disabled', true);
  1271. }
  1272. if($('#select-template').find(':selected').data('unmatch-criteria')=='1')
  1273. {
  1274. $('#button-confirm-delete-rubric').prop('disabled', true);
  1275. $('#button-confirm-update-rubric').prop('disabled', true);
  1276. $('#button-create-rubric').prop('disabled', true);
  1277. }
  1278. else
  1279. {
  1280. $('#button-create-rubric').prop('disabled', false);
  1281. }
  1282. // Enable print button
  1283. $('#button-print-rubric').prop('disabled', false);
  1284. }
  1285. });
  1286. function changeTable(){
  1287. amount_of_scales = parseInt($('#number_of_scales').find(':selected').val());
  1288. counter2 = 0;
  1289. maximum = parseInt($('#max_score').find(":selected").val());
  1290. newScaleHeaders = '<th></th><th>Criterion</th>';
  1291. editableTitles = '<th></th><th></th>';
  1292. counter = 0;
  1293. division = maximum/amount_of_scales;
  1294. if(amount_of_scales==1){
  1295. newScaleHeaders+= "<th>Score (1 - "+maximum+")</th>";
  1296. editableTitles += "<th class = 'editable' data-type = 'textarea'>Click to edit Title </th>"
  1297. }
  1298. else if(maximum!= amount_of_scales){
  1299. while(counter <amount_of_scales){
  1300. minimumScore = 1+(counter*division);
  1301. maximumScore = (1+counter)*division;
  1302. newScaleHeaders+= "<th>Scale "+ (counter +1) + " ("+minimumScore+" - "+maximumScore+")</th>";
  1303. editableTitles+="<th class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
  1304. counter++;
  1305. }
  1306. }else{
  1307. while(counter <amount_of_scales){
  1308. newScaleHeaders+= "<th>Scale "+ (counter +1) + " </th>";
  1309. editableTitles+="<th class = 'editable' data-type = 'textarea'>Click to edit Title "+(counter+1)+"</th>"
  1310. counter++;
  1311. }
  1312. }
  1313. newScaleHeaders += '<th>Outcomes</th><th></th>';
  1314. editableTitles += '<th></th><th></th>';
  1315. $('#theScaleTitles').html(editableTitles);
  1316. $("#criterion-header").html(newScaleHeaders);
  1317. $('#allCriteria').html(' ');
  1318. }
  1319. // When a school changes, update its programs. If all is selected, disable
  1320. $('#select-school').on('change', function()
  1321. {
  1322. toggleProgramSelect($(this));
  1323. });
  1324. $('#max_score').on('change', function(){
  1325. var max = parseInt($('#max_score').find(':selected').val());
  1326. var stringToScales = "<option value= '1'>Cuantitative Rubric </option>";
  1327. selectedValue = 1;
  1328. valueBefore = 0;
  1329. for(i=2; i<=20; i++){
  1330. if(max%i==0){
  1331. stringToScales += "<option value= '"+i+"'>"+i+"-Scale Rubric</option>";
  1332. selectedValue = i - valueBefore;
  1333. valueBefore = i;
  1334. }
  1335. }
  1336. $('#number_of_scales').html(stringToScales);
  1337. $('#number_of_scales').selectpicker('refresh');
  1338. $('#number_of_scales').val(selectedValue);
  1339. $('#number_of_scales').selectpicker('refresh');
  1340. var expected_points = Math.floor(max *0.7);
  1341. var expected_points_html = '';
  1342. for(i=1; i<max; i++){
  1343. expected_points_html += '<option value="'+i+'"> '+i+'</option>';
  1344. }
  1345. $('#expected_points').html(expected_points_html);
  1346. refreshSelects();
  1347. $('#expected_points').val(expected_points);
  1348. refreshSelects();
  1349. changeTable();
  1350. fetchCriteria($('#select-outcome'), $('#select-objective'))
  1351. fetchCriteriaFromPlan('#select-courses-plans','#select-annual-plans', '#max_score', '#number_of_scales');
  1352. })
  1353. $('#number_of_scales').on('change', function(){
  1354. changeTable();
  1355. fetchCriteria($('#select-outcome'), $('#select-objective'))
  1356. fetchCriteriaFromPlan('#select-courses-plans','#select-annual-plans', '#max_score', '#number_of_scales');
  1357. $('#rubric-container').hide();
  1358. $('#rubric-name').val('');
  1359. $('tbody').empty();
  1360. })
  1361. // When a learning outcome changes, update its criteria
  1362. /*$('#select-outcome, input[name=criteria-filter]').on('change', function()
  1363. {
  1364. fetchCriteria($('#select-outcome'));
  1365. });
  1366. */
  1367. // When the add button is clicked
  1368. $('#button-add-criterion').on('click', function(e)
  1369. {
  1370. //Prevent page refresh
  1371. e.preventDefault();
  1372. //Add new criterion
  1373. addCriterion("#select-criterion");
  1374. });
  1375. // When the create or update buttons are clicked (.save)
  1376. $('.save').on('click', function(e)
  1377. {
  1378. //Prevent page refresh
  1379. e.preventDefault();
  1380. var emptyFields=false;
  1381. $('#allCriteria').children('td').each(function()
  1382. {
  1383. if (($(this).text() == "" || $(this).text() == "Empty") && !($(this).hasClass('nullable')) )
  1384. {
  1385. emptyFields=true;
  1386. }
  1387. });
  1388. // If any fields are empty, display error
  1389. if(emptyFields || $.trim($('#rubric-name').val())=='')
  1390. {
  1391. $('#js-error-row').show();
  1392. $('#js-error-row').find('#error-message').text('Error: Please fill all the fields. Make sure your rubric has a name and all scale scores are filled.');
  1393. return;
  1394. }
  1395. else
  1396. {
  1397. $('#js-error-row').hide();
  1398. }
  1399. // Check whether a rubric with the written name already exists
  1400. if($(this).attr('id')=='button-create-rubric' && nameExists())
  1401. {
  1402. $('#js-error-row').show();
  1403. $('#js-error-row').find('#error-message').text('Error: A template with that name already exists.');
  1404. return;
  1405. }
  1406. else
  1407. {
  1408. $('#js-error-row').hide();
  1409. }
  1410. /*
  1411. program_id = $('#select-program').find(':selected').data('program-id')
  1412. if(program_id == 0){
  1413. $('#modal-title-rubric').html("All criteria will be associated with this school's programs");
  1414. htmlString = "<h5>The following criteria and objectives will be matched with all programs</h5>"
  1415. htmlString += "<ol style='list-style-position: inside'>"
  1416. $('tbody tr').each(function( index )
  1417. {
  1418. objectives = $(this).data('assoc-objectives');
  1419. htmlString += "<li>" +$(this).data('criterion-name');
  1420. htmlString += "<br><h5>This criterion is associated with these objectives</h5>"
  1421. htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
  1422. for(index in objectives){
  1423. objective_string = objectives[index];
  1424. htmlString +="<li>"+objective_string+"</li>";
  1425. }
  1426. htmlString += "</ul>"
  1427. htmlString +="</li>"
  1428. htmlString+= "<br>";
  1429. });
  1430. htmlString +='</ol>';
  1431. $("#modal-body-rubric").html(htmlString);
  1432. }
  1433. else{
  1434. $('#modal-title-rubric').html('Some criteria will be associated with this program');
  1435. $('tbody tr').each(function( index )
  1436. {
  1437. htmlString = '';
  1438. console.log($(this));
  1439. if(typeof $(this).data('program_ids')!== 'undefined')
  1440. {
  1441. program_ids = $(this).data('program_ids');
  1442. console.log("ids"+program_ids);
  1443. console.log("ids"+$(this).data('program_ids'));
  1444. }
  1445. else if(typeof $(this).data('program-ids')!== 'undefined')
  1446. {
  1447. program_ids = $(this).data('program-ids')
  1448. console.log("Ids"+program_ids);
  1449. }
  1450. else
  1451. {
  1452. program_ids = [];
  1453. console.log(" "+program_ids);
  1454. }
  1455. console.log(program_ids);
  1456. // program_ids = $(this).data('program_ids')
  1457. if(!program_ids.indexOf(program_id) ){
  1458. title = "<h6>The following criteria and objectives will be matched with this program</h6>"
  1459. htmlString += "<ol style='list-style-position: inside'>"
  1460. objectives = $(this).data('assoc-objectives');
  1461. //objectives = objectives.split(',');
  1462. htmlString += "<li>" +$(this).data('criterion-name');
  1463. htmlString += "<br><h6>This criterion is associated with these objectives</h6>"
  1464. htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
  1465. for(index in objectives){
  1466. objective_string = objectives[index];
  1467. htmlString +="<li>"+objective_string+"</li>";
  1468. }
  1469. htmlString += "</ul>"
  1470. htmlString +="</li>"
  1471. htmlString+= "<br>";
  1472. }
  1473. if(htmlString != ''){
  1474. $("#modal-body-rubric").html(title);
  1475. $("#modal-body-rubric").append(htmlString);
  1476. }
  1477. });
  1478. }
  1479. $('#rubric-modal').modal('toggle');*/
  1480. $('#saveButton').data('button-id',$(this).attr('id'));
  1481. saveTemplate();
  1482. });
  1483. // When the confirm delete button is clicked
  1484. $('#button-delete-rubric').on('click', function(e)
  1485. {
  1486. $('#modal-confirm-delete').modal('hide');
  1487. // Delete from database
  1488. $.post
  1489. (
  1490. "{{ URL::to('deleteTemplate') }}",
  1491. {
  1492. id: $('#select-template').find(':selected').data('template-id')
  1493. },
  1494. function(data)
  1495. {
  1496. location.reload();
  1497. }
  1498. );
  1499. });
  1500. // Remove a criterion and hide the table if it was the only one
  1501. $('table').on('click', 'span.glyphicon-remove', function(e)
  1502. {
  1503. $(this).closest('tr').remove();
  1504. if(!$('tbody').children().length)
  1505. {
  1506. $('#rubric-container').hide();
  1507. }
  1508. buildCopyrightList();
  1509. });
  1510. // When print button is clicked, redirect to print page
  1511. $('#button-print-rubric').on('click', function(e)
  1512. {
  1513. e.preventDefault();
  1514. window.location = "printRubric/"+$('#select-template').find(':selected').data('template-id');
  1515. });
  1516. // --------------------------------------------------------------------------
  1517. // Page load
  1518. // --------------------------------------------------------------------------
  1519. $('#updated-text').hide();
  1520. // Enable/disable program selection depending on school selection if user is
  1521. // admin
  1522. if({{Auth::user()->role}}==1)
  1523. toggleProgramSelect($('#select-school'));
  1524. // Fetch criteria of first outcome
  1525. fetchCriteria($('#select-outcome'), $('#select-objective'));
  1526. changeTable();
  1527. // Hide table
  1528. $('#rubric-container').hide();
  1529. // Disable Update and Delete Buttons by default
  1530. $('#button-confirm-update-rubric').prop('disabled', true);
  1531. $('#button-confirm-delete-rubric').prop('disabled', true);
  1532. $('#button-print-rubric').prop('disabled', true);
  1533. // Sortable rows
  1534. $('.table').sortable({
  1535. handle: 'span.glyphicon.glyphicon-move',
  1536. containerSelector: 'table',
  1537. itemPath: '> tbody',
  1538. itemSelector: 'tr',
  1539. placeholder: '<tr class="placeholder"><th><span class="glyphicon glyphicon-arrow-right"></span></th></tr>'
  1540. });
  1541. @stop