<?php

// Event::listen('illuminate.query', function($sql, $params)
// {
//     print_r($sql);

//     echo '<pre>';
//     print_r($params);
//     echo "</pre>";
// });

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/


// Route model bindings
Route::model('template', 'Template');
Route::model('program', 'Program');
Route::model('five_year_plan', 'FiveYearPlan');


// Composers
View::composer(array(
    'local.professors._navigation',
    'local.managers.admins._new_navigation',
    'local.managers.sCoords._new_navigation',
    'local.managers.pCoords._new_navigation',
), function ($view) {
    // Get user's courses' numbers
    $courses = Auth::user()->courses;

    $schools = School::orderBy('name', 'asc')->get();
    $view->with('courses', $courses)->with('schools', $schools);
});

View::composer(array(
    'local.professors.*',
    'local.managers.admins._new_navigation',
    'local.managers.sCoords._new_navigation',
    'local.managers.pCoords._new_navigation',
    'local.managers.shared.limited-course',
    'local.managers.shared.school',
    'local.managers.shared.school-uhs',
    'local.managers.shared.programs',
    'local.managers.shared.program',
    'local.managers.shared.rubrics',
    'global.view-learning-outcomes-criteria',
    'global.view-learning-outcomes-criteria',
    'global.view-three-year-plan'
), function ($view) {
    $view->with('role', Auth::user()->role);
});


/*
 * Login/logout routes
 */

/** Use modified guest filter to redirect logged in user */
Route::get('/', array('before' => 'guest', 'uses' => 'AuthController@showLogin'));
Route::post('/login', array('uses' => 'AuthController@login'));

/**
 * Protected Routes
 */
