<?php //Function from rorypicko (Stack Overflow) function seoUrl($string) { //Lower case everything $string = strtolower($string); //Make alphanumeric (removes all other characters) $string = preg_replace("/[^a-z0-9_\s-]/", "", $string); //Clean up multiple dashes or whitespaces $string = preg_replace("/[\s-]+/", " ", $string); //Convert whitespaces and underscore to dash $string = preg_replace("/[\s_]/", "-", $string); return $string; } header('Content-type: application/vnd.ms-word'); header('Content-Disposition: attachment; Filename='.seoURL($rubric->name).'.docx'); echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">'; echo '<meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'>'; echo '<body>'; //Inline styles (necessary because it's a download) echo '<style> body { font: "Arial", sans-serif; } .header-text { text-align:center; font-weight: bold; margin:0; } table { border-collapse: collapse; border: 1px solid black; width: 100%; } td, th { border: 1px solid black; padding: 5px; } @page { mso-page-orientation: landscape; } </style>'; ?> <p class="header-text">University of Puerto Rico, Río Piedras Campus</p> <p class="header-text">Online Learning Assessment System</p> <p class="header-text">{{$course->program->name}} Program</p> <p class="header-text">{{{ $course->code }}} {{{ $course->number }}} - {{$course->name}}</p> <h1 class="header-text">Assessment Rubric </h1> <span>Rubric: {{{ $rubric->name}}}</span><br> <span>Activity: {{{ $activity->name}}} </span><br> <span>Passing Criteria: <span id="expected_percentage">{{{ $rubric->expected_percentage }}}% of students must obtain at least </span> <span id="expected_points">{{{$rubric->expected_points}}}</span> points </span><br> <span>Date: {{ date('M d, Y') }}<br> <br> <table class="table table-striped table-condensed"> <thead><tr><th>Criterion</th><th>Beginning (1-2)</th><th>In Progress (3-4)</th><th>Good (5-6)</th><th>Excellent (7-8)</th><th>Copyright</th><th>Notes</th></tr></thead> <tbody> @foreach(json_decode($rubric->contents) as $criterion) <tr> <td> {{{ $criterion->name }}} </td> <td>{{{ $criterion->description12 }}}</td> <td>{{{ $criterion->description34 }}}</td> <td>{{{ $criterion->description56 }}}</td> <td>{{{ $criterion->description78 }}}</td> <td> @if($criterion->copyright) {{{ $criterion->copyright }}} @endif </td> <td> @if($criterion->notes) {{{ $criterion->notes }}} @endif </td> </tr> @endforeach </tbody> </table> <? echo '</body>'; echo '</html>'; ?>