@extends('layouts.master') @section('navigation') @if(Auth::user()->role==1) @include('local.managers.admins._new_navigation') @elseif(Auth::user()->role==2) @include('local.managers.sCoords._new_navigation') @elseif(Auth::user()->role==3) @include('local.managers.pCoords._new_navigation') @endif @stop @section('main')
General Information
@if(Auth::user()->role==1)
@endif @if(Auth::user()->role==1 || Auth::user()->role==2)
@endif
% of all students must score at least point(s) in a criterion for it to pass.

Note: You can hide or show this section by clicking on its heading. You may want to hide it to have more space.

@if(Auth::user()->role != '1')
@if(Auth::user()->role == '3') @endif
@endif
updated
Criterion Beginning (1-2) In Progress (3-4) Good (5-6) Excellent (7-8)
@stop @section('included-js') @stop @section('javascript') // -------------------------------------------------------------------------- // Page load // -------------------------------------------------------------------------- $('#updated-text').hide(); // Enable/disable program selection depending on school selection if user is // admin if({{Auth::user()->role}}==1) toggleProgramSelect($('#select-school')); // Fetch criteria of first outcome fetchCriteria($('#select-outcome')); // Hide table $('#rubric-container').hide(); // Disable Update and Delete Buttons by default $('#button-confirm-update-rubric').prop('disabled', true); $('#button-confirm-delete-rubric').prop('disabled', true); $('#button-print-rubric').prop('disabled', true); // Sortable rows $('.table').sortable({ handle: 'span.glyphicon.glyphicon-move', containerSelector: 'table', itemPath: '> tbody', itemSelector: 'tr', placeholder: '' }); // -------------------------------------------------------------------------- // Functions // -------------------------------------------------------------------------- // Fetch criteria associated to a specific learning outcome function fetchCriteria(outcome) { $.post ( "{{ URL::route('fetchCriteria') }}", { id: outcome.find(':selected').data('outcome-id'), filter: $('input[name=criteria-filter]:checked').val() }, function(data) { $('#select-criterion').empty(); // Append criteria data.forEach( function (arrayItem) { $('#select-criterion') .append(''); }); // If there are no criteria assigned to the selected outcome, disable the // input and the button used to add criteria. if(!$('#select-criterion').children().length) { $('#select-criterion').prop('disabled', true); $('#button-add-criterion').prop('disabled', true); } // Otherwise, enable both the input and the button else { $('#select-criterion').prop('disabled', false); $('#button-add-criterion').prop('disabled', false); } $('#updated-text').fadeIn('slow').fadeOut('slow'); } ); } // Add a new criterion to the rubric function addCriterion() { // Show the rubric container if(!$('tbody').children().length) { $('#rubric-container').show(); } // Get the selected criterion's id var id= parseInt($('#select-criterion').find(':selected').data('criterion-id')); // Check for duplicates var duplicates=false; $('tbody tr').each(function() { if ($(this).data('criterion-id') == id) { duplicates=true; } }); // If there are any, display an error if(duplicates) { $('#js-error-row').show(); $('#js-error-row').find('#error-message').text('Error: The selected criterion was already added.'); return; } // Otherwise, hide the error container else { $('#js-error-row').hide(); } // Fetch information of the criterion selected $.post ( "{{ URL::route('fetchCriterion') }}", { id: id}, function(data) { // Append the fetched data var str =''; if(data.notes) { str+=''+data.name+''; } else { str+=''+data.name+''; } str+=''+data.description12+'' +''+data.description34+'' +''+data.description56+'' +''+data.description78+'' +''; $('table tbody').append(str); // Build copyright list buildCopyrightList(); // Enable X-Edtable on this new row $('.editable').editable({ unsavedclass: null, rows: 4 }); // Turn on tooltips again (because content is dynamic) $('[data-toggle="tooltip"]').tooltip(); // Sortable rows $('.table').sortable({ handle: 'span.glyphicon.glyphicon-move', containerSelector: 'table', itemPath: '> tbody', itemSelector: 'tr', placeholder: '' }); } ); } // Fetch single criterion function fetchCriterion(criterion) { $.post ( "{{ URL::route('fetchCriterion') }}", { id: outcome.find(':selected').data('outcome-id')}, function(data) { $('#select-criterion').empty(); data.forEach( function (arrayItem) { $('#select-criterion') .append(''); }); $('#select-criterion').append(''); } ); } // Build list from copyright info in rubric function buildCopyrightList() { // Empty the copyright list $('#copyright-list').empty(); $('tbody tr').each(function( index ) { var criterion = $(this); // If there's copyright info if(criterion.data('criterion-copyright')!=null) { var copyright = criterion.data('criterion-copyright'); // If there is anything in the copyright list if($('#copyright-list li').length>0) { // Check copyright list for the same copyright text var found = false; $('#copyright-list li').each(function() { // If found, give the string its number if(copyright==$(this).find('span').text()) { copyrightNumber = Number.parseInt($(this).find('sup').text()); criterion.children('td:nth-child(1)').find('sup').text(copyrightNumber); found =true; //to break return false; } }); // Otherwise, give it the next number and append a new item to the // list if(!found) { var copyrightNumber = $('#copyright-list li').length+1; criterion.children('td:nth-child(1)').find('sup').text(copyrightNumber); $('#copyright-list').append('
  • '+copyrightNumber+' '+copyright+'
  • '); } } // Otherwise, give it number 1 and append it else { criterion.children('td:nth-child(1)').find('sup').text('1'); $('#copyright-list').append('
  • 1 '+copyright+'
  • '); } } }); if($('#copyright-info li').length>0) { $('#copyright-info').show(); } else { $('#copyright-info').hide(); } } // Fetch programs associated to a specific school function fetchPrograms(school) { $.ajax({ type: 'POST', url: "{{ URL::action('ProgramsController@fetch') }}", data: { id: school.find(':selected').data('school-id')}, success: function(data) { $('#select-program').empty(); $('#select-program').append(''); data.forEach( function (program) { $('#select-program') .append(''); }); }, async:false }); if($('#select-school').find(':selected').data('school-id')!=0) $('#select-program').prop('disabled', false); else $('#select-program').prop('disabled', true); } // Load a template. This function is different from the one for professors function loadTemplate() { $.post ( "{{ URL::to('loadTemplate') }}", { id: $('#select-template').find(':selected').data('template-id')}, function(data) { // Show the container and empty all rows $('#rubric-container').show(); $('tbody').empty(); //Set the name of the rubric $('#rubric-name').val(data.name); // Set school id to 0, then to the saved value if it exists $('#select-school option[data-school-id="0"]').prop('selected', true); $('#select-school option[data-school-id="'+data.school_id+'"]').prop('selected', true); // Fetch programs associated to that school fetchPrograms($('#select-school')); // Set program id to 0, then to the saved value if it exists $('#select-program option[data-program-id="0"]').prop('selected', true); $('#select-program option[data-program-id="'+data.program_id+'"]').prop('selected', true); // Set expected values $('#expected_percentage option[value="'+data.expected_percentage+'"]').prop('selected', true); $('#expected_points option[value="'+data.expected_points+'"]').prop('selected', true); // Set visibility var is_visible = JSON.parse(data.is_visible); if(is_visible) { $('#is_visible0').prop('checked', false); $('#is_visible1').prop('checked', true); } else { $('#is_visible1').prop('checked', false); $('#is_visible0').prop('checked', true); } // Set the contents of the rubric var contents = JSON.parse(data.contents); contents.forEach(function (data) { // Append the fetched data var str =''; if(data.notes) { str+=''+data.name+''; } else { str+=''+data.name+''; } str+=''+data.description12+'' +''+data.description34+'' +''+data.description56+'' +''+data.description78+'' +''; $('table tbody').append(str); // Build copyright list buildCopyrightList(); // Enable X-Edtable on this new row $('.editable').editable({ unsavedclass: null, rows: 4 }); // Turn on tooltips again (because content is dynamic) $('[data-toggle="tooltip"]').tooltip(); }); // Sortable rows $('.table').sortable({ handle: 'span.glyphicon.glyphicon-move', containerSelector: 'table', itemPath: '> tbody', itemSelector: 'tr', placeholder: '' }); // Build Copyright List buildCopyrightList(); } ); } // Checks whether the user wants to save a rubric with a name that already exists function nameExists() { var duplicates = false; $('#select-template option').each(function() { var optionName = $(this).text().trim(); if($('#rubric-name').val().trim()===optionName) { duplicates = true; } }); return duplicates; } //Enable disable program select function toggleProgramSelect(school) { if(school.find(':selected').data('school-id')<1) { $('#select-program option[data-program-id="0"]').prop('selected', true); $('#select-program').prop('disabled', true); } else { fetchPrograms(school); $('#select-program').prop('disabled', false); } } // -------------------------------------------------------------------------- // Events // -------------------------------------------------------------------------- // Toggle visibility for accordion panels $('.panel-heading').on('click', function() { if($(this).find('.glyphicon').hasClass('glyphicon-triangle-right')) { $(this).find('.glyphicon').removeClass('glyphicon-triangle-right'); $(this).find('.glyphicon').addClass('glyphicon-triangle-bottom'); } else if($(this).find('.glyphicon').hasClass('glyphicon-triangle-bottom')) { $(this).find('.glyphicon').removeClass('glyphicon-triangle-bottom'); $(this).find('.glyphicon').addClass('glyphicon-triangle-right'); } $(this).siblings('.panel-body').stop().slideToggle(); }); // When trying to change the template, ask the user to confirm and reset the // rubric if s/he does $('#select-template').on('change', function() { // If changing to custom template, reset if($('#select-template').find(':selected').data('template-id')=='0') { $('#rubric-container').hide(); $('#rubric-name').val(''); $('tbody').empty(); // Disable delete, update and print buttons $('#button-confirm-delete-rubric').prop('disabled', true); $('#button-confirm-update-rubric').prop('disabled', true); $('#button-print-rubric').prop('disabled', true); } // Otherwise, load the selected template else { loadTemplate(); //If user is admin, or the templates id matches user's, or the template // id's school matches user, allow editing var selected = $('#select-template').find(':selected'); var program = '{{ Auth::user()->program_id }}'; if( {{ Auth::user()->role }}==1 || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1) || ({{ Auth::user()->role }}==3 && selected.data('template-program-id')== program && selected.data('admin')!=1 ) ) { $('#button-confirm-delete-rubric').prop('disabled', false); $('#button-confirm-update-rubric').prop('disabled', false); } else { // Disable update and edit $('#button-confirm-delete-rubric').prop('disabled', true); $('#button-confirm-update-rubric').prop('disabled', true); } // Enable print button $('#button-print-rubric').prop('disabled', false); } }); // When a school changes, update its programs. If all is selected, disable $('#select-school').on('change', function() { toggleProgramSelect($(this)); }); // When a learning outcome changes, update its criteria $('#select-outcome, input[name=criteria-filter]').on('change', function() { fetchCriteria($('#select-outcome')); }); // When the add button is clicked $('#button-add-criterion').on('click', function(e) { //Prevent page refresh e.preventDefault(); //Add new criterion addCriterion(); }); // When the create or update buttons are clicked (.save) $('.save').on('click', function(e) { //Prevent page refresh e.preventDefault(); // Empty field validation var emptyFields=false; $('td').each(function() { if ($(this).text() == "" || $(this).text() == "Empty") { emptyFields=true; } }); // If any fields are empty, display error if(emptyFields || $.trim($('#rubric-name').val())=='') { $('#js-error-row').show(); $('#js-error-row').find('#error-message').text('Error: Please fill all the fields. Make sure your rubric has a name.'); return; } else { $('#js-error-row').hide(); } // Check whether a rubric with the written name already exists if($(this).attr('id')=='button-create-rubric' && nameExists()) { $('#js-error-row').show(); $('#js-error-row').find('#error-message').text('Error: A template with that name already exists.'); return; } else { $('#js-error-row').hide(); } var criterionObject = new Object(); var criteriaArray = new Array(); // For each criterion in the rubric, get its value and put it into an array $('tbody tr').each(function( index ) { criterionObject.id = $(this).data('criterion-id'); criterionObject.outcome_id = $(this).data('assoc-outcome-id'); criterionObject.name = $(this).children('td:nth-child(2)').find('span').text(); criterionObject.description12 = $(this).children('td:nth-child(3)').text(); criterionObject.description34 = $(this).children('td:nth-child(4)').text(); criterionObject.description56 = $(this).children('td:nth-child(5)').text(); criterionObject.description78 = $(this).children('td:nth-child(6)').text(); criterionObject.copyright = $(this).data('criterion-copyright'); criterionObject.notes = $(this).data('criterion-notes'); // Clone the object and push it into the array var clone = jQuery.extend({}, criterionObject); criteriaArray.push(clone); //console.log(JSON.stringify(clone)); }); //console.log('school', $('#select-school').find(':selected').data('school-id') ); //console.log('program', $('#select-program').find(':selected').data('program-id') ); if($(this).attr('id')=='button-create-rubric') { // Create $.post ( "{{ URL::to('saveTemplate') }}", { name: $('#rubric-name').val(), contents: JSON.stringify(criteriaArray), school_id: $('#select-school').find(':selected').data('school-id'), program_id: $('#select-program').find(':selected').data('program-id'), expected_percentage: $('#expected_percentage').find(':selected').val(), expected_points: $('#expected_points').find(':selected').val(), is_visible: $('input[name=is_visible]:checked').val() }, function(data) { location.reload(true); } ); } else { console.log('school', $('#select-school').find(':selected').data('school-id') ); console.log('program', $('#select-program').find(':selected').data('program-id') ); // Update database $.post ( "{{ URL::to('updateTemplate') }}", { id: $('#select-template').find(':selected').data('template-id'), name: $('#rubric-name').val(), contents: JSON.stringify(criteriaArray), school_id: $('#select-school').find(':selected').data('school-id'), program_id: $('#select-program').find(':selected').data('program-id'), expected_percentage: $('#expected_percentage').find(':selected').val(), expected_points: $('#expected_points').find(':selected').val(), is_visible: $('input[name=is_visible]:checked').val() }, function(data) { location.reload(true); } ); } }); // When the confirm delete button is clicked $('#button-delete-rubric').on('click', function(e) { $('#modal-confirm-delete').modal('hide'); // Delete from database $.post ( "{{ URL::to('deleteTemplate') }}", { id: $('#select-template').find(':selected').data('template-id') }, function(data) { location.reload(); } ); }); // Remove a criterion and hide the table if it was the only one $('table').on('click', '.glyphicon-remove', function(e) { $(this).closest('tr').remove(); if(!$('tbody').children().length) { $('#rubric-container').hide(); } buildCopyrightList(); }); // When print button is clicked, redirect to print page $('#button-print-rubric').on('click', function(e) { e.preventDefault(); window.location = "printRubric/"+$('#select-template').find(':selected').data('template-id'); }); @stop