@extends('layouts.master') @section('navigation') @if($role==1) @include('local.managers.admins._navigation') @elseif($role==2) @include('local.managers.sCoords._navigation') @elseif($role==3) @include('local.managers.pCoords._navigation') @else @include('local.professors._navigation') @endif @stop @section('main')
{{ HTML::linkAction('ActivitiesController@show', 'Back to Activity', array($activity->id), array('class'=>'btn btn-default btn-sm pull-right')) }}

@if($activity->rubric_id!=NULL) @endif
% of all students must score at least points in a criterion for it to pass.

CriterionBeginning (1-2)In Progress (3-4)Good (5-6)Excellent (7-8)
@if($activity->outcomes_attempted!=NULL) @endif
@stop @section('javascript') // -------------------------------------------------------------------------- // Page load // -------------------------------------------------------------------------- console.log({{ $activity }}); //If there are no rubrics to show, alert user and redirect. if($('#select-template').children().length) loadTemplate(); else { $('#modal-no-rubric').modal({ backdrop: 'static' }); } // -------------------------------------------------------------------------- // Functions // -------------------------------------------------------------------------- // Fetch criteria associated to a specific learning outcome function fetchCriteria(outcome) { $.post ( "{{ URL::route('fetchCriteria') }}", { id: outcome.find(':selected').data('outcome-id')}, function(data) { $('#select-criterion').empty(); data.forEach( function (arrayItem) { // If criterion does not belong to a user, display it if(arrayItem.user_id==null) { $('#select-criterion') .append(''); } // If it does, but the user is the one logged on, display. // Otherwise, ignore else if(arrayItem.user_id!="" && {{{Auth::id()}}}==arrayItem.user_id ) { $('#select-criterion') .append(''); } }); // Add custom option $('#select-criterion') .append(''); $('#select-criterion').prop('disabled', false); $('#button-add-criterion').prop('disabled', false); } ); } // 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(); } } // Load a template function loadTemplate() { $.post ( "{{ URL::to('loadTemplate') }}", { id: $('#select-template').find(':selected').data('template-id')}, function(data) { //alert(JSON.stringify(data)); // Show the container and empty all rows $('#rubric-container').show(); $('tbody').empty(); //Set the name of the rubric $('#rubric-name').val(data.name); console.log($('#expected_percentage').text()); console.log($('#expected_points').text()); // Set expected values $('#expected_percentage').text(data.expected_percentage); $('#expected_points').text(data.expected_points); // Set the contents of the rubric var contents = JSON.parse(data.contents); contents.forEach(function (criterion) { var str =''; var subcriteria = ''; if(criterion.subcriteria){ var subcriteria_array = criterion.subcriteria; subcriteria = ''; } // If the criterion has notes, set the tooltip with them if(criterion.notes) { str+=''+criterion.name+''+subcriteria+''; } else { str+=''+criterion.name+''+subcriteria+''; } // Add the descriptions str+=''+criterion.description12.replace(/\n/gi, '
    ')+'' +''+criterion.description34.replace(/\n/gi, '
    ')+'' +''+criterion.description56.replace(/\n/gi, '
    ')+'' +''+criterion.description78.replace(/\n/gi, '
    ')+''; // Append the string to the table $('table tbody').append(str); // Turn on tooltips again (because content is dynamic) $('[data-toggle="tooltip"]').tooltip(); }); // Build Copyright List buildCopyrightList(); } ); } // -------------------------------------------------------------------------- // Events // -------------------------------------------------------------------------- // When trying to change the template, ask the user to confirm and reset the // rubric if s/he does $('#select-template').on('change', function() { loadTemplate(); }); // When a learning outcome changes, update its criteria $('#select-outcome').on('change', function() { fetchCriteria($(this)); }); // When save button is clicked $('#button-save-rubric').on('click', function(e) { //Prevent page refresh e.preventDefault(); 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(1)').find('span').text(); var subcriteriaArray = new Array(); $(this).children('td:nth-child(1)').find('.subcriteria li').each(function(index){ subcriteriaArray.push($(this).text()); }); criterionObject.subcriteria = subcriteriaArray; criterionObject.description12 = $(this).children('td:nth-child(2)').html().replace(/
    /gi, '\n'); criterionObject.description34 = $(this).children('td:nth-child(3)').html().replace(/
    /gi, '\n'); criterionObject.description56 = $(this).children('td:nth-child(4)').html().replace(/
    /gi, '\n'); criterionObject.description78 = $(this).children('td:nth-child(5)').html().replace(/
    /gi, '\n'); 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); }); // If activity does not have a rubric, create it if($('#assigned_rubric').length === 0) { $('#js-error-row').hide(); // Create $.post ( "{{ URL::to('professor/saveRubric') }}", { name: $('#select-template').find(':selected').text(), activity_id: parseInt($('#activity_id').val()), contents: JSON.stringify(criteriaArray), expected_percentage: $('#expected_percentage').text(), expected_points: $('#expected_points').text() }, function(data) { location.replace(data); } ); } // Else, update it else { // Update database $.post ( "{{ URL::to('professor/updateRubric') }}", { id: $('#assigned_rubric').data('assigned-rubric'), name: $('#select-template').find(':selected').text(), contents: JSON.stringify(criteriaArray), expected_percentage: $('#expected_percentage').text(), expected_points: $('#expected_points').text() }, function(data) { location.replace(data); } ); } }); // When Ok button is clicked, redirect to previous page // When save button is clicked $('#button-redirect').on('click', function(e) { e.preventDefault(); history.go(-1); }); @stop