Skip to content

Commit

Permalink
Replace remove $CFG->completiondefault
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Nov 11, 2023
1 parent d608ec2 commit 6998088
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
19 changes: 13 additions & 6 deletions classes/local/activitymodulemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public static function create_module_for_series($courseid, $ocinstanceid, $title
}

// Create an LTI modinfo object.
$moduleinfo = self::build_activity_modinfo($pluginid, $ocinstanceid, $title, $sectionid, $seriesid, opencasttype::SERIES,
$introtext, $introformat, $availability, $allowdownload);
$moduleinfo = self::build_activity_modinfo($pluginid, $course, $ocinstanceid, $title, $sectionid, $seriesid,
opencasttype::SERIES, $introtext, $introformat, $availability, $allowdownload);

// Add the Opencast Activity series module to the given course.
// This does not check any capabilities to add modules to courses by purpose.
Expand Down Expand Up @@ -158,7 +158,7 @@ public static function create_module_for_episode($courseid, $ocinstanceid, $titl
}

// Create an Opencast Activity modinfo object.
$moduleinfo = self::build_activity_modinfo($pluginid, $ocinstanceid, $title, $sectionid, $episodeuuid,
$moduleinfo = self::build_activity_modinfo($pluginid, $course, $ocinstanceid, $title, $sectionid, $episodeuuid,
opencasttype::EPISODE, $introtext, $introformat, $availability, $allowdownload);

// Add the Opencast Activity episode module to the given course.
Expand All @@ -172,6 +172,7 @@ public static function create_module_for_episode($courseid, $ocinstanceid, $titl
* Helperfunction to create a modinfo class, holding the Opencast LTI module information.
*
* @param int $pluginid
* @param \stdClass $course
* @param int $ocinstanceid Opencast instance id
* @param string $title
* @param int $sectionid
Expand All @@ -184,10 +185,10 @@ public static function create_module_for_episode($courseid, $ocinstanceid, $titl
*
* @return object
*/
public static function build_activity_modinfo($pluginid, $ocinstanceid, $title, $sectionid, $opencastid, $type,
public static function build_activity_modinfo($pluginid, $course, $ocinstanceid, $title, $sectionid, $opencastid, $type,
$introtext = '', $introformat = FORMAT_HTML, $availability = null,
$allowdownload = false) {
global $CFG;
global $DB;

// Create standard class object.
$moduleinfo = new \stdClass();
Expand All @@ -211,13 +212,19 @@ public static function build_activity_modinfo($pluginid, $ocinstanceid, $title,
$moduleinfo->groupmode = NOGROUPS;
$moduleinfo->groupingid = 0;
$moduleinfo->availability = $availability;
$moduleinfo->completion = $CFG->completiondefault;

// Populate the modinfo object with opencast activity specific parameters.
$moduleinfo->type = $type;
$moduleinfo->opencastid = $opencastid;
$moduleinfo->ocinstanceid = $ocinstanceid;

// Apply completion defaults.
$module = $DB->get_record('modules', array('name' => 'opencast'), '*', MUST_EXIST);
$defaults = \core_completion\manager::get_default_completion($course, $module);
foreach ($defaults as $key => $value) {
$moduleinfo->$key = $value;
}

// Return modinfo.
return $moduleinfo;
}
Expand Down
21 changes: 14 additions & 7 deletions classes/local/ltimodulemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ public static function create_module_for_series($ocinstanceid, $courseid, $title
}

// Create an LTI modinfo object.
$moduleinfo = self::build_lti_modinfo($pluginid, $title, $sectionid, $toolid, 'series=' . $seriesid, $introtext,
$introformat, $availability);
$moduleinfo = self::build_lti_modinfo($pluginid, $course, $title, $sectionid, $toolid, 'series=' . $seriesid,
$introtext, $introformat, $availability);

// Add the LTI series module to the given course (this doesn't check any capabilities to add modules to courses by purpose).
$modulecreated = \add_moduleinfo($moduleinfo, $course);
Expand Down Expand Up @@ -376,7 +376,7 @@ public static function create_module_for_episode($ocinstanceid, $courseid, $titl
}

// Create an LTI modinfo object.
$moduleinfo = self::build_lti_modinfo($pluginid, $title, $sectionid, $toolid, 'id=' . $episodeuuid, $introtext,
$moduleinfo = self::build_lti_modinfo($pluginid, $course, $title, $sectionid, $toolid, 'id=' . $episodeuuid, $introtext,
$introformat, $availability);

// Add the LTI episode module to the given course. This doesn't check any capabilities to add modules to courses by purpose.
Expand All @@ -397,6 +397,7 @@ public static function create_module_for_episode($ocinstanceid, $courseid, $titl
* Helperfunction to create a modinfo class, holding the Opencast LTI module information.
*
* @param int $pluginid
* @param \stdClass $course
* @param string $title
* @param int $sectionid
* @param int $toolid
Expand All @@ -407,9 +408,9 @@ public static function create_module_for_episode($ocinstanceid, $courseid, $titl
*
* @return object
*/
public static function build_lti_modinfo($pluginid, $title, $sectionid, $toolid, $instructorcustomparameters, $introtext = '',
$introformat = FORMAT_HTML, $availability = null) {
global $CFG;
public static function build_lti_modinfo($pluginid, $course, $title, $sectionid, $toolid, $instructorcustomparameters,
$introtext = '', $introformat = FORMAT_HTML, $availability = null) {
global $DB;

// Create standard class object.
$moduleinfo = new \stdClass();
Expand All @@ -432,7 +433,13 @@ public static function build_lti_modinfo($pluginid, $title, $sectionid, $toolid,
$moduleinfo->groupmode = NOGROUPS;
$moduleinfo->groupingid = 0;
$moduleinfo->availability = $availability;
$moduleinfo->completion = $CFG->completiondefault;

// Apply completion defaults.
$module = $DB->get_record('modules', array('name' => 'opencast'), '*', MUST_EXIST);

This comment has been minimized.

Copy link
@ferishili

ferishili Nov 19, 2024

Contributor

Hi @justusdieckmann,
Regarding the issue #377, I did a closer look and ended up here.
So for this I have a question first:
Why should it be opencast and not the lti module?
The opencast module is related to the build_activity_modinfo function.
The lti module is related here.
Is there any specific reason for this here, or I would guess it s meant to be replaced with lti after the copy & paste from build_activity_modinfo. right?

$defaults = \core_completion\manager::get_default_completion($course, $module);
foreach ($defaults as $key => $value) {
$moduleinfo->$key = $value;
}

// Populate the modinfo object with LTI specific parameters.
$moduleinfo->typeid = $toolid;
Expand Down
23 changes: 11 additions & 12 deletions classes/setting_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,26 @@ class setting_helper {
* @throws \coding_exception
*/
public static function validate_workflow_setting($data) {
if ($data == null) {
return false;
}

// Hack to get the opencast instance id.
$category = optional_param('category', null, PARAM_RAW);
if ($category) {
$ocinstanceid = intval(ltrim($category, 'block_opencast_instance_'));
$ocinstanceid = intval(str_replace('block_opencast_instance_', '', $category));
} else {
$section = optional_param('section', null, PARAM_RAW);
$ocinstanceid = intval(ltrim($section, 'block_opencast_importvideossettings_'));
$ocinstanceid = intval(str_replace('block_opencast_importvideossettings_', '', $section));
}

// Do only if a workflow was set.
if ($data != null) {
// Get an APIbridge instance.
$apibridge = \block_opencast\local\apibridge::get_instance($ocinstanceid);
// Get an APIbridge instance.
$apibridge = \block_opencast\local\apibridge::get_instance($ocinstanceid);

// Verify if the given value is a valid Opencast workflow.
if (!$apibridge->check_if_workflow_exists($data)) {
return get_string('workflow_not_existing', 'block_opencast');
}
return false;
// Verify if the given value is a valid Opencast workflow.
if (!$apibridge->check_if_workflow_exists($data)) {
return get_string('workflow_not_existing', 'block_opencast');
}

return false;
}

Expand Down

0 comments on commit 6998088

Please sign in to comment.