Skip to content

Commit

Permalink
Merge pull request #65 from Panopto/staging
Browse files Browse the repository at this point in the history
2023031300 Release Merge
  • Loading branch information
jmalmsten-panopto authored Mar 14, 2023
2 parents ab7c06b + 564c521 commit 83d5a01
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 151 deletions.
2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ protected static function has_marked_panoptosubmission_submissions($panoptosubmi

$params = [
'panactivityid' => $panoptosubmissionid,
'teacher' => $userid
'teacher' => $userid
];

$sql = "SELECT count(s.id) as nomarked " .
Expand Down
24 changes: 22 additions & 2 deletions contentitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@

$courseid = required_param('courseid', PARAM_INT);

/**
* Student Submission path.
*/
const STUDENT_SUBMISSION_PATH = '/mod/panoptosubmission/contentitem_return.php';

// Check access and capabilities.
$course = get_course($courseid);
require_login($course);
Expand All @@ -43,10 +48,25 @@
}

// LTI 1.3 login request.
$isthismoodle41 = empty($CFG->version) ? false : $CFG->version >= 2022112800.00;
$config = lti_get_type_type_config($toolid);

if ($config->lti_ltiversion === LTI_VERSION_1P3) {
$lti = null;
if ($isthismoodle41) {
// Moodle 4.1 needs LTI object.
$lti = new stdClass();

// Give it some random id, this is not used in the code but will create a PHP notice if not provided.
$ltiviewerurl = new moodle_url(STUDENT_SUBMISSION_PATH);
$resourcelinkid = sha1($ltiviewerurl->out(false) .
'&' . $courseid .
'&' . $course->timecreated
);
$lti->id = $resourcelinkid;
}
if (!isset($SESSION->lti_initiatelogin_status)) {
echo lti_initiate_login($courseid, "mod_panoptosubmission", null, $config);
echo lti_initiate_login($courseid, "mod_panoptosubmission", $lti, $config);
exit;
} else {
unset($SESSION->lti_initiatelogin_status);
Expand All @@ -61,7 +81,7 @@
'sesskey' => sesskey()
];

$returnurl = new \moodle_url('/mod/panoptosubmission/contentitem_return.php', $returnurlparams);
$returnurl = new \moodle_url(STUDENT_SUBMISSION_PATH, $returnurlparams);

// Prepare the request.
$request = lti_build_content_item_selection_request(
Expand Down
4 changes: 2 additions & 2 deletions contentitem_return.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
require_once(dirname(dirname(dirname(__FILE__))) . '/mod/lti/locallib.php');

$courseid = required_param('course', PARAM_INT);
$id = required_param('id', PARAM_INT);
$jwt = optional_param('JWT', '', PARAM_RAW);
$id = required_param('id', PARAM_INT);
$jwt = optional_param('JWT', '', PARAM_RAW);

require_login($courseid);

Expand Down
2 changes: 1 addition & 1 deletion grade_preferences_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function definition() {
$context = context_module::instance($this->_customdata['cmid']);

$groupopt = array();
$groups = array();
$groups = array();

// If the user doesn't have access to all group print the groups they have access to.
if (!has_capability('moodle/site:accessallgroups', $context)) {
Expand Down
40 changes: 20 additions & 20 deletions grade_submissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/grade_preferences_form.php');

$id = required_param('cmid', PARAM_INT); // Course Module ID.
$mode = optional_param('mode', 0, PARAM_TEXT);
$id = required_param('cmid', PARAM_INT); // Course Module ID.
$mode = optional_param('mode', 0, PARAM_TEXT);
$tifirst = optional_param('tifirst', '', PARAM_TEXT);
$tilast = optional_param('tilast', '', PARAM_TEXT);
$page = optional_param('page', 0, PARAM_INT);
$tilast = optional_param('tilast', '', PARAM_TEXT);
$page = optional_param('page', 0, PARAM_INT);

$url = new moodle_url('/mod/panoptosubmission/grade_submissions.php');
$url->param('cmid', $id);
Expand Down Expand Up @@ -62,8 +62,8 @@
require_capability('mod/panoptosubmission:gradesubmission', $context);

$event = \mod_panoptosubmission\event\grade_submissions_page_viewed::create(array(
'objectid' => $pansubmissionactivity->id,
'context' => $context
'objectid' => $pansubmissionactivity->id,
'context' => $context
));
$event->trigger();

Expand Down Expand Up @@ -104,9 +104,9 @@
$data = new stdClass();
}

$data->filter = get_user_preferences('panoptosubmission_filter', 0);
$data->quickgrade = get_user_preferences('panoptosubmission_quickgrade', 0);
$data->perpage = get_user_preferences('panoptosubmission_perpage', 10);
$data->filter = get_user_preferences('panoptosubmission_filter', 0);
$data->quickgrade = get_user_preferences('panoptosubmission_quickgrade', 0);
$data->perpage = get_user_preferences('panoptosubmission_perpage', 10);
$data->group_filter = get_user_preferences('panoptosubmission_group_filter', 0);

$gradedata = data_submitted();
Expand Down Expand Up @@ -160,21 +160,21 @@

// Add to log only if updating.
$event = \mod_panoptosubmission\event\grades_updated::create(array(
'context' => $context,
'other' => array(
'crud' => 'u'
'context' => $context,
'other' => array(
'crud' => 'u'
)
));
$event->trigger();
}

} else {
// No user submission however the instructor has submitted grade data.
$usersubmissions = new stdClass();
$usersubmissions->panactivityid = $cm->instance;
$usersubmissions->userid = $userid;
$usersubmissions->teacher = $USER->id;
$usersubmissions->timemarked = $time;
$usersubmissions = new stdClass();
$usersubmissions->panactivityid = $cm->instance;
$usersubmissions->userid = $userid;
$usersubmissions->teacher = $USER->id;
$usersubmissions->timemarked = $time;

// Need to prevent completely empty submissions from getting entered.
// Into the video submissions' table.
Expand Down Expand Up @@ -209,9 +209,9 @@

// Add to log only if updating.
$event = \mod_panoptosubmission\event\grades_updated::create(array(
'context' => $context,
'other' => array(
'crud' => 'c'
'context' => $context,
'other' => array(
'crud' => 'c'
)
));
$event->trigger();
Expand Down
48 changes: 24 additions & 24 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ function panoptosubmission_add_instance($newactivity) {
if ($newactivity->timedue) {
$event = new stdClass();

$event->name = $newactivity->name;
$event->name = $newactivity->name;
$event->description = format_module_intro('panoptosubmission', $newactivity, $newactivity->coursemodule, false);
$event->format = FORMAT_HTML;
$event->courseid = $newactivity->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'panoptosubmission';
$event->instance = $newactivity->id;
$event->eventtype = 'due';
$event->timestart = $newactivity->timedue;
$event->format = FORMAT_HTML;
$event->courseid = $newactivity->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'panoptosubmission';
$event->instance = $newactivity->id;
$event->eventtype = 'due';
$event->timestart = $newactivity->timedue;
$event->timeduration = 0;

calendar_event::create($event);
Expand Down Expand Up @@ -87,25 +87,25 @@ function panoptosubmission_update_instance($targetinstance) {
if ($event->id = $DB->get_field(
'event', 'id', array('modulename' => 'panoptosubmission', 'instance' => $targetinstance->id))) {

$event->name = $targetinstance->name;
$event->name = $targetinstance->name;
$event->description = format_module_intro('panoptosubmission', $targetinstance, $targetinstance->coursemodule, false);
$event->format = FORMAT_HTML;
$event->timestart = $targetinstance->timedue;
$event->format = FORMAT_HTML;
$event->timestart = $targetinstance->timedue;

$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
$event = new stdClass();
$event->name = $targetinstance->name;
$event->name = $targetinstance->name;
$event->description = format_module_intro('panoptosubmission', $targetinstance, $targetinstance->coursemodule, false);
$event->format = FORMAT_HTML;
$event->courseid = $targetinstance->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'panoptosubmission';
$event->instance = $targetinstance->id;
$event->eventtype = 'due';
$event->timestart = $targetinstance->timedue;
$event->format = FORMAT_HTML;
$event->courseid = $targetinstance->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'panoptosubmission';
$event->instance = $targetinstance->id;
$event->eventtype = 'due';
$event->timestart = $targetinstance->timedue;
$event->timeduration = 0;

calendar_event::create($event);
Expand Down Expand Up @@ -308,12 +308,12 @@ function panoptosubmission_grade_item_update($targetinstance, $grades = null) {

if ($targetinstance->grade > 0) {
$params['gradetype'] = GRADE_TYPE_VALUE;
$params['grademax'] = $targetinstance->grade;
$params['grademin'] = 0;
$params['grademax'] = $targetinstance->grade;
$params['grademin'] = 0;

} else if ($targetinstance->grade < 0) {
$params['gradetype'] = GRADE_TYPE_SCALE;
$params['scaleid'] = -$targetinstance->grade;
$params['scaleid'] = -$targetinstance->grade;

} else {
$params['gradetype'] = GRADE_TYPE_TEXT;
Expand Down
42 changes: 21 additions & 21 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ function panoptosubmission_email_teachers($cm, $name, $submission, $context) {
if ($teachers = panoptosubmission_get_graders($cm, $user, $context)) {

$strassignments = get_string('modulenameplural', 'panoptosubmission');
$strassignment = get_string('modulename', 'panoptosubmission');
$strsubmitted = get_string('submitted', 'panoptosubmission');
$strassignment = get_string('modulename', 'panoptosubmission');
$strsubmitted = get_string('submitted', 'panoptosubmission');

foreach ($teachers as $teacher) {
$info = new stdClass();
Expand All @@ -240,28 +240,28 @@ function panoptosubmission_email_teachers($cm, $name, $submission, $context) {
$info->url = $CFG->wwwroot . '/mod/panoptosubmission/grade_submissions.php?cmid=' . $cm->id;
$info->timeupdated = strftime('%c', $submission->timemodified);
$info->courseid = $cm->course;
$info->cmid = $cm->id;
$info->cmid = $cm->id;

$postsubject = $strsubmitted . ': ' . $user->username . ' -> ' . $name;
$posttext = panoptosubmission_email_teachers_text($info);
$posthtml = ($teacher->mailformat == 1) ? panoptosubmission_email_teachers_html($info) : '';

$eventdata = new \core\message\message();
$eventdata->courseid = $COURSE->id;
$eventdata->modulename = 'panoptosubmission';
$eventdata->userfrom = $user;
$eventdata->userto = $teacher;
$eventdata->subject = $postsubject;
$eventdata->fullmessage = $posttext;
$eventdata->courseid = $COURSE->id;
$eventdata->modulename = 'panoptosubmission';
$eventdata->userfrom = $user;
$eventdata->userto = $teacher;
$eventdata->subject = $postsubject;
$eventdata->fullmessage = $posttext;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = $posthtml;
$eventdata->smallmessage = $postsubject;
$eventdata->fullmessagehtml = $posthtml;
$eventdata->smallmessage = $postsubject;

$eventdata->name = 'panoptosubmission_updates';
$eventdata->component = 'mod_panoptosubmission';
$eventdata->notification = 1;
$eventdata->contexturl = $info->url;
$eventdata->contexturlname = $info->assignment;
$eventdata->name = 'panoptosubmission_updates';
$eventdata->component = 'mod_panoptosubmission';
$eventdata->notification = 1;
$eventdata->contexturl = $info->url;
$eventdata->contexturlname = $info->assignment;

message_send($eventdata);
}
Expand Down Expand Up @@ -330,12 +330,12 @@ function panoptosubmission_get_graders($cm, $user, $context) {
function panoptosubmission_email_teachers_text($info) {
global $DB;

$param = array('id' => $info->courseid);
$course = $DB->get_record('course', $param);
$param = array('id' => $info->courseid);
$course = $DB->get_record('course', $param);
$posttext = '';

if (!empty($course)) {
$posttext = format_string($course->shortname, true, $course->id) . ' -> ' .
$posttext = format_string($course->shortname, true, $course->id) . ' -> ' .
get_string('modulenameplural', 'panoptosubmission') . ' -> ';
$posttext .= format_string($info->assignment, true, $course->id) . "\n";
$posttext .= '---------------------------------------------------------------------' . "\n";
Expand All @@ -355,8 +355,8 @@ function panoptosubmission_email_teachers_text($info) {
function panoptosubmission_email_teachers_html($info) {
global $CFG, $DB;

$param = array('id' => $info->courseid);
$course = $DB->get_record('course', $param);
$param = array('id' => $info->courseid);
$course = $DB->get_record('course', $param);
$posthtml = '';

if (!empty($course)) {
Expand Down
Loading

0 comments on commit 83d5a01

Please sign in to comment.