Commit 041ec5f4 authored by Matt Clarkson's avatar Matt Clarkson

Bug 1789297: module/lti: LTI assignment submission

behatnotneeded
Change-Id: I4341264ec1b2d301b9ca9dd5d777fe90ce91a9e6
parent 4467a370
......@@ -1279,7 +1279,7 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
// we are dealing with an annotation added since smartevidence was added
$defaultval = $evidence->state;
if ($options = Framework::get_my_assessment_options_for_user($view->get('owner'), $evidence->framework)) {
if ($options = Framework::get_my_assessment_options_for_user($view, $evidence->framework)) {
if (!array_key_exists($defaultval, $options)) {
$defaultval = null;
}
......
......@@ -1258,7 +1258,7 @@ class Collection {
* @param int $owner The owner of the collection (if not just $USER)
* @throws SystemException
*/
public function submit($group = null, $submittedhost = null, $owner = null) {
public function submit($group = null, $submittedhost = null, $owner = null, $sendnotification=true) {
global $USER;
if ($this->is_submitted()) {
......@@ -1318,7 +1318,7 @@ class Collection {
'name' => $this->name,
'group' => ($group) ? $group->id : null,
'groupname' => ($group) ? $group->name : null));
if ($group) {
if ($group && $sendnotification) {
activity_occurred(
'groupmessage',
array(
......
......@@ -6922,7 +6922,7 @@ class View {
return $data;
}
public function submit($group) {
public function submit($group, $sendnotification=true) {
global $USER;
if ($this->is_submitted()) {
......@@ -6937,31 +6937,34 @@ class View {
'name' => $this->title,
'group' => $group->id,
'groupname' => $group->name));
activity_occurred(
'groupmessage',
array(
'group' => $group->id,
'roles' => $group->roles,
'url' => $this->get_url(false),
'strings' => (object) array(
'urltext' => (object) array('key' => 'view'),
'subject' => (object) array(
'key' => 'viewsubmittedsubject1',
'section' => 'activity',
'args' => array($group->name),
),
'message' => (object) array(
'key' => 'viewsubmittedmessage1',
'section' => 'activity',
'args' => array(
display_name($USER, null, false, true),
$this->title,
$group->name,
if ($sendnotification) {
activity_occurred(
'groupmessage',
array(
'group' => $group->id,
'roles' => $group->roles,
'url' => $this->get_url(false),
'strings' => (object) array(
'urltext' => (object) array('key' => 'view'),
'subject' => (object) array(
'key' => 'viewsubmittedsubject1',
'section' => 'activity',
'args' => array($group->name),
),
'message' => (object) array(
'key' => 'viewsubmittedmessage1',
'section' => 'activity',
'args' => array(
display_name($USER, null, false, true),
$this->title,
$group->name,
),
),
),
),
)
);
)
);
}
}
/**
......
......@@ -828,7 +828,7 @@ class Framework {
return false;
}
$options = self::get_my_assessment_options_for_user($view->get('owner'), $evidence->framework);
$options = self::get_my_assessment_options_for_user($view, $evidence->framework);
if (!$options) {
// not allowed to set the assessment so we just show the current state as html
$choices = self::get_evidence_statuses($collection->get('framework'));
......@@ -942,26 +942,28 @@ class Framework {
/**
* Check to see if a user can set the assessment status for a piece of evidence.
*
* @param string $ownerid The owner of the smart evidence annotation
* @param string $view The view being assessed
* @param string $framework ID of the framework
*
* @return bool
*/
public static function can_assess_user($ownerid, $framework = null) {
return (boolean) static::get_my_assessment_options_for_user($ownerid, $framework);
public static function can_assess_user($view, $framework = null) {
return (boolean) static::get_my_assessment_options_for_user($view, $framework);
}
/**
* Get assessment status options for a piece of evidence.
*
* @param string $ownerid The owner of the smart evidence annotation
* @param string $view The view being assessed
* @param string $framework ID of the framework
* @return array Options for select dropdown
*/
public static function get_my_assessment_options_for_user($ownerid, $framework = null) {
public static function get_my_assessment_options_for_user($view, $framework = null) {
global $USER;
$ownerid = $view->get('owner');
if (empty($ownerid) || !is_numeric($ownerid)) {
return false;
}
......@@ -983,6 +985,11 @@ class Framework {
$isadminofowner = true;
}
}
else if (!empty($USER->get('id')) && group_user_can_assess_submitted_views($view->get('submittedgroup'), $USER->get('id'))) {
if ($USER->get('id') != $owner->get('id')) {
$isadminofowner = true;
}
}
require_once(get_config('libroot') . 'institution.php');
$institution = new Institution($institution);
......
......@@ -97,7 +97,7 @@ else if ($action == 'evidence') {
}
require_once('view.php');
$view = new View($evidence->view);
if (!Framework::can_assess_user($view->get('owner'), $evidence->framework)) {
if (!Framework::can_assess_user($view, $evidence->framework)) {
json_reply(true, get_string('accessdenied', 'error'));
exit;
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="module/lti/db" VERSION="20180307" COMMENT="XMLDB file for lti related tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="lti_assessment">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="oauthserver" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="resourcelinkid" TYPE="text" NOTNULL="true" />
<FIELD NAME="contextid" TYPE="text" NOTNULL="true" />
<FIELD NAME="lisoutcomeserviceurl" TYPE="text" NOTNULL="true" />
<FIELD NAME="contexttitle" TYPE="text" NOTNULL="false" />
<FIELD NAME="resourcelinktitle" TYPE="text" NOTNULL="false" />
<FIELD NAME="group" TYPE="int" NOTNULL="true" />
<FIELD NAME="emailnotifications" TYPE="int" LENGTH="1" DEFAULT="1" NOTNULL="true" />
<FIELD NAME="lock" TYPE="int" LENGTH="1" DEFAULT="1" NOTNULL="true" />
<FIELD NAME="archive" TYPE="int" LENGTH="1" DEFAULT="0" NOTNULL="true" />
<FIELD NAME="timeconfigured" TYPE="datetime" NOTNULL="false" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="oauthserverregistryfk" TYPE="foreign" FIELDS="oauthserver" REFTABLE="oauth_server_registry" REFFIELDS="id" />
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
</KEYS>
<INDEXES>
<INDEX NAME="resourcelinkididx" UNIQUE="false" FIELDS="resourcelinkid" />
<INDEX NAME="contextididx" UNIQUE="false" FIELDS="contextid" />
</INDEXES>
</TABLE>
<TABLE NAME="lti_assessment_submission">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="usr" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="ltiassessment" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="lisresultsourceid" TYPE="text" NOTNULL="true" />
<FIELD NAME="timesubmitted" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="grade" TYPE="int" LENGTH="4" NOTNULL="false" />
<FIELD NAME="timegraded" TYPE="datetime" NOTNULL="false" />
<FIELD NAME="gradedbyusr" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="collectionid" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="viewid" TYPE="int" LENGTH="10" NOTNULL="false" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="userfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="collectionidfk" TYPE="foreign" FIELDS="collectionid" REFTABLE="collection" REFFIELDS="id" />
<KEY NAME="viewfk" TYPE="foreign" FIELDS="viewid" REFTABLE="view" REFFIELDS="id" />
<KEY NAME="ltiassessmentfk" TYPE="foreign" FIELDS="ltiassessment" REFTABLE="lti_assessment" REFFIELDS="id" />
</KEYS>
<INDEXES>
<INDEX NAME="lisresultsourceididx" UNIQUE="false" FIELDS="lisresultsourceid" />
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
<?php
/**
*
* @package mahara
* @subpackage module-lti
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
function xmldb_module_lti_upgrade($oldversion=0) {
$status = true;
/**
* Ensure that all the Web Services tables have been created - even if we
* are transitioning from artefact/webservice to webservice
*/
if ($oldversion < 2018071009) {
log_debug('Adding "lti_assessment" table');
$table = new XMLDBTable('lti_assessment');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('oauthserver', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('resourcelinkid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('contextid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('lisoutcomeserviceurl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('contexttitle', XMLDB_TYPE_TEXT);
$table->addFieldInfo('resourcelinktitle', XMLDB_TYPE_TEXT);
$table->addFieldInfo('group', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('emailnotifications', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 1);
$table->addFieldInfo('lock', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 1);
$table->addFieldInfo('archive', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
$table->addFieldInfo('timeconfigured', XMLDB_TYPE_DATETIME);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('oauthserverregistryfk', XMLDB_KEY_FOREIGN, array('oauthserver'), 'oauth_server_registry', array('id'));
$table->addKeyInfo('groupfk', XMLDB_KEY_FOREIGN, array('group'), 'group', array('id'));
$table->addIndexInfo('resourcelinkididx', XMLDB_INDEX_NOTUNIQUE, array('resourcelinkid'));
$table->addIndexInfo('contextididx', XMLDB_INDEX_NOTUNIQUE, array('contextid'));
create_table($table);
log_debug('Adding "lti_assessment_submission" table');
$table = new XMLDBTable('lti_assessment_submission');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('ltiassessment', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('lisresultsourceid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('timesubmitted', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('grade', XMLDB_TYPE_INTEGER, 4);
$table->addFieldInfo('timegraded', XMLDB_TYPE_DATETIME);
$table->addFieldInfo('gradedbyusr', XMLDB_TYPE_INTEGER, 10);
$table->addFieldInfo('collectionid', XMLDB_TYPE_INTEGER, 10);
$table->addFieldInfo('viewid', XMLDB_TYPE_INTEGER, 10);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('userfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
$table->addKeyInfo('collectionidfk', XMLDB_KEY_FOREIGN, array('collectionid'), 'collection', array('id'));
$table->addKeyInfo('ltiassessmentfk', XMLDB_KEY_FOREIGN, array('ltiassessment'), 'lti_assessment', array('id'));
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('viewid'), 'view', array('id'));
$table->addIndexInfo('lisresultsourceididx', XMLDB_INDEX_NOTUNIQUE, array('lisresultsourceid'));
create_table($table);
}
return true;
}
\ No newline at end of file
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('libroot') . 'collection.php');
require_once(get_config('libroot') . 'view.php');
// We relocated this file to view/index.php now that we have merged the pages and collections list.
// Redirect to the new URL.
$collectionid = param_integer('collectionid', 0);
$viewid = param_integer('viewid', 0);
if ($collectionid) {
$collection = new Collection($collectionid);
redirect($collection->get_url());
}
else if ($viewid) {
$view = new View($viewid);
redirect($view->get_url());
}
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Grade</h3>
<p>Please select a grade from 0 - 100.</p>
......@@ -11,21 +11,52 @@
defined('INTERNAL') || die();
$string['archive'] = 'Archive when graded';
$string['archivedescription'] = 'After a grade has been awarded, a snapshot of the portfolio will be taken.';
$string['autoconfiguredesc'] = 'Automatically enable settings and configurations needed for LTI.';
$string['autoconfiguretitle'] = 'Auto-configure LTI';
$string['autocreateusers'] = 'Auto-create users';
$string['autocreationnotenabled'] = 'Auto-creation of user accounts is not enabled';
$string['configstep'] = 'Conguration item';
$string['portfolioname'] = 'Portfolio title';
$string['configstep'] = 'Configuration item';
$string['configstepstatus'] = 'Status';
$string['configuration'] = 'Assessment settings';
$string['configurationintro'] = 'You can change the submission settings as long as nobody has submitted a portfolio yet. Once there is a submission, the settings are locked in.';
$string['configurationsaved'] = 'Assessment settings saved';
$string['emailtutors'] = 'Email tutors on student submission';
$string['emailtutorsdescription'] = '';
$string['grade_description'] = '';
$string['grade'] = 'Grade';
$string['gradedby'] = 'Graded by';
$string['gradereceived'] = 'You were awarded a grade of %s out of 100 by %s at %s';
$string['gradesubmissions'] = 'Submissions for grading';
$string['gradesubmitted'] = 'Grade successfully submitted';
$string['groupname'] = 'Assessment submissions for "%s" - "%s"';
$string['institutiondenied'] = 'Access to "%s" is denied. Please contact your institution administrator.';
$string['lock'] = 'Unlock portfolio after grading';
$string['lockdescription'] = 'Users make changes to their portfolio after it has been graded.';
$string['ltiserviceexists'] = 'The LTI service group is registered.';
$string['nocollections'] = 'You do not have any portfolios that can be submitted for assessment.';
$string['noticeenabled'] = 'The LTI API is enabled.';
$string['noticenotenabled'] = 'The LTI API is <b>not</b> enabled.';
$string['notconfigured'] = 'Currently, this activity does not allow submissions. Please check back later.';
$string['notreadylabel'] = 'Not ready';
$string['oauthprotocolenabled'] = 'OAuth protocol enabled';
$string['parentauthforlti'] = 'Parent authority';
$string['portfoliosubmitted'] = 'You submitted the portfolio "%s" for assessment on %s.';
$string['readylabel'] = 'Ready';
$string['restprotocolenabled'] = 'REST protocol enabled';
$string['usernameexists2'] = 'Username "%s" is not valid.';
$string['saveandrelease'] = 'Save and allow submissions';
$string['submitportfolio'] = 'Submit a portfolio for assessment';
$string['submitto'] = 'Submit this portfolio for assessment to %s, %s';
$string['submitintro'] = 'Select the page or collection that you want to submit to this activity. If you do not yet have a portfolio, <a href="%sview/index.php" target="_blank">create one</a>. Once you are done, reload the activity from the LMS.';
$string['timegraded'] = 'Time graded';
$string['timesubmitted'] = 'Time submitted';
$string['usernameexists1'] = 'Username "%s" already exists.';
$string['viewsubmittedmessage1'] = '%s has submitted "%s" to %s
Please grade this submission via "%s"';
$string['viewsubmittedsubject1'] = 'Assessment submission to %s';
$string['webserviceauthdisabled'] = 'Web service authentication is not enabled for this institution';
$string['webserviceproviderenabled'] = 'Incoming web service requests allowed';
$string['institutiondenied'] = 'Access to \'%s\' is denied. Please contact your institution administrator.';
$string['notreadylabel'] = 'Not ready';
$string['readylabel'] = 'Ready';
$string['parentauthforlti'] = 'Parent authority';
This diff is collapsed.
<?php
/**
*
* @package mahara
* @subpackage module-lti
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'configextensions/frameworks');
define('SECTION_PLUGINTYPE', 'module');
define('SECTION_PLUGINNAME', 'lti');
define('SECTION_PAGE', 'submission');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('submitportfolio', 'module.lti'));
safe_require('module', 'lti');
if (PluginModuleLti::can_grade()) {
$form = PluginModuleLti::config_form();
}
else if (PluginModuleLti::can_submit_for_grading()) {
$form = PluginModuleLti::submit_for_grading_form();
}
$smarty = smarty();
if ($SESSION->get('lti.presentation_target') != 'window') {
$smarty->assign('SIDEBARS', false);
$smarty->assign('presentation', 'presentation-iframe');
}
if (PluginModuleLti::can_grade()) {
$smarty->assign('PAGEHEADING', get_string('gradesubmissions', 'module.lti'));
if (!$submissions = PluginModuleLti::get_all_submissions()) {
// Assessment configuration form
$smarty->assign('PAGEHEADING', get_string('configuration', 'module.lti'));
$smarty->assign('form', $form);
$smarty->display('module:lti:config.tpl');
}
else {
// List of submissions
$smarty->assign('submissions', $submissions);
$smarty->display('module:lti:submissions.tpl');
}
}
else if (PluginModuleLti::can_submit_for_grading()) {
$smarty->assign('PAGEHEADING', get_string('submitportfolio', 'module.lti'));
$sub = PluginModuleLti::get_submission();
if ($sub && $sub->is_submitted()) {
// Info on submitted collection
$info = $sub->get_portfolio_info();
$grader = $sub->get_grader();
$smarty->assign('title', $info->title);
$smarty->assign('link', $info->link);
$smarty->assign('timesubmitted', $sub->timesubmitted);
$smarty->assign('grade', $sub->grade);
$smarty->assign('gradedby', empty($grader) ? '' : display_name($grader));
$smarty->assign('timegraded', $sub->timegraded);
$smarty->display('module:lti:submittedforgrading.tpl');
}
else if (PluginModuleLTI::activity_configured()) {
// Assessment submission form
$smarty->assign('form', $form);
$smarty->display('module:lti:submitforgrading.tpl');
}
else {
$smarty->assign('error', get_string('notconfigured', 'module.lti'));
$smarty->display('module:lti:submitforgrading.tpl');
}
}
else {
throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
\ No newline at end of file
......@@ -12,5 +12,5 @@
defined('INTERNAL') || die();
$config = new stdClass();
$config->version = 2017030600;
$config->release = '1.0.0';
$config->version = 2018071009;
$config->release = '1.1.0';
......@@ -72,6 +72,15 @@ class module_lti_launch extends external_api {
'custom_canvas_user_id' => new external_value(PARAM_TEXT, 'LTI custom_canvas_user_id', VALUE_OPTIONAL),
'custom_canvas_user_login_id' => new external_value(PARAM_TEXT, 'LTI custom_canvas_user_login_id', VALUE_OPTIONAL),
'custom_canvas_workflow_state' => new external_value(PARAM_TEXT, 'LTI custom_canvas_workflow_state', VALUE_OPTIONAL),
'ext_ims_lis_basic_outcome_url' => new external_value(PARAM_TEXT, 'LTI ext_ims_lis_basic_outcome_url', VALUE_OPTIONAL),
'ext_lti_assignment_id' => new external_value(PARAM_TEXT, 'LTI ext_lti_assignment_id', VALUE_OPTIONAL),
'ext_outcome_data_values_accepted' => new external_value(PARAM_TEXT, 'LTI ext_outcome_data_values_accepted', VALUE_OPTIONAL),
'ext_outcome_result_total_score_accepted' => new external_value(PARAM_TEXT, 'LTI ext_outcome_result_total_score_accepted', VALUE_OPTIONAL),
'ext_outcome_submission_submitted_at_accepted' => new external_value(PARAM_TEXT, 'LTI ext_outcome_submission_submitted_at_accepted', VALUE_OPTIONAL),
'ext_outcomes_tool_placement_url' => new external_value(PARAM_TEXT, 'LTI ext_outcomes_tool_placement_url', VALUE_OPTIONAL),
'custom_canvas_assignment_id' => new external_value(PARAM_TEXT, 'LTI custom_canvas_assignment_id', VALUE_OPTIONAL),
'custom_canvas_assignment_points_possible' => new external_value(PARAM_TEXT, 'LTI custom_canvas_assignment_points_possible', VALUE_OPTIONAL),
'custom_canvas_assignment_title' => new external_value(PARAM_TEXT, 'LTI custom_canvas_assignment_title', VALUE_OPTIONAL),
// Blackboard specific LTI params
'ext_launch_id' => new external_value(PARAM_TEXT, 'Blackboard ext_launch_id', VALUE_OPTIONAL),
......@@ -228,21 +237,82 @@ class module_lti_launch extends external_api {
$SESSION->set('logouturl', $params['launch_presentation_return_url']);
}
$SESSION->set('lti.lis_result_sourcedid', $params['lis_result_sourcedid']);
$SESSION->set('lti.roles', $params['roles']);
$SESSION->set('lti.presentation_target', $params['launch_presentation_document_target']);
$SESSION->set('lti.launch_presentation_return_url', $params['launch_presentation_return_url']);
$parts = parse_url($params['launch_presentation_return_url']);
$cspurl = $parts['scheme'] . '://' . $parts['host'];
$SESSION->set('csp-ancestor-exemption', $cspurl);
// If the consumer supports grading send the user to select a portfolio
if (!empty($params['lis_outcome_service_url'])) {
db_begin();
if ($assessment = get_record('lti_assessment', 'oauthserver', $WEBSERVICE_OAUTH_SERVERID, 'resourcelinkid', $params['resource_link_id'])) {
if ($assessment->contexttitle != $params['context_title'] || $assessment->resourcelinktitle != $params['resource_link_title']) {
$assessment->contexttitle = $params['context_title'];
$assessment->resourcelinktitle = $params['resource_link_title'];
update_record('lti_assessment', $assessment);
}
$groups = $USER->get('grouproles');
if (!isset($groups[$assessment->group])) {
group_add_user($assessment->group, $USER->get('id'), PluginModuleLti::can_grade() ? 'admin' : 'member');
}
}
else {
$SESSION->set('lti.lis_outcome_service_url', $params['lis_outcome_service_url']);
$SESSION->set('lti.lis_result_sourcedid', $params['lis_result_sourcedid']);
$SESSION->set('lti.roles', $params['roles']);
$SESSION->set('lti.serverid', $WEBSERVICE_OAUTH_SERVERID);
$SESSION->set('lti.presentation_target', $params['launch_presentation_document_target']);
if (!$groupid = get_field('lti_assessment', 'group', 'oauthserver', $WEBSERVICE_OAUTH_SERVERID, 'contextid', $params['context_id'], 'resourcelinkid', $params['resource_link_id'])) {
$basename = get_string('groupname', 'module.lti', $params['context_title'], $params['resource_link_title']);
$name = $basename;
// generate a unique group name
$i = 0;
while (get_record('group', 'name', $name)) {
$name = $basename . ' - ' . $i++;
}
// Create assessment group
$group = array(
'name' => $name,
'institution' => $WEBSERVICE_INSTITUTION,
'grouptype' => 'standard',
'submittableto' => true,
'hidemembersfrommembers' => true,
'hidemembers' => true,
'members' => array($USER->get('id') => PluginModuleLti::can_grade() ? 'admin' : 'member'),
'allowarchives' => true,
'hidden' => true,
'submittableto' => false,
);
$groupid = group_create($group);
}
// Create assessment record
$assessment = new stdClass;
$assessment->oauthserver = $WEBSERVICE_OAUTH_SERVERID;
$assessment->resourcelinkid = $params['resource_link_id'];
$assessment->contextid = $params['context_id'];
$assessment->lisoutcomeserviceurl = $params['lis_outcome_service_url'];
$assessment->contexttitle = $params['context_title'];
$assessment->resourcelinktitle = $params['resource_link_title'];
$assessment->group = $groupid;
$assessment->id = insert_record('lti_assessment', $assessment, 'id', true);
}
$parts = parse_url($params['lis_outcome_service_url']);
$cspurl = $parts['scheme'] . '://' . $parts['host'];
db_commit();
$SESSION->set('csp-ancestor-exemption', $cspurl);
$SESSION->set('lti.assessment', $assessment->id);
redirect(get_config('wwwroot').'module/lti/submission.php');
redirect(get_config('wwwroot') . 'module/lti/submission.php');
exit;
}
......
{include file="header.tpl"}
{str tag=configurationintro section=module.lti}
{$form|safe}
{include file="footer.tpl"}
\ No newline at end of file
{include file="header.tpl"}
<table id="searchresults" class="table table-striped fullwidth listing">
<thead>