Skip to content

Commit

Permalink
2017032203 release code. (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalmsten-panopto authored Mar 22, 2017
1 parent 73dd202 commit 4a1cb4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions lib/panopto_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,38 @@ public function get_provisioning_info($getsharedinfo = true) {
$mappedpanoptocourse = $this->get_course();
}

if (isset($mappedpanoptocourse)) {
$provisioninginfo->ExternalCourseID = $this->instancename . ':' . $this->moodlecourseid;

if (isset($mappedpanoptocourse) && ($provisioninginfo->ExternalCourseID !== $mappedpanoptocourse->ExternalCourseID)) {
$provisioninginfo->ExternalCourseID = $mappedpanoptocourse->ExternalCourseID;

$namechunks = explode(':', $mappedpanoptocourse->DisplayName);
// Display names generated by panopto are formatted like <shortname>:<longname>, this assumes that format.
// Hacky but there is not much else we can do until we move to provisioning by folder ID.
if (count($namechunks) === 2) {

$chunkscount = count($namechunks);
if ($chunkscount === 2) {
$provisioninginfo->shortname = $namechunks[0];
$provisioninginfo->longname = $namechunks[1];
} else if ($chunkscount === 1) {
// This is a weird case I don't expect to happen. This should only occur if the user maps to a panopto folder that does not contain any colons.
$provisioninginfo->shortname = '';
$provisioninginfo->longname = $namechunks[0];
} else {
$provisioninginfo->shortname = substr($mappedpanoptocourse->DisplayName, 0, 5);
$provisioninginfo->longname = $mappedpanoptocourse->DisplayName;
$provisioninginfo->shortname = $namechunks[0];
$mappedlongname = '';

// If there are more than 2 chunks take the chunks after the first one and combine them into a longname.
// Panopto should recombine these into the original namechunk[0]:mappedlongname. Where mappedlongname = namechunk[1]:namechunk[2]:...:namechunk[n]
for ($i = 1; $i < count($namechunks); ++$i) {
$mappedlongname .= $namechunks[$i];

if ($i !== $chunkscount - 1) {
$mappedlongname .= ':';
}
}

$provisioninginfo->longname = $mappedlongname;
}
} else {
$provisioninginfo->shortname = $DB->get_field(
Expand All @@ -413,8 +433,6 @@ public function get_provisioning_info($getsharedinfo = true) {
if (!isset($provisioninginfo->shortname) || empty($provisioninginfo->shortname)) {
$provisioninginfo->shortname = substr($provisioninginfo->longname, 0, 5);
}

$provisioninginfo->ExternalCourseID = $this->instancename . ':' . $this->moodlecourseid;
}

$provisioninginfo->Server = $this->servername;
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Plugin version should normally be the same as the internal version.
// If an admin wants to install with an older version number, however, set that here.
$plugin->version = 2017032000;
$plugin->version = 2017032203;

// Requires this Moodle version - 2.7.
$plugin->requires = 2014051200;
Expand Down

0 comments on commit 4a1cb4f

Please sign in to comment.