@extends('layouts.master') @section('navigation') @if($role==1) @include('local.managers.admins._new_navigation') @elseif($role==2) @include('local.managers.sCoords._new_navigation') @elseif($role==3) @include('local.managers.pCoords._new_navigation') @else @include('local.professors._navigation') @endif @stop @section('main')

Course: {{{ $course->code }}}{{{ $course->number }}}-{{{ $course->section }}}

{{ HTML::linkAction('ActivitiesController@show', 'Back to Activity', array($activity->id), array('class'=>'btn btn-default btn-sm pull-right')) }}

Activity: {{{ $activity->name}}}

@foreach ($rubric_contents as $criterion) @endforeach @foreach ($students as $student) @for ($i = 0; $i @endfor @endforeach @for ($i = 0; $i @endfor
{{ $criterion->name}}
id }}>{{{ $student->name }}}
Total
@stop @section ('javascript') // -------------------------------------------------------------------------- // Events // -------------------------------------------------------------------------- // Submit button is clicked $('#button-submit-assessment').on('click', function(e) { //TODO var expected_points = 6; var expected_percentage = 70; //Prevent page refresh e.preventDefault(); // Row in the database var activity_id = $('#activity').data('activity-id'); // Object to hold the score sum of each criterion var criteriaSumObject = new Object(); // Object to hold how many students got at least the expected points var CriteriaAchievedCounter = new Object(); // Object to hold all student evaluations var studentAssessments = new Array(); // Iterate through all students $('tbody tr').each(function( index ) { var ScoresObject = new Object(); // Scores column in database var CriterionObject = new Object(); // Objects inside ScoresObject var SingleStudentAssessment = new Object(); SingleStudentAssessment.student_id = $(this).find('.student-field').data('student-id'); // For each criterion, store the score in array $(this).children('td.score-field').each(function( index ) { var scoreField = $(this); var criterion_id = $('.criterion-field').eq(index).data('criterion-id'); var score = scoreField.children('select').find(':selected').val(); ScoresObject[criterion_id]=score; // Initialize the index for the sum object, if it's undefined if(typeof(criteriaSumObject[criterion_id]) == 'undefined') { criteriaSumObject[criterion_id]=0; } // Add to this criterion's total criteriaSumObject[criterion_id]+=parseInt(score); // Initialize the index for the achieved criteria count object, if it's undefined if(typeof(CriteriaAchievedCounter[criterion_id]) == 'undefined') { CriteriaAchievedCounter[criterion_id]=0; } // Add to the achieved criteria count for this criterion, if the // score reaches or exceeds the expected points if(score >= expected_points) { CriteriaAchievedCounter[criterion_id]+=1; } }); SingleStudentAssessment.scores = ScoresObject; console.log('student object: '+JSON.stringify(SingleStudentAssessment)); var clone = jQuery.extend({}, SingleStudentAssessment); studentAssessments.push(clone); }); console.log('students: '+JSON.stringify(studentAssessments)); console.log('total points per criteria: '+JSON.stringify(criteriaSumObject)); console.log('total of students that achieved each criterion ' +JSON.stringify(CriteriaAchievedCounter)); // Iterate through all evaluated criteria, determining which were achieved // by comparing the completion percentage to the expected percentage var CriteriaAchievedResults = new Object(); $.each(CriteriaAchievedCounter, function( index, value ) { var x = CriteriaAchievedCounter[index]; var y = $('tbody tr').length; if((x/y)*100 >= expected_percentage) { CriteriaAchievedResults[index]=1; } else { CriteriaAchievedResults[index]=0; } }); console.log('criteria results: '+JSON.stringify(CriteriaAchievedResults)); // Save activity to the database $.post ( "{{ URL::action('ActivitiesController@saveAssessment') }}", { activity_id: activity_id, criteria_achievement: JSON.stringify(CriteriaAchievedResults), student_scores: JSON.stringify(studentAssessments) }, function(data) { location.reload(); } ); }); @stop