|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // This file is part of BasicLTI4Moodle 00018 // 00019 // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability) 00020 // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web 00021 // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI 00022 // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS 00023 // are already supporting or going to support BasicLTI. This project Implements the consumer 00024 // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas. 00025 // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem 00026 // at the GESSI research group at UPC. 00027 // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI 00028 // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a 00029 // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier. 00030 // 00031 // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis 00032 // of the Universitat Politecnica de Catalunya http://www.upc.edu 00033 // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu 00034 00050 require_once("../../config.php"); 00051 require_once($CFG->dirroot.'/mod/lti/lib.php'); 00052 require_once($CFG->libdir.'/plagiarismlib.php'); 00053 00054 $id = optional_param('id', 0, PARAM_INT); // Course module ID 00055 $l = optional_param('l', 0, PARAM_INT); // lti instance ID 00056 $mode = optional_param('mode', 'all', PARAM_ALPHA); // What mode are we in? 00057 $download = optional_param('download' , 'none', PARAM_ALPHA); //ZIP download asked for? 00058 00059 if ($l) { // Two ways to specify the module 00060 $lti = $DB->get_record('lti', array('id' => $l), '*', MUST_EXIST); 00061 $cm = get_coursemodule_from_instance('lti', $lti->id, $lti->course, false, MUST_EXIST); 00062 00063 } else { 00064 $cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST); 00065 $lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST); 00066 } 00067 00068 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 00069 00070 require_login($course, false, $cm); 00071 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 00072 require_capability('mod/lti:grade', $context); 00073 00074 $url = new moodle_url('/mod/lti/grade.php', array('id' => $cm->id)); 00075 if ($mode !== 'all') { 00076 $url->param('mode', $mode); 00077 } 00078 $PAGE->set_url($url); 00079 00080 $module = array( 00081 'name' => 'mod_lti_submissions', 00082 'fullpath' => '/mod/lti/submissions.js', 00083 'requires' => array('base'), 00084 'strings' => array(), 00085 ); 00086 00087 $PAGE->requires->js_init_call('M.mod_lti.submissions.init', array(), true, $module); 00088 00089 $PAGE->requires->yui2_lib('datatable'); 00090 00091 $submissionquery = ' 00092 SELECT s.id, u.firstname, u.lastname, u.id AS userid, s.datesubmitted, s.gradepercent 00093 FROM {lti_submission} s 00094 INNER JOIN {user} u ON s.userid = u.id 00095 WHERE s.ltiid = :ltiid 00096 ORDER BY s.datesubmitted DESC 00097 '; 00098 00099 $submissions = $DB->get_records_sql($submissionquery, array('ltiid' => $lti->id)); 00100 00101 $html = ' 00102 <noscript> 00103 <!-- If javascript is disabled, we need to show the table using CSS. 00104 The table starts out hidden to avoid flickering as it loads --> 00105 <style type="text/css"> 00106 #lti_submissions_table_container { display: block !important; } 00107 </style> 00108 </noscript> 00109 00110 <div id="lti_submissions_table_container" style="display:none"> 00111 <table id="lti_submissions_table"> 00112 <thead> 00113 <tr> 00114 <th>User</th> 00115 <th>Date</th> 00116 <th>Grade</th> 00117 </tr> 00118 </thead> 00119 <tbody> 00120 <!--table body--> 00121 </tbody> 00122 </table> 00123 </div> 00124 '; 00125 00126 $rowtemplate = ' 00127 <tr> 00128 <td> 00129 <!--firstname--> <!--lastname--> 00130 </td> 00131 <td> 00132 <!--datesubmitted--> 00133 </td> 00134 <td> 00135 <!--gradepercent--> 00136 </td> 00137 </tr> 00138 '; 00139 00140 $rows = ''; 00141 00142 foreach ($submissions as $submission) { 00143 $row = $rowtemplate; 00144 00145 foreach ($submission as $key => $value) { 00146 if ($key === 'datesubmitted') { 00147 $value = userdate($value); 00148 } 00149 00150 $row = str_replace('<!--' . $key . '-->', $value, $row); 00151 } 00152 00153 $rows .= $row; 00154 } 00155 00156 $table = str_replace('<!--table body-->', $rows, $html); 00157 00158 $title = 'Submissions for ' . $lti->name; 00159 00160 $PAGE->set_title(format_string($title , true)); 00161 $PAGE->set_heading($course->fullname); 00162 00163 echo $OUTPUT->header(); 00164 echo $OUTPUT->heading($title ); 00165 00166 echo $table; 00167 00168 echo $OUTPUT->footer();