Route::group(array('before' => 'auth|has_access'), function () {

    /**
     * Recalculate course outcomes
     *
     */

    Route::get('recalculateCourses', function () {

        DB::disableQueryLog();

        if (Auth::user()->id != 58)
            Redirect::action('AuthController@showLogin');

        try {
            $courses = Course::all();

            foreach ($courses as $course) {
                echo $course->id;
                // Recalculate course outcomes
                $activities = Activity::where('course_id', $course->id)
                    ->whereNotNull('outcomes_attempted')
                    ->where('draft', 0)
                    ->get();


                //If there are still evaluated activities in the course, recalculate course outcomes
                if (!$activities->isEmpty()) {
                    $outcomeCount = Outcome::all()->count();

                    // Variables to hold recalculated outcomes for the course
                    $course_outcomes_attempted = array_fill(1, $outcomeCount, 0);
                    $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);

                    // For each activity
                    foreach ($activities as $activity2) {
                        // If activity has been assessed
                        if ($activity2->outcomes_attempted != NULL) {
                            echo '<ul>';
                            // Get the achieved criteria
                            $criteria_achievement = json_decode($activity2->criteria_achieved, true);
                            foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
                                // Find corresponding learning outcome;
                                $criterion = Criterion::withTrashed()->where('id', $criterion_id)->first();

                                print '<li>' . $criterion->id . '</li>';


                                $outcome = Outcome::find($criterion->outcome_id);

                                // If criterion is achieved (1), add 1 to both arrays
                                if ($criterion_achieved === 1) {
                                    $course_outcomes_attempted[$outcome->id] += 1;
                                    $course_outcomes_achieved[$outcome->id] += 1;
                                }
                                // Else, only add to the attempted outcomes arrays
                                elseif ($criterion_achieved === 0) {
                                    $course_outcomes_attempted[$outcome->id] += 1;
                                }
                            }

                            echo '</ul>';
                        }
                    }

                    // Update course
                    DB::table('courses')
                        ->where('id', $course->id)
                        ->update(array(
                            'outcomes_attempted' => json_encode($course_outcomes_attempted),
                            'outcomes_achieved' => json_encode($course_outcomes_achieved),
                            'updated_at' => date('Y-m-d H:i:s')
                        ));
                }
                // Otherwise, set them all to NULL
                else {
                    DB::table('courses')
                        ->where('id', $course->id)
                        ->update(array(
                            'outcomes_attempted' => NULL,
                            'outcomes_achieved' => NULL,
                            'updated_at' => date('Y-m-d H:i:s')
                        ));
                }
            }

            return 'success';
        } catch (Exception $e) {
            return 'failure (' . $e->getLine() . '): ' . $e->getMessage();
        }
    });

    /**
     * Shared Routes
     */

    // Annual Plan routes
    Route::post('deleteCommentsFromOutcome', array('uses' => 'AnnualPlansController@deleteCommentsFromOutcome'));
    Route::post('addCommentsToOutcome', array('uses' => 'AnnualPlansController@addCommentsToOutcome'));
    Route::post('fetchAnnualPlan', array('uses' => 'AnnualPlansController@fetchTheAnnualPlan'));

    Route::post('deleteTaFromOutcome', array('uses' => 'TransformativeActionsController@deleteTaFromOutcome'));
    Route::post(
        'postTransformativeToOutcome',
        array(
            'as' => 'postTransformativeToOutcome',
            'uses' => 'TransformativeActionsController@createTAForOutcome'
        )
    );


    Route::post('postAnnualReport/{annual_id?}', 'AnnualPlansController@postAnnualReport');
    Route::get('printAnnualPlan/{annual_plan?}/{submit?}', 'AnnualPlansController@printAnnualPlan');
    Route::post('checkIfPlanReady', 'AnnualPlansController@checkIfPlanReady');

    Route::post('submitAnnualPlan/{annual_id?}', 'AnnualPlansController@submitAnnualPlan');


    Route::post("checkIfReady", 'AnnualPlansController@checkIfReady');

    Route::get("printAnnualReport/{annual_plan?}/{submit?}", 'AnnualPlansController@printAnnualReport');
    Route::post('fetchObjectiveInfo', array(
        'as' => 'fetchObjectiveInfo',
        'uses' => 'AnnualPlansController@fetchObjectiveInfo'
    ));
    Route::get('selectAnnualProgram', array(
        'as' => 'selectAnnualProgram',
        'uses' => 'AnnualPlansController@selectProgramPlan'
    ));

    Route::post("fetchReportWithOutcome", array(
        'as' => 'fetchReportWithOutcome',
        'uses' => 'AnnualPlansController@fetchReportWithOutcome'
    ));

    Route::get('annual_plan_report/{program_id}', array(
        'as' => 'annual_plan_report/{program_id}',
        'uses' => 'OutcomesController@annualReport'
    ));
    Route::post('fetchAnnualReport', array(
        'as' => 'fetchAnnualReport',
        'uses' => 'AnnualPlansController@fetchAnnualReport'
    ));

    //Shared course creation, ( por si School coordinator y Program coordinator
    // van a poder crear luego)
    Route::get('editCourses', 'CoursesController@editView');
    Route::post("createCourse", 'CoursesController@create');
    Route::post("updateCourseInfo", 'CoursesController@updateCourseInfo');
    Route::post("fetch_assoc_courses", 'CoursesController@fetchCourses');


    //Fetch Objectives for Template

    Route::post("fetchObjectiveForTemplate", 'TemplatesController@fetchObjectivesForTemplate');


    //shared viewTransformativeActions

    Route::get('viewTransformativeActions', 'TransformativeActionsController@viewTransformativeActions');
    Route::get('viewProgramActivities', 'TransformativeActionsController@viewProgramActivities');

    //View Three year plan

    Route::get('three-year-plan/show/{program_id}', "ThreeYearPlanController@showPDFs");
    Route::get("downloadThreeYearPlanPDF/{path_id}", "ThreeYearPlanController@showHTML");
    Route::get("findHTMLlinksTYP/{path_id}", 'ThreeYearPlanController@findHTML');

    //View annual plans and report

    Route::get('{annual_report_or_plan}/show/{program_id}', "AnnualPlansController@annualPlansShow");
    Route::get("findHTMLlinksAP/{type_of_annual}/{path_id}", "AnnualPlansController@findHTML");

    //Route::post('submitAnnualPlan', array('uses' => 'AnnualPlansController@submitAnnualPlan'));

    Route::post('fetchTransformativeStatus', array('uses' => 'TransformativeActionsController@fetchStatus'));

    Route::post('saveTransStatus', array('uses' => 'TransformativeActionsController@saveTransStatus'));

    Route::post('futureTransformativeCourse', 'AnnualPlansController@futureTransformative');
    //other stuff
    Route::post('deleteCriterion', 'CriteriaController@delete');
    Route::post('postActivityCriterionTrans/{activity_id}', array(
        'as' => 'postActivityCriterionTrans/{activity_id}',
        'uses' => 'TransformativeActionsController@postActivityCriterion'
    ));
    Route::post('changeStatusOfCriterion', array(
        'as' => 'changeStatusOfCriterion',
        'uses' => 'CriteriaController@changeStatus'
    ));
    Route::post('createThreeYearCycle', array(
        'as' => 'createThreeYearCycle',
        'uses' => 'ThreeYearPlanController@create'
    ));
    Route::get('printThreeYear/{program_id}/{typ}/{submit?}', array(
        'as' => 'printThreeYear/{program_id}/{typ}/{submit?}',
        'uses' => 'ThreeYearPlanController@printPlan'
    ));
    Route::get('viewThreeYear/{program_id}/{typ}', array(
        'as' => 'viewThreeYear/{program_id}/{typ}',
        'uses' => 'ThreeYearPlanController@viewPlan'
    ));

    Route::post('submitTYP/{program_id}', 'ThreeYearPlanController@submit');
    // Fetch all criteria associated to an outcome
    Route::post('fetchInfo', array(
        'as' => 'fetchInfo',
        'uses' => 'AnnualPlansController@fetchInfo'
    ));
    Route::post('fetchCriteria', array(
        'as' => 'fetchCriteria',
        'uses' => 'OutcomesController@fetchCriteria'
    ));
    Route::post('fetchCriterionWithTemplate', array(
        'as' => 'fetchCriterionWithTemplate',
        'uses' => 'CriteriaController@fetchCriterionWithTemplate'
    ));
    Route::post('fetchFormative', array(
        'as' => 'fetchFormative',
        'uses' => 'TransformativeActionsController@fetchCourses'
    ));

    Route::post('fetchObjectivesForOutcome', "Objective2Controller@fetchObjectivesForOutcome");

    //Objectives and Criteria Shared Routes
    Route::get('criteria', array('uses' => 'CriteriaController@edit'));
    Route::get('objectives', array('uses' => 'Objective2Controller@edit'));

    // Fetch a criterion for a rubric
    Route::post('fetchCriterion', array(
        'as' => 'fetchCriterion',
        'uses' => 'CriteriaController@fetchCriterion'
    ));
    // Fetch Criterions associated to programs
    Route::post('fetchAllCriterion', array(
        'as' => 'fetchAllCriterion',
        'uses' => 'CriteriaController@fetchAllCriterion'
    ));

    Route::post('insertPCOBO', 'Objective2Controller@insertPCOBO');


    Route::get('viewFormative', array(
        'as' => 'viewFormative',
        'uses' => 'TransformativeActionsController@viewFormativeActions'
    ));


    Route::post('delete', array(
        'as' => 'delete',
        'uses' => 'TransformativeActionsController@deleteTA'
    ));
    // Fetch a criterion for a rubric
    Route::post('fetchCriterionWithTrashed', array(
        'as' => 'fetchCriterionWithTrashed',
        'uses' => 'CriteriaController@fetchCriterionWithTrashed'
    ));

    Route::get('learning-outcomes/show/{id}', array(
        'as' => "learning-outcomes/show/{id}",
        'uses' => 'OutcomesController@show'
    ));
    //Fetch objectives for criteria when outcome is chosen
    Route::post('fetchObjectivesForSelect', array(
        'as' => 'fetchObjectivesForSelect',
        'uses' => 'CriteriaController@fetchObjectivesForSelect'
    ));

    // Fetch a criterion for a rubric with custom content
    Route::post('fetchRubricCriterion', array(
        'as' => 'fetchRubricCriterion',
        'uses' => 'RubricsController@fetchRubricCriterion'
    ));
    Route::post('fetchObjectives', 'Objective2Controller@fetchAllObjectives');

    // Load a rubric template
    Route::post('loadTemplate', array('uses' => 'TemplatesController@fetch'));

    Route::post('filterSemesters', array('uses' => 'SemestersController@filterSemesters'));


    // Log out user
    Route::get('logout', 'AuthController@logout');

    // Edit and update user profile
    Route::get('profile', 'UsersController@edit');
    Route::post('profile/update', array('before' => 'csrf', 'uses' => 'UsersController@update'));

    // Allows users to give feeback
    Route::post('feedback/send', array('before' => 'csrf', 'uses' => 'FeedbackController@send'));
    Route::resource(
        'feedback',
        'FeedbackController',
        array('only' => array('create'))
    );

    Route::get('agreement', 'AgreementController@index');
    Route::post('agreement/agree', array('before' => 'csrf', 'uses' => 'AgreementController@agree'));

    // Show users all learning outcomes and criteria
    Route::get('learning-outcomes-criteria', 'CriteriaController@index');
    Route::post('fetchOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@fetchOutcome'));
    // Show users all objectives and criteria
    Route::get('learning-objectives-criteria', 'Objective2Controller@viewObjectives');
    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectiveForCriteria'));

    // Show professor overview to users with courses
    Route::get('professor', 'ProfessorsController@overview');

    // view objectives and criteria, edit criteria
    Route::post('fetchCriteriaFromProgram', 'Objective2Controller@fetchProgramCriteria');

    // Assessment reports for users' courses

    Route::get('my-assessment-reports', 'OutcomesController@professorAssessmentReport');
    Route::post('objectives/fetch', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetch'));

    // Transformative Actions for p-coordinators and professors
    Route::get('transformativeAction', array('uses' => 'TransformativeActionsController@editTA'));
    Route::post('transformativeAction/createTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@createTA'));
    Route::post('transformativeAction/selectTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@selectTA'));
    Route::post('transformativeAction/updateTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@updateTA'));
    Route::post('transformativeAction/filterTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@filterTA'));
    Route::post('transformativeAction/objectivesFromOutcome', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@objectivesFromOutcome'));


    /**
     * Administrator Routes
     */
    Route::group(array('before' => 'admin'), function () {
        Route::get('/administrator', 'AdministratorsController@overview2');
        Route::get('/administrator2', 'AdministratorsController@overview');
        Route::post('/administrator2/filter', 'AdministratorsController@overview2_filter_results');
        Route::post('administrator/rubrics', array(
            'as' => 'rubrics',
            'before' => 'csrf',
            'uses' => 'CriteriaController@fetch'
        ));

        // manage courses permissions. 

        Route::get('manageCoursesPermissions', 'ProgramsController@assignOtherProgramIndex');
        Route::post('addToOtherProgramTYP', 'ProgramsController@addToOtherProgramTYP');
        Route::post("fetchPairingInfo", 'ProgramsController@fetchPairingInfo');
        Route::post("updatePairingInfo", 'ProgramsController@updatePairingInfo');


        //New navigation routes

        Route::get('campusAnnualReport', 'AnnualPlansController@adminReportIndex');
        Route::get('campusResults', 'OutcomesController@adminProgramIndex');
        Route::get('manageSemesterCycle', 'ThreeYearPlanController@manageSemesterCycle');


        //Plans routes
        Route::get('showThreeYearPlans', 'ThreeYearPlanController@adminIndex');
        Route::post('fetchSubmit', 'ThreeYearPlanController@fetchSubmitted');
        Route::get('showAnnualPlans', 'AnnualPlansController@adminIndex');
        Route::get("showAnnualReports", "AnnualPlansController@adminReportIndex");
        Route::post('fetchSubmitAn', 'AnnualPlansController@fetchSubmitted');



        //endhere
        Route::post('createOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@create'));
        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));

        Route::get('learning-outcomes', 'OutcomesController@index');
        //Route::post('fetchObjectives', 'Objective2Controller@fetchAllObjectives');
        // TODO: Change later
        Route::get('new-learning-outcomes', 'OutcomesController@newIndex');

        Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
        Route::post('learning-outcomes/delete', array('before' => 'csrf', 'uses' => 'OutcomesController@delete'));
        Route::post('criteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));
        Route::delete('critteria/delete', array('before' => 'csrf', 'uses' => 'CriteriaController@destroy'));

        Route::get('administrator/users/{query?}', 'UsersController@index');

        Route::post('administrator/updateAccess', array('before' => 'csrf', 'uses' => 'UsersController@updateAccess'));
        Route::post('administrator/users/store', array('before' => 'csrf', 'uses' => 'UsersController@store'));

        //Route::get('criteria', array('uses' => 'CriteriaController@edit'));
        //Route::get('objectives', array('uses' => 'Objective2Controller@edit'));
        Route::get('administrator/semesters', 'SemestersController@edit');
        Route::post('administrator/semesters/update', 'SemestersController@update');
        Route::post('deleteObjective', 'Objective2Controller@delete');

        Route::get('assessment-report', 'OutcomesController@assessmentReport');
        // TODO: Change later
        Route::get('new-assessment-report/{outcome_id}', 'OutcomesController@newAssessmentReport');

        Route::get('template-list', 'TemplatesController@index');

        Route::get('template/{template}', 'TemplatesController@show');
        Route::post('onLoadFetch', 'TemplatesController@onLoadFetch');

        Route::get('courses/reassign', 'CoursesController@reassign');
        Route::post('courses/update', array('before' => 'csrf', 'uses' => 'CoursesController@update'));

        Route::get('activities/create', 'ActivitiesController@newCreate');
        Route::get('total_assessment-report', 'OutcomesController@totalAssessmentReport');
    });

    /**
     * School Coordinator Routes
     */
    Route::group(array('before' => 'scoord'), function () {
        Route::get('school-coordinator-test', 'SchoolCoordinatorsController@overview_test');
        Route::get('school-coordinator', 'SchoolCoordinatorsController@overview');
        Route::get('school/{id}', 'SchoolsController@show');
        Route::get('program/{id}', 'ProgramsController@show');
        Route::post('programs/report', 'ProgramsController@showReport');
        Route::get('template/{template}', 'TemplatesController@show');

        // Route::post('storeTypInfo', 'OutcomesController@storeCycleInfo'); //TODO: where is this route supposed to be placed?
        Route::get('programs', 'ProgramsController@index');
        Route::get('template-list', 'TemplatesController@index');
        Route::post('deleteObjective', 'Objective2Controller@delete');
        // Print school report
        Route::get('print_school/{id}', 'SchoolsController@print_school');

        // Assessment reports

        Route::get('school-assessment-report', 'OutcomesController@schoolAssessmentReport');
        Route::get('student_school_assessment-report/{school_id}', 'SchoolsController@studentSchoolAssessmentReport');

        // Gabriel added this, so the school coordinator can add criterias and objectives
        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
        //Route::get('school-objective', 'Objective2Controller@edit');
        //Route::get('school-criteria', 'CriteriaController@edit');

        Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));

        //Show users annual plan
        Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
        Route::post('annual-plan-fetchTYP/{program_id}/{typ_id}', 'AnnualPlansController@fetchTYP');
        Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
        Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
        Route::get('annual-plan-show/{program_id}', 'AnnualPlansController@viewAllPlans');
        Route::post('fetchAllTables', 'AnnualPlansController@fetchAllTables');
        Route::post('annual-plan-postTA', 'AnnualPlansController@postTA');
        Route::post('annual-report-post', 'AnnualPlansController@postReport');
        Route::post('annual-plan-deleteTA', 'AnnualPlansController@deleteTA');
        Route::post('annual-plan-trans-report', 'AnnualPlansController@transformativeReport');


        // Show users plan de tres a~nos
        Route::get('three-years-plan/{program_id}', 'ThreeYearPlanController@threeYearsReport');
        Route::post('fetchThreeYears', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@fetchThreeYears'));
        Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
        Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
        Route::post('section2_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_on_change'));
        Route::post('section3_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_arrive'));
        Route::post('section3_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_on_change'));
        Route::post('typ/getObjectives', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@getObjectivesForTYP'));
        Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
        Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
        Route::post('createAnnualPlan/{program_id}', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@createAnnualPlan'));
    });


    /**
     * Program Coordinator Routes
     */
    Route::group(array('before' => 'pcoord'), function () {
        Route::get('program-coordinator', 'ProgramCoordinatorsController@overview');
        Route::post('deleteObjective', 'Objective2Controller@delete');
        Route::get('rubrics_old', 'TemplatesController@newTemplate');
        Route::get('rubrics', 'TemplatesController@newTemplate_new');
        Route::get('template/{template}', 'TemplatesController@show');

        Route::post('saveTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@create'));
        Route::post('updateTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@update'));
        Route::post('deleteTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@destroy'));
        Route::get('course/{id}', 'CoursesController@showLimited');
        Route::get('rubrics/{template_id}/download', 'TemplatesController@download');
        Route::post('program/fetch', array('before' => 'csrf', 'uses' => 'ProgramsController@fetch'));
        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
        Route::get('printRubric/{id}', 'TemplatesController@printview');
        Route::get('rubric/{rubric_id}', 'RubricsController@show_limited');
        Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
        Route::get('template-list', 'TemplatesController@index');

        Route::get('student_program_assessment-report/{program_id}', 'ProgramsController@studentProgramAssessmentReport');


        //Criteria and objectives
        //Route::get('program-criteria', 'CriteriaController@edit');
        Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));
        //Route::get('program-objective', 'Objective2Controller@edit');

        // Print program report
        Route::get('print_program/{id}', 'ProgramsController@print_program');

        // Print course (grouped sections) report
        Route::get('print_course/{code}/{number}/{semester_code}', 'CoursesController@print_course');


        // Assessment reports
        Route::get('program-assessment-report/{program_id}', 'OutcomesController@programAssessmentReport');
        Route::get('assessment-reports', 'OutcomesController@managerAssessmentReports');

        // Learning Objectives
        Route::get('program/{program}/objectives', 'ObjectivesController@index');
        Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@update'));
        Route::post('program/{id}/createObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@create'));
        Route::post('fetchObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjective'));
        Route::post('fetchObjectivesForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectivesForCriteria'));

        //Objectives
        //Route::get('objective', 'Objective2Controller@edit');
        Route::post('createObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@create'));
        Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@update'));
        Route::post('fetchObjectiveWithTrashed', array('before' => 'csrf', 'uses' => 'Objective2Controller@fetchObjectiveWithTrashed'));
        Route::post('deletePCOBO', 'Objective2Controller@deletePCOBO');
        Route::post('updatePCOBO', 'Objective2Controller@updatePCOBO');


        // Five year plans,
        Route::get('five-year-plans', 'FiveYearPlansController@index');
        Route::get('program/{program}/five-year-plans/create', 'FiveYearPlansController@create');
        Route::get('program/{program}/five-year-plans/{five_year_plan}', 'FiveYearPlansController@show');
        Route::get('program/{program}/five-year-plans/{five_year_plan}/edit', 'FiveYearPlansController@edit');
        Route::get('five-year-plans/{five_year_plan}/ms-word', 'FiveYearPlansController@msWord');
        Route::post('five-year-plans/store', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@store'));
        Route::post('five-year-plans/update', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@update'));


        // Annual plans
        Route::get('annual-plans', 'AnnualPlansController@index');
        Route::get('program/{program}/annual-plans/create', 'AnnualPlansController@create');
        Route::get('program/{program}/annual-plans/{five_year_plan}', 'AnnualPlansController@show');
        Route::get('program/{program}/annual-plans/{five_year_plan}/edit', 'AnnualPlansController@edit');
        Route::post('annual-plans/store', array('before' => 'csrf', 'uses' => 'AnnualPlansController@store'));
        Route::post('annual-plans/update', array('before' => 'csrf', 'uses' => 'AnnualPlansController@update'));

        Route::get('learning-outcomes/shows/{id}', 'OutcomesController@show');
        // TODO: Change route name
        Route::get('learning-outcomes/newshow/{id}', 'OutcomesController@newShow');
        Route::get('new-report/{id}', 'OutcomesController@newReport');
        Route::get('new-report-all', 'OutcomesController@newReportAll');
        Route::get('courses/{id}', 'CoursesController@newShow');

        Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
        Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
        Route::post('annual-plan-CreateOrEdit/{program_id}', 'AnnualPlansController@CreateOrEdit');
        Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
        Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');

        //Gabriel added this

        Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
        Route::post('annual-plan-fetchTYP/{program_id}/{typ_id}', 'AnnualPlansController@fetchTYP');
        Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
        Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
        Route::get('annual-plan-show/{program_id}', 'AnnualPlansController@viewAllPlans');
        Route::post('fetchAllTables', 'AnnualPlansController@fetchAllTables');
        Route::post('annual-plan-postTA', 'AnnualPlansController@postTA');
        Route::post('annual-report-post', 'AnnualPlansController@postReport');
        Route::post('annual-plan-deleteTA', 'AnnualPlansController@deleteTA');
        Route::post('annual-plan-trans-report', 'AnnualPlansController@transformativeReport');


        // Transformative Actions
        Route::post('transformativeAction/approveTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@approveTA'));

        // Show users plan de tres a~nos
        Route::get('three-years-plan/{program_id}', 'ThreeYearPlanController@threeYearsReport');
        Route::post('fetchThreeYears', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@fetchThreeYears'));
        Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
        Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
        Route::post('section2_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_on_change'));
        Route::post('section3_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_arrive'));
        Route::post('section3_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_on_change'));
        Route::post('typ/getObjectives', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@getObjectivesForTYP'));
        Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
        Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
        Route::post('createAnnualPlan/{program_id}', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@createAnnualPlan'));
    });


    /**
     * Professor Routes
     */
    Route::group(array('prefix' => 'professor', 'before' => 'prof'), function () {

        Route::get('rubrics', 'TemplatesController@newTemplateProf');
        Route::get('templateForProfessor', 'TemplatesController@ProfIndex');
        Route::post('program', array('before' => 'csrf', 'uses' => 'ProfessorsController@program'));
        Route::get('activities/{activity_id}/rubrics', 'RubricsController@newRubric');
        Route::get('activities/{activity_id}/other_method', 'RubricsController@newOtherMethod');
        Route::get('activities/{activity_id}/rubric', 'RubricsController@show');
        Route::get('activities/{activity_id}/rubric/{rubric_id}/download', 'RubricsController@download');
        Route::get('activities/{activity_id}/rubric/{rubric_id}/print', 'RubricsController@printview');
        Route::get('activities/{activity_id}/assess', 'ActivitiesController@assess');
        Route::get('activities/{activity_id}/view_assessment', 'ActivitiesController@viewAssessment');
        Route::get('activities/{activity_id}/print_assessment', 'ActivitiesController@printAssessment');
        Route::post('activities/saveAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@saveAssessment'));
        Route::post('activities/deleteAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@deleteAssessment'));
        Route::delete('activities/{activity_id}/delete', 'ActivitiesController@destroy');
        Route::post('activities/{activity_id}/update', array('before' => 'csrf', 'uses' => 'ActivitiesController@update'));
        Route::get('courses/{id}', 'CoursesController@show');
        Route::get('courses/{semester}/{id}/students/{number}', 'StudentsController@show');
        Route::get('courses/{semester}/{id}/students/{number}/print_report', 'StudentsController@printStudentReport');
        Route::get('activities/{id}', 'ActivitiesController@show');
        Route::post('activities/{id}', array('before' => 'csrf', 'uses' => 'ActivitiesController@create'));
        Route::get('students', 'StudentsController@students');
        Route::get('program', 'ProfessorsController@program');
        Route::get('personal-information', 'ProfessorsController@personalInformation');
        Route::get('manual', 'ProfessorsController@manual');
        Route::post('loadRubric', array('before' => 'csrf', 'uses' => 'RubricsController@fetch'));
        Route::post('saveRubric', array('before' => 'csrf', 'uses' => 'RubricsController@create'));
        Route::post('updateRubric', array('before' => 'csrf', 'uses' => 'RubricsController@update'));
        Route::post('deleteRubric', array('before' => 'csrf', 'uses' => 'RubricsController@destroy'));
        Route::get('learning-outcomes-criteria', 'CriteriaController@index');
        Route::get('learning-objectives-criteria', 'Objective2Controller@viewObjectives');
        Route::get('export_grades/{id}', 'CoursesController@exportGrades');
        Route::get('template/{template}', 'TemplatesController@show');
        Route::get('compare_activities/{activity_1}/{activity_2}', 'ActivitiesController@compareActivities');
        // Assessment reports
        //Route::get('professor-assessment-report/{outcome_id}', 'OutcomesController@professorAssessmentReport');
        Route::get('professor-assessment-reports', 'OutcomesController@professorAssessmentReport');

        Route::get('general-studies-overview', 'ProfessorsController@generalStudiesOverview');
        Route::get('template/{template}', 'TemplatesController@profShow');
    });
});