1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051 |
- @extends('layouts.master')
-
- @section('navigation')
- @include('local.managers.pCoords._navigation')
- @stop
- @section('main')
-
- <div class="row">
- <div class="col-md-6">
- <!-- Form to add a new criterion -->
- <div class="panel panel-default panel-button">
- <div class="panel-heading">
- Create
- </div>
- <div class="panel-body">
- {{ Form::open(array('action' => 'CriteriaController@create')) }}
- <div id='outcomeGroup' data-value = "1">
- <div class="form-group col-md-11">
- <label>Associated Outcomes</label>
-
- {{ Form::select('outcome[]', $outcomes, reset($outcomes), ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")']) }}
- </div>
- </div>
- <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
- <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
- <span class='glyphicon glyphicon-plus'>
-
- </span>
- Add another Outcome
- </button>
- <div id='objectiveGroup' data-value = '1'>
- <div class="form-group">
- <label>Associated Objectives</label>
- <select id="objective_0" name="objective[]" class="form-control selectpicker">
- </select>
-
- </div>
- </div>
- <input type='hidden' name='counterObjective' id='counterObjective' value=1>
- <button id='button-add-objective' class='btn btn-md btn-secondary' onclick='addObjectiveTest()'>
- <span class='glyphicon glyphicon-plus'>
-
- </span>
- Add another Objective
- </button>
-
- <!-- Associated Program -->
- <div class="form-group">
- {{ Form::label('program_id', 'Associated Program') }}<br>
- <br>
-
-
- <input type = "hidden" id = "{{ $programs[0]->name }}" name="program_id[]" value="{{$programs[0]->id}}">
- <input type="checkbox" id="{{ $programs[0]->name }}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
- <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
-
-
- </div>
-
- <div class="form-group">
- {{ Form::label('name', 'Name') }}
- {{ Form::text('name', '', array('class' => 'form-control')) }}
- </div>
-
- <div class="form-group">
- {{ Form::label('subcriteria', 'Subcriteria') }}
- <p class="help-block"><strong>Manually add</strong> bullets or numbering.</p>
- {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'aria-labelledby'=>'subcriteria')) }}
- </div>
- <div class="form-group">
- {{ Form::label('maximum_score', 'Maximum Score') }}
- {{ Form::text('maximum_score', '1', array('class' => 'form-control', 'id'=>'maximum_score', 'oninput'=>'addOptions("Num_scale", "maximum_score", "Scales")')) }}
- </div>
- <div class="form-group">
- {{ Form::label('scales', 'Number of Scales') }}
- <select id="Num_scale" name="scales" class="form-control selectpicker" onchange='numberOfScales("Num_scale", "Scales")'>
-
- </select>
- </div>
- <div id='Scales' data-value="0">
-
- </div>
-
-
- <div class="form-group">
- {{ Form::label('copyright', 'Copyright') }}
- {{ Form::textarea('copyright', '', array('class' => 'form-control', 'rows'=>2, 'placeholder'=>'(optional)', 'aria-labelledby'=>'copyright')) }}
- </div>
-
- <div class="form-group">
- {{ Form::label('notes', 'Notes') }}
- {{ Form::textarea('notes', '', array('class' => 'form-control', 'rows'=>2, 'placeholder'=>'(optional)', 'aria-labelledby'=>'notes')) }}
- </div>
-
- {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
- {{ Form::close() }}
- </div>
- </div>
- </div>
-
- <div class="col-md-6">
- <div class="panel panel-default panel-button">
- <div class="panel-heading">
- Edit
- </div>
- <div class="panel-body">
- {{ Form::open(array('action' => 'CriteriaController@update')) }}
-
- <button class="btn btn-md btn-secondary filterButton">
- <span class="glyphicon glyphicon-plus">
- </span>
- Filters
- </button>
- <div class="filterSection">
- <div class="form-group">
- {{ Form::label('program_id2', 'Associated Program')}}
- <select id='select-program' class="form-control selectpicker" onchange='fetchAllCriterion("select-program", "assoc_outcomes_fetch")'>
-
- <option value='{{$programs[0]->id}}' data-subtext="{{$programs[0]->code}}">{{$programs[0]->name}}</option>
-
- </select>
- </div>
- <div class="form-group">
- <label>Associated Outcome</label>
- {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllCriterion("select-program", "assoc_outcomes_fetch")']) }}
-
- </div>
- </div>
-
- <div class="form-group">
- {{ Form::label('criterion_id', 'Criterion') }}
- <select id="select-criterion" name="id" class="form-control selectpicker" onchange='fetchCriterionForEditing()'>
- @foreach ($criteria as $criterion)
- <option value="{{ $criterion->id }}" data-subtext="
- @if($criterion->program)
- [{{ $criterion->program->name }}]
- @endif
- ">
- {{ $criterion->name }}
-
-
-
- </option>
- @endforeach
- </select>
- </div>
-
- <!-- Associated Outcome -->
- <div id='assocOutcomeGroup' data-value="1">
- <div class="form-group">
- <label>Associated Outcome</label>
- {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
-
- </div>
- </div>
- <button id='button-add-objective-assoc' class='btn btn-md btn-secondary' onclick='addAssocOutcome()'>
- <span class='glyphicon glyphicon-plus'>
-
- </span>
- Add another Outcome
- </button>
-
- <div id='assoc_objectiveGroup' data-value="1">
- <div class="form-group">
- <label>Associated Objectives</label>
- <select id="assoc_objective_0" name="assoc_objective[]" class="form-control selectpicker">
- <option value="0">No associated objectives</option>
- </select>
-
- </div>
- </div>
- <button id='button-add-outcome-assoc' class='btn btn-md btn-secondary' onclick='addAssocObjective()'>
- <span class='glyphicon glyphicon-plus'>
-
- </span>
- Add another Objective
- </button>
-
- <!-- Associated Program -->
- <div class="form-group">
-
- {{ Form::label('program_id2', 'Associated Program') }}<br><br>
-
- <input type = "hidden" id = "{{ $programs[0]->name }}" name="program_id[]" value="{{$programs[0]->id}}">
-
- <input type="checkbox" id="assoc_program_id_{{ $programs[0]->id }}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
- <label for="assoc_program_id_{{ $programs[0]->id }}"> {{ $programs[0]->name }} <sub>[{{ $programs[0]->school->name }}]</sub></label><br>
-
- </div>
-
-
- <!-- Status -->
- <div class="form-group">
- {{ Form::label('status', 'Status') }}
- <span data-toggle="tooltip" data-placement="top" title="Use this option to deactivate or reactivate criteria. Inactive criteria will stay in the system, but will not be available to use in new rubrics." class="glyphicon glyphicon-question-sign"></span>
-
- <select id="status" name="status" class="form-control">
- <option value="1">Active</option>
- <option value="0">Inactive</option>
- </select>
- </div>
-
-
-
- <div class="form-group">
- {{ Form::label('name', 'Name') }}
- {{ Form::text('name', Input::old('name'), array('class' => 'form-control', 'id'=>'criterion_name')) }}
- </div>
-
- <div class="form-group">
- {{ Form::label('subcriteria', 'Subcriteria') }}
- <p class="help-block"><strong>Manually add</strong> bullets or numbering.</p>
- {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'id' => 'criterion_subcriteria')) }}
- </div>
- <div class="form-group">
- {{ Form::label('assoc_maximum_score', 'Maximum Score') }}
- {{ Form::text('assoc_maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
- </div>
-
-
- <div class="form-group">
- {{ Form::label('scales', 'Number of Scales') }}
- <select id="Num_assoc_scale" class="form-control selectpicker" onchange='numberOfAssoc("Num_assoc_scale", "Assoc_Scales")'>
-
- </select>
- </div>
- <div id='Assoc_Scales' data-value="0">
-
- </div>
-
-
-
-
- <div class="form-group">
- {{ Form::label('copyright', 'Copyright Information') }}
- {{ Form::textarea('copyright', Input::old('copyright'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_copyright', 'placeholder'=>'(optional)')) }}
- </div>
-
- <div class="form-group">
- {{ Form::label('notes', 'Additional Notes') }}
- {{ Form::textarea('notes', Input::old('notes'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_notes', 'placeholder'=>'(optional)')) }}
- </div>
-
- {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
- {{ Form::close() }}
- {{ Form::open(array('action' => 'CriteriaController@delete')) }}
-
- <input type='hidden' name='criterion_delete' id='deleteCriteria'>
-
- {{Form::submit("Delete", array('class'=> 'btn btn-primary btn-block', 'id'=>"DeleteButton"))}}
-
- </div>
- </div>
- </div>
- </div>
- <script>
- var selectOptions = document.getElementById('outcome0').innerHTML;
-
- var counter = 1;
- var counterObj = 1;
- var outcomeString = 'OutcomeGroup_';
-
- $(document).ready(function() {
- addOptions('Num_scale', 'maximum_score', 'Scales');
- numberOfScales('Num_scale', 'Scales');
- });
-
- function addOptions(select, max, scaleDiv) {
-
-
- var maxscore = parseInt($('#' + max).val())
- options = '<option value = "1"> 1</option>';
- selectedValue = 1;
- valueBefore = 0;
- for (var i = 2; i <= 20; i++) {
- if(maxscore%i==0){
- options += '<option value="' + i.toString() + '">' + i.toString() + '</option>';
-
- }
-
- }
-
- var previousvalue = parseInt($('#' + select).val());
- $('#' + select).html(options);
- $('#' + select).val(previousvalue);
- $('#' + select).selectpicker('refresh');
- $('#'+select).trigger('change');
- }
-
- function numberOfAssoc(string, Scales) {
- var maximum = $('#assoc_maximum_score').val();
- var amountOfScale = parseInt($('#' + string).val());
- var dataValue = parseInt($('#' + Scales).attr('data-value'));
- var division = maximum/amountOfScale;
- //add
-
-
- fullDiv = '';
- if(division ==1){
- for (var i = dataValue; i < amountOfScale; i++) {
- div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
- '<div class ="form-group">' +
- '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(i+1)+')</label>' +
- '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
- fullDiv += div;
-
-
- }
- }
- else if(division == maximum){
- div = '<div id="assoc_eval' +0 + Scales + '">' +
- '<div class ="form-group">' +
- '<label for ="assoc_descripcion' + 0 + '">Scale Description ('+1+' - '+maximum+') </label>' +
- '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + 0 + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
- fullDiv += div;
- }
- else{
- for (var i = 0; i < amountOfScale; i++) {
-
- div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
- '<div class ="form-group">' +
- '<label for ="assoc_descripcion' + i.toString() + '">Scale Description ('+(1+(i*division))+' - '+((1+i)*division)+')</label>' +
- '<textarea class="form-control" rows="2" aria-labelledby="assoc_descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
- fullDiv += div;
- }
- }
-
- $('#' + Scales).html(fullDiv);
- $('#' + Scales).attr('data-value', amountOfScale);
- }
-
-
-
-
-
- //add
-
-
-
-
-
-
-
- function numberOfScales(string, Scales) {
- var maximum = parseInt($('#maximum_score').val());
- var amountOfScale = parseInt($('#' + string).val());
- var dataValue = parseInt($('#' + Scales).attr('data-value'));
- var division = maximum/amountOfScale;
- //add
-
-
-
-
- fullDiv = '';
- if(division ==1){
- for (var i = 0; i < amountOfScale; i++) {
- div = '<div id="eval' + i.toString() + Scales + '">' +
- '<div class ="form-group">' +
- '<label id = "label_for_des'+i.toString()+'" for ="descripcion' + i.toString() + '">Scale Description ('+(i+1)+')</label>' +
- '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
- fullDiv += div;
- }
- }
- else if(division==maximum){
-
- div = '<div id="eval' + 0 + Scales + '">' +
- '<div class ="form-group">' +
- '<label id = "label_for_des'+0+'" for ="descripcion' + 0 + '">Scale Description ('+1+' - '+maximum+')</label>' +
- '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + 0 + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
- fullDiv += div;
- }
-
- else{
- for (var i = 0; i < amountOfScale; i++) {
- div = '<div id="eval' + i.toString() + Scales + '">' +
- '<div class ="form-group">' +
- '<label id = "label_for_des'+i.toString()+'" for ="descripcion' + i.toString() + '">Scale Description ('+(1+(i*division))+' - '+((1+i)*division)+')</label>' +
- '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
- fullDiv += div;
- }
- }
-
- $('#' + Scales).html(fullDiv);
-
-
- $('#' + Scales).attr('data-value', amountOfScale);
-
- }
-
- $('.filterSection').hide();
- $('.filterButton').on('click', function()
- {
- var span = $(this).find('span');
- if(span.attr('class') == 'glyphicon glyphicon-plus'){
- span.attr('class','glyphicon glyphicon-minus');
- } else{
- span.attr('class','glyphicon glyphicon-plus');
- }
- $('.filterSection').toggle(533);
- });
-
-
-
- //Add outcome Button
- function addOutcomeTest() {
- counter = parseInt($('#outcomeGroup').data("value"));
- var $select = $('<select/>', {
- 'class': "selectpicker form-control",
- 'name': "outcome[]",
- 'data-live-search': 'true',
- 'id': 'outcome' + counter.toString(),
- 'onchange': 'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")'
-
- });
- var $div = $('<div/>', {
- 'id': 'outcomeForm' + counter.toString(),
- 'class': 'form-group col-md-11'
- });
-
- var $divForButton = $('<div/>', {
- 'class': 'col-md-1',
- 'id': 'close' + counter.toString()
-
- });
- var $button = $('<button/>', {
- 'type': 'button',
- 'class': 'btn btn-primary',
- 'onclick': 'deleteLast("outcomeForm'+counter.toString()+'", "outcomeGroup", "close' + counter.toString() + '", "objectiveGroup")'
- });
-
- $button.append('X');
- $divForButton.append($button);
-
- $div.appendTo('#outcomeGroup')
- $select.append(selectOptions);
-
- $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
- $('#outcomeGroup').data("value", (counter +1));
- fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
- counter += 1;
- $divForButton.appendTo('#outcomeGroup');
-
-
-
-
- }
-
-
-
- //Delete Outcome and OptGroup associated
-
- function deleteLast(outcomeForm, outcomeDiv, closeButton, objectiveGroup) {
- $div = document.getElementById(outcomeForm );
- $div.remove();
- $div = document.getElementById(closeButton);
- $div.remove();
- if(outcomeDiv =='outcomeGroup'){
- $('#' + outcomeDiv).data('value',parseInt($('#' + outcomeDiv).data('value')) - 1);
- fetchObjectiveForSelect(outcomeDiv, objectiveGroup);}
-
- }
- //Delete Objective
-
- function deleteObjective(objectiveForm, closeObj, objectiveGroup) {
- $div = document.getElementById(objectiveForm);
- $div.remove();
- $div = document.getElementById(closeObj);
- $div.remove();
- counter = parseInt($('#'+objectiveGroup).data("value"));
- $('#'+objectiveGroup).data("value", counter-1);
-
-
- }
-
- //Add objective when editing
-
- function addAssocObjective() {
- selectObj = document.getElementById('assoc_objective_0').innerHTML;
- assocObjectiveCounter = parseInt($('#assoc_objectiveGroup').data('value'));
- var $select = $('<select/>', {
- 'class': "selectpicker form-control",
- 'name': "assoc_objective[]",
- 'data-live-search': 'true',
- 'id': 'assoc_objective_' + assocObjectiveCounter.toString(),
-
-
- });
- var $div = $('<div/>', {
- 'id': 'assoc_objectiveForm' + assocObjectiveCounter.toString(),
- 'class': 'form-group col-md-11'
- });
- var $divForButton = $('<div/>', {
- 'class': 'col-md-1',
- 'id': 'assoc_closeObj' + assocObjectiveCounter.toString()
-
- });
- var $button = $('<button/>', {
- 'type': 'button',
- 'class': 'btn btn-primary',
- 'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', "assoc_objectiveGroup")'
- });
-
- $button.append('X');
- $divForButton.append($button);
-
- $div.appendTo('#assoc_objectiveGroup')
- $select.append(selectObj);
-
- $select.appendTo('#assoc_objectiveForm' + assocObjectiveCounter.toString()).selectpicker('refresh');
- $('#assoc_objectiveGroup').data("value", assocObjectiveCounter +1);
-
- $divForButton.appendTo('#assoc_objectiveGroup');
-
- }
-
-
- //Add objective when creating a criteria
- function addObjectiveTest() {
- selectObj = document.getElementById('objective_0').innerHTML;
- counter = parseInt($("#objectiveGroup").data('value'));
- var $select = $('<select/>', {
- 'class': "selectpicker form-control",
- 'name': "objective[]",
- 'data-live-search': 'true',
- 'id': 'objective_' + counter.toString()
-
- });
- var $div = $('<div/>', {
- 'id': 'objectiveForm' + counter.toString(),
- 'class': 'form-group col-md-11'
- });
- var $divForButton = $('<div/>', {
- 'class': 'col-md-1',
- 'id': 'closeObj' + counter.toString()
-
- });
- var $button = $('<button/>', {
- 'type': 'button',
- 'class': 'btn btn-primary',
- 'onclick': 'deleteObjective("objectiveForm' + counter.toString() + '", "closeObj' + counter.toString() + '")'
- });
-
- $button.append('X');
- $divForButton.append($button);
-
- $div.appendTo('#objectiveGroup')
- $select.append(selectObj);
-
- $select.appendTo('#objectiveForm' + counter.toString()).selectpicker('refresh');
-
-
- $divForButton.appendTo('#objectiveGroup');
- $('#objectiveGroup').data('value', counter +1);
- }
-
- //Create outcome for editing
-
- var assocOutcomeCounter = 0;
-
-
- function addAssocOutcome() {
- assocOutcomeCounter = parseInt($('#assocOutcomeGroup').data('value'));
- var $select = $('<select/>', {
- 'class': "selectpicker form-control",
- 'name': "assoc_outcome[]",
- 'data-live-search': 'true',
- 'id': 'assoc_outcome_' + assocOutcomeCounter.toString(),
- 'onchange': 'fetchAssocObjective("assoc_outcome_' + assocOutcomeCounter.toString() + '")'
-
- });
- var $div = $('<div/>', {
- 'id': 'assoc_outcomeForm' + assocOutcomeCounter.toString(),
- 'class': 'form-group col-md-11'
- });
-
- var $divForButton = $('<div/>', {
- 'class': 'col-md-1',
- 'id': 'assoc_close' + assocOutcomeCounter.toString()
-
- });
- var $button = $('<button/>', {
- 'type': 'button',
- 'class': 'btn btn-primary',
- 'onclick': 'deleteLast("assoc_outcomeForm' + assocOutcomeCounter.toString() + '", "assocOutcomeGroup", "assoc_close' + assocOutcomeCounter.toString() + '","assoc_objectiveGroup")'
- });
-
- $button.append('X');
- $divForButton.append($button);
-
- $div.appendTo('#assocOutcomeGroup')
- $select.append(selectOptions);
-
- $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
- assocOutcomeCounter += 1;
- $divForButton.appendTo('#assocOutcomeGroup');
-
- $('#assocOutcomeGroup').data('value', assocOutcomeCounter);
-
-
- }
- //Fetch associated objective for editing
-
-
- var assocObjectiveCounter = 1;
-
- function fetchAssocObjective(outcomeDiv, objectiveGroup) {
- var count = $('#'+outcomeDiv).data('value');
- var allOutcomes =[];
-
- $("#" + outcomeDiv + ' select').each(function() {
- allOutcomes.push( this.value);
-
- })
- var allObjectives = [];
- $("#" + objectiveGroup + ' select').each(function() {
- var temp = {
- id: this.id,
- value: this.value
- }
- allObjectives.push(temp);
- })
-
-
- $.post(
- "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
- allOutcomes: allOutcomes
- },
-
- function(json) {
-
- optionName = '<option value ="0">Nothing Selected</option>';
- for(outcome in varArray.outcomes){
- optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
- var objectiveForOutcome = varArray.objectives;
- var objectives = objectiveForOutcome[outcome];
- for (objective in objectives) {
-
-
- var obj= objectives[objective];
- var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
- optionName += (option);
- }
- optionName += '</optgroup>';
- }
-
-
- $('#assoc_objective_0').html(optionName);
- $('#assoc_objective_0').selectpicker('refresh');
- if($("#assoc_objective_0 option[value='"+allObjectives[0].value+"']").length>0){
- $("#assoc_objective_0").val(allObjectives[0].value);
- $('#assoc_objective_0').selectpicker('refresh');
- }
-
- for (var i = allObjectives.length - 1; i > 0; i--) {
- deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup');
- }
- for(var i=1; i<allObjectives.length; i++){
- addAssocObjective();
- $('#assoc_objective_'+i.toString()).selectpicker('refresh');
- if($("#assoc_objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
- $("#assoc_objective_"+i.toString()).val(allObjectives[i].value);
- $("#assoc_objective_"+i.toString()).selectpicker("refresh");
- }
- }
-
-
-
- },
- 'json'
- );
- }
-
- //Fetch objective at creating criteria
- counterForPost = 0;
-
- function fetchObjectiveForSelect(outcomeDiv, objectiveGroup) {
- var count = $("#" + outcomeDiv).data('value');
- var allOutcomes = [];
- $("#" + outcomeDiv + ' select').each(function() {
- allOutcomes.push( this.value);
-
- })
- var allObjectives = [];
- $("#" + objectiveGroup + ' select').each(function() {
- var temp = {
- id: this.id,
- value: this.value
- }
- allObjectives.push(temp);
- })
-
- $.post(
- "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
- allOutcomes: allOutcomes
- },
- function(varArray) {
- counterOutcome =0;
- optionName = '<option value ="0">Nothing Selected</option>';
- for(outcome in varArray.outcomes){
- optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '">';
- var objectiveForOutcome = varArray.objectives;
- var objectives = objectiveForOutcome[outcome];
- for (objective in varArray.objectives[outcome]) {
-
-
- var obj= objectives[objective];
- var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
- optionName += (option);
- }
- optionName += "</optgroup>";
- }
-
-
-
-
- $('#objective_0').html(optionName);
- $('#objective_0').selectpicker('refresh');
- if($("#objective_0 option[value='"+allObjectives[0].value+"']").length>0){
- $("#objective_0").val(allObjectives[0].value);
- $('#objective_0').selectpicker('refresh');
- }
-
-
- for (var i = allObjectives.length - 1; i > 0; i--) {
- deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString(), 'objectiveGroup');
- }
- for(var i =1; i<allObjectives.length; i++){
- addObjectiveTest();
- $('#objective_'+i.toString()).selectpicker('refresh');
- if($("#objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
- $("#objective_"+i.toString()).val(allObjectives[i].value);
- $("#objective_"+i.toString()).selectpicker("refresh");
- }
- }
-
-
-
-
-
-
- },
- 'json'
- );
- }
- //after post
-
-
- //For editing criterion
- function fetchAllCriterion(program, outcome) {
- var program_id_fetch = $('#' + program).find(':selected').val();
- var outcome_fetch = $('#' + outcome).find(':selected').val();
- $.post(
- "{{URL::action('CriteriaController@fetchAllCriterion')}}", {
- program_fetch: program_id_fetch,
- outcome_fetch: outcome_fetch
- },
- function(json) {
- json_length = (json.criterion.length);
- fullHTML = '';
- for (var i = 0; i < json_length; i++) {
- fullHTML += '<option value="' + json.criterion[i].id + '">' + json.criterion[i].name + '</option>';
- }
- $('#select-criterion').html(fullHTML);
- $('#select-criterion').selectpicker('refresh');
- fetchCriterionForEditing()
-
- },
- 'json'
- );
- }
-
- function deleteCriterion() {
- var id = $('#select-criterion').find(':selected').val()
-
- $.post(
- "{{ URL::action('CriteriaController@delete')}}", {
- id: id
- },
- function() {
- window.location.reload(true)
- }
- )
- }
-
-
- function fetchCriterionForEditing() {
- var id = $('#select-criterion').find(':selected').val();
-
- $.post(
- "{{ URL::action('CriteriaController@fetchCriterionWithTrashed') }}", {
- id: id
- },
- function(json) {
-
- if (!(json.activity_criterion.length)) {
-
- $('#DeleteButton').prop('enabled', true);
-
- } else {
- $('#DeleteButton').prop('disabled', true);
- }
-
- if (!(json.criteria.length)) {
- name = ' ';
- var subcriteria = '';
- copyright = null;
- notes = null;
- $('#status').val(0);
- maximum = 1;
- $('#assoc_maximum_score').val(1);
-
-
- } else {
- var name = json.criteria[0].name;
- if (json.criteria[0].subcriteria) {
- subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
- }else {
- subcriteria = "";
- }
- if (json.criteria[0].copyright) {
- var copyright = json.criteria[0].copyright;
- } else {
- var copyright = ''
- }
- if (json.criteria[0].notes) notes = json.criteria[0].notes;
- else notes = '';
-
- // Display info
- $('#criterion_name').val(name);
- $('#criterion_subcriteria').text(subcriteria);
- if (json.criteria[0].deleted_at)
- $('#status').val(0);
- else
- $('#status').val(1);
- $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
- var maximum = json.criteria[0].maximum_score;
-
- // If copyright or notes aren't empty, load them
-
- }
-
-
-
- $('#criterion_copyright').text(copyright);
-
-
- $('#criterion_notes').text(notes);
-
-
-
-
-
-
-
- // Select associated outcome
- try {
- assocOutcomeCounter= parseInt($("#assocOutcomeGroup").data('value'));
- for (var i = assocOutcomeCounter - 1; i > 0; i--) {
- deleteLast("assoc_outcomeForm" + i.toString() , "assocOutcomeGroup", "assoc_close" + i.toString() ,"assoc_objectiveGroup");
- }
- } catch (err) {
- var Notran = true;
- }
-
- if (json.outcomes.length) {
- $('#assoc_outcome_0').val(json.outcomes[0].id);
- $('#assoc_outcome_0').selectpicker('refresh');
- } else {
- $('#assoc_outcome_0').val($('#assoc_outcomes_fetch').find(':selected').val());
- $('#assoc_outcome_0').selectpicker('refresh');
- }
-
-
-
- for (var i = 1; i < json.outcomes.length; i++) {
- addAssocOutcome();
- $('#assoc_outcome_' + i.toString()).val(json.outcomes[i].id);
- $('#assoc_outcome_' + i.toString()).selectpicker('refresh');
-
- }
-
- counterObj =$('#assoc_objectiveGroup').data('value');
-
-
- try {
- for (var i = counterObj - 1; i > 0; i--) {
- deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup')
- }
- } catch (err) {
- var noEntro = true;
- }
- $('#assoc_objectiveGroup').data('value', 1);
-
-
-
-
-
- assocOutcomeCounter = 0;
- var i = 0;
- optionName = '<option value ="0">Nothing Selected</option>';
- for(outcome in json.outcomes_assoc){
- optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '">';
- var objectiveForOutcome = json.objectives_assoc;
- var objectives = objectiveForOutcome[outcome];
- for (objective in objectives) {
-
-
- var obj= objectives[objective];
- var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
- optionName += (option);
- }
- optionName+= '</optgroup>';
- }
- $('#assoc_objective_0').html(optionName);
-
- $('#assoc_objective_0').selectpicker('refresh');
-
-
-
-
-
-
-
-
-
-
- try {
- $('#assoc_objective_0').val(json.objectives[0].id);
- $('#assoc_objective_0').selectpicker('refresh');
- } catch (err) {
- if (!json.objectives.length) {
- $('#assoc_objective_0').val(0);
- $('#assoc_objective_0').selectpicker('refresh');
- }
- var thereIsNoObjective = true;
- }
-
- for (var i = 1; i < json.objectives.length; i++) {
- addAssocObjective();
- $('#assoc_objective_' + i.toString()).val(json.objectives[i].id);
- $('#assoc_objective_' + i.toString()).selectpicker('refresh');
- }
- $('assoc_objectiveGroup').data('value',json.objectives.length);
-
-
-
-
-
-
-
-
- // Select status
-
-
-
-
-
-
-
-
- },
- 'json'
- );
- }
- </script>
- @stop
-
- @section('javascript')
-
- // --------------------------------------------------------------------------
- // Page load
- // --------------------------------------------------------------------------
-
- // Hide accordion panel contents by default
- $('.panel-group .panel-body').hide();
-
- $('#outcome-display').parent().hide();
-
- fetchCriterionForEditing();
- fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
- // setCriterionStatus();
-
-
- fetchAllCriterion("select-program", "assoc_outcomes_fetch");
-
- // --------------------------------------------------------------------------
- // Functions
- // --------------------------------------------------------------------------
- $('#button-add-outcome').on('click', function(e) {
- // Prevent the default action of the clicked item. In this case that is submit
- e.preventDefault();
-
-
- return false;
- });
- $('.filterButton').on('click', function(e) {
- // Prevent the default action of the clicked item. In this case that is submit
- e.preventDefault();
-
-
- return false;
- });
- $('#button-add-objective-assoc').on('click', function(e) {
- // Prevent the default action of the clicked item. In this case that is submit
- e.preventDefault();
-
-
- return false;
- });
- $('#button-add-outcome-assoc').on('click', function(e) {
- // Prevent the default action of the clicked item. In this case that is submit
- e.preventDefault();
-
-
- return false;
- });
- $('#button-add-objective').on('click', function(e) {
- // Prevent the default action of the clicked item. In this case that is submit
- e.preventDefault();
-
-
- return false;
- });
- // Fetch criterion info for editing
-
-
- // --------------------------------------------------------------------------
- // Events
- // --------------------------------------------------------------------------
-
- // When panel heading is clicked, toggle it
- $('.panel-group .panel-heading').on('click', function()
- {
- $(this).next().stop().slideToggle();
- })
-
- //$('#outcome[0]').on('change', function(){
-
- //$('.selectpicker').selectpicker('refresh');
- //})
- // When list item is clicked, load corresponding info
-
-
- // When list item is clicked, load corresponding info
- $('.selectpicker').on('change', function()
- {
- //alert($(this).find(':selected').val());
- $('.selectpicker').selectpicker('refresh');
- });
-
- @stop
|