Permalink
Browse files

Updating LTI submission viewer

  • Loading branch information...
1 parent a35626f commit f4f711d79b1c9c3de2ca55c7905c2b93057f82b9 @scriby scriby committed Sep 28, 2011
View
@@ -44,7 +44,7 @@
$capabilities = array(
- 'mod/ltii:view' => array(
+ 'mod/lti:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/lti/db" VERSION="20110901" COMMENT="XMLDB file for Moodle mod/lti"
+<XMLDB PATH="mod/lti/db" VERSION="20110923" COMMENT="XMLDB file for Moodle mod/lti"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -58,7 +58,7 @@
<INDEX NAME="tooldomain" UNIQUE="false" FIELDS="tooldomain" PREVIOUS="course"/>
</INDEXES>
</TABLE>
- <TABLE NAME="lti_types_config" COMMENT="Basic LTI types configuration" PREVIOUS="lti_types">
+ <TABLE NAME="lti_types_config" COMMENT="Basic LTI types configuration" PREVIOUS="lti_types" NEXT="lti_submission">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="typeid"/>
<FIELD NAME="typeid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Basic LTI type id" PREVIOUS="id" NEXT="name"/>
@@ -72,5 +72,24 @@
<INDEX NAME="typeid" UNIQUE="false" FIELDS="typeid"/>
</INDEXES>
</TABLE>
+ <TABLE NAME="lti_submission" COMMENT="Keeps track of individual submissions for LTI activities." PREVIOUS="lti_types_config">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="ltiid"/>
+ <FIELD NAME="ltiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="ID of the LTI tool instance" PREVIOUS="id" NEXT="userid"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="ltiid" NEXT="datesubmitted"/>
+ <FIELD NAME="datesubmitted" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="userid" NEXT="dateupdated"/>
+ <FIELD NAME="dateupdated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="datesubmitted" NEXT="gradepercent"/>
+ <FIELD NAME="gradepercent" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="5" PREVIOUS="dateupdated" NEXT="originalgrade"/>
+ <FIELD NAME="originalgrade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="5" PREVIOUS="gradepercent" NEXT="launchid"/>
+ <FIELD NAME="launchid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="originalgrade" NEXT="state"/>
+ <FIELD NAME="state" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="launchid"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+ </KEYS>
+ <INDEXES>
+ <INDEX NAME="ltiid" UNIQUE="false" FIELDS="ltiid"/>
+ </INDEXES>
+ </TABLE>
</TABLES>
</XMLDB>
@@ -89,4 +89,96 @@
require_capability('mod/lti:grade', get_context_instance(CONTEXT_MODULE, $cm->id));
-lti_submissions($cm, $course, $basiclti, $mode); // Display or process the submissions
+//lti_submissions($cm, $course, $basiclti, $mode); // Display or process the submissions
+
+$module = array(
+ 'name' => 'mod_lti_submissions',
+ 'fullpath' => '/mod/lti/submissions.js',
+ 'requires' => array('base'),
+ 'strings' => array(
+
+ ),
+);
+
+$PAGE->requires->js_init_call('M.mod_lti.submissions.init', array(), true, $module);
+
+$PAGE->requires->yui2_lib('datatable');
+
+$submissionquery = <<<SQL
+ SELECT s.id, u.firstname, u.lastname, u.id AS userid, s.datesubmitted, s.gradepercent
+ FROM {lti_submission} s
+ INNER JOIN {user} u ON s.userid = u.id
+ WHERE s.ltiid = :ltiid
+ ORDER BY s.datesubmitted DESC
+SQL;
+
+$submissions = $DB->get_records_sql($submissionquery, array('ltiid' => $basiclti->id));
+
+$html = <<<HTML
+<noscript>
+ <!-- If javascript is disabled, we need to show the table using CSS.
+ The table starts out hidden to avoid flickering as it loads -->
+ <style type="text/css">
+ #lti_submissions_table_container { display: block !important; }
+ </style>
+</noscript>
+
+<div id="lti_submissions_table_container" style="display:none">
+ <table id='lti_submissions_table'>
+ <thead>
+ <tr>
+ <th>User</th>
+ <th>Date</th>
+ <th>Grade</th>
+ </tr>
+ </thead>
+ <tbody>
+ <!--table body-->
+ </tbody>
+ </table>
+</div>
+HTML;
+
+$rowtemplate = <<<HTML
+<tr>
+ <td>
+ <!--firstname--> <!--lastname-->
+ </td>
+ <td>
+ <!--datesubmitted-->
+ </td>
+ <td>
+ <!--gradepercent-->
+ </td>
+</tr>
+HTML;
+
+$rows = '';
+
+foreach($submissions as $submission){
+ $row = $rowtemplate;
+
+ foreach($submission as $key => $value){
+ if($key === 'datesubmitted'){
+ $value = userdate($value);
+ }
+
+ $row = str_replace('<!--' . $key . '-->', $value, $row);
+ }
+
+ $rows .= $row;
+}
+
+$table = str_replace('<!--table body-->', $rows, $html);
+
+$title = 'Submissions for ' . $basiclti->name;
+
+$PAGE->set_title(format_string($title , true));
+$PAGE->set_heading($course->fullname);
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading($title );
+
+echo $table;
+
+echo $OUTPUT->footer();
Oops, something went wrong.

0 comments on commit f4f711d

Please sign in to comment.