Skip to content

Commit

Permalink
Plugin: LTI: Improve form in session context
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jan 21, 2022
1 parent 8d30d63 commit 90da89c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions plugin/ims_lti/multiply_session.php
Expand Up @@ -25,10 +25,6 @@
$ltiToolId = $request->query->getInt('id');
$sessionId = $request->query->getInt('session_id');

if (empty($sessionId)) {
api_not_allowed();
}

/** @var ImsLtiTool $tool */
$tool = $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $ltiToolId);

Expand All @@ -40,6 +36,12 @@
throw new Exception($plugin->get_lang('NoAllowed'));
}

$session = api_get_session_entity($sessionId);

if (!$session) {
api_not_allowed(true);
}

$content = '';

$courses = ImsLtiPlugin::getCoursesForParentTool($tool);
Expand All @@ -54,6 +56,7 @@
$selectedCoursesIds = array_keys($slctCourses);

$form = new FormValidator('frm_multiply', 'post', api_get_self().'?id='.$tool->getId().'&session_id='.$sessionId);
$form->addLabel(get_lang('SessionName'), $session);
$form->addLabel($plugin->get_lang('Tool'), $tool->getName());
$form->addSelectAjax(
'courses',
Expand Down Expand Up @@ -105,7 +108,6 @@
if ($newSelectedCourseIds) {
foreach ($newSelectedCourseIds as $newSelectedCourseId) {
$newSelectedCourse = api_get_course_entity($newSelectedCourseId);
$session = api_get_session_entity($sessionId);

$newTool = clone $tool;
$newTool->setParent($tool);
Expand Down
4 changes: 2 additions & 2 deletions plugin/ims_lti/session.php
Expand Up @@ -79,8 +79,8 @@
$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')];
$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()];

$template = new Template($plugin->get_lang('AddInCourses'));
$template->assign('header', $plugin->get_lang('AddInCourses'));
$template = new Template($plugin->get_lang('AddInSessions'));
$template->assign('header', $plugin->get_lang('AddInSessions'));
$template->assign('content', $content);
$template->display_one_col_template();
} catch (Exception $exception) {
Expand Down

0 comments on commit 90da89c

Please sign in to comment.