From fa33f5be0ea1d7eddd3cfc4785fead7a5d519369 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 9 Mar 2020 15:27:24 -0500 Subject: [PATCH] LTI: Avoid use AGS when there is no gradebook - refs BT#16379 --- plugin/ims_lti/configure.php | 8 ++++-- plugin/ims_lti/edit.php | 4 ++- plugin/ims_lti/lang/english.php | 1 + plugin/ims_lti/lang/french.php | 1 + plugin/ims_lti/lang/spanish.php | 3 +- plugin/ims_lti/src/Form/FrmAdd.php | 44 +++++++++++++++++++++++------ plugin/ims_lti/src/Form/FrmEdit.php | 43 ++++++++++++++++++++++------ 7 files changed, 82 insertions(+), 22 deletions(-) diff --git a/plugin/ims_lti/configure.php b/plugin/ims_lti/configure.php index 43a6aa4f47c..796e8e632ec 100644 --- a/plugin/ims_lti/configure.php +++ b/plugin/ims_lti/configure.php @@ -79,7 +79,9 @@ ->setRedirectUrl($formValues['redirect_url']) ->setAdvantageServices( [ - 'ags' => $formValues['1p3_ags'], + 'ags' => isset($formValues['1p3_ags']) + ? $formValues['1p3_ags'] + : LtiAssignmentGradesService::AGS_NONE, 'nrps' => $formValues['1p3_nrps'], ] ); @@ -200,7 +202,9 @@ ->setRedirectUrl($formValues['redirect_url']) ->setAdvantageServices( [ - 'ags' => $formValues['1p3_ags'], + 'ags' => isset($formValues['1p3_ags']) + ? $formValues['1p3_ags'] + : LtiAssignmentGradesService::AGS_NONE, 'nrps' => $formValues['1p3_nrps'], ] ); diff --git a/plugin/ims_lti/edit.php b/plugin/ims_lti/edit.php index d67080af385..3fa3f1856af 100644 --- a/plugin/ims_lti/edit.php +++ b/plugin/ims_lti/edit.php @@ -66,7 +66,9 @@ ->setRedirectUrl($formValues['redirect_url']) ->setAdvantageServices( [ - 'ags' => $formValues['1p3_ags'], + 'ags' => isset($formValues['1p3_ags']) + ? $formValues['1p3_ags'] + : LtiAssignmentGradesService::AGS_NONE, 'nrps' => $formValues['1p3_nrps'], ] ) diff --git a/plugin/ims_lti/lang/english.php b/plugin/ims_lti/lang/english.php index f605571cbe1..d02d41bd0a4 100644 --- a/plugin/ims_lti/lang/english.php +++ b/plugin/ims_lti/lang/english.php @@ -65,3 +65,4 @@ $strings['TokenUrl'] = 'OAuth2 Access Token URL'; $strings['KeySetUrl'] = 'Keyset URL'; $strings['NamesAndRoleProvisioningService'] = 'Names and Role Provisioning Service'; +$strings['YouNeedCreateTheGradebokInCourseFirst'] = 'You must first create the course gradebook to use this service by following this link %s'; diff --git a/plugin/ims_lti/lang/french.php b/plugin/ims_lti/lang/french.php index 8c647958b7a..65753a1208c 100644 --- a/plugin/ims_lti/lang/french.php +++ b/plugin/ims_lti/lang/french.php @@ -36,3 +36,4 @@ $strings['NoTool'] = 'Tool not exists'; $strings['ToolAddedOnCourseX'] = 'Tool addeed on course %s.'; $strings['SupportDeppLinkingHelp'] = 'Contact your Tool Provider to verify if Deep Linking support is mandatory'; +$strings['YouNeedCreateTheGradebokInCourseFirst'] = 'You must first create the course gradebook to use this service by following this link %s'; diff --git a/plugin/ims_lti/lang/spanish.php b/plugin/ims_lti/lang/spanish.php index 08f33b71c93..1b3bbf3c578 100644 --- a/plugin/ims_lti/lang/spanish.php +++ b/plugin/ims_lti/lang/spanish.php @@ -37,4 +37,5 @@ $strings['ToolAddedOnCourseX'] = 'Herramienta agregada en el curso %s.'; $strings['SupportDeppLinkingHelp'] = 'Contacte a su Proveedor de Herramienta para verificar si el soporte a Deep Linking es obligatorio'; $strings['NoAccessToUrl'] = 'Sin acceso a la URL'; -$strings['LaunchUrlNotFound'] = 'URL de lanzamiento no encontrada'; \ No newline at end of file +$strings['LaunchUrlNotFound'] = 'URL de lanzamiento no encontrada'; +$strings['YouNeedCreateTheGradebokInCourseFirst'] = 'Debe crear el libro de calificaciones del curso para usar este servicio siguiendo este enlace %s'; diff --git a/plugin/ims_lti/src/Form/FrmAdd.php b/plugin/ims_lti/src/Form/FrmAdd.php index 8a54e465d01..75b4fca96b9 100644 --- a/plugin/ims_lti/src/Form/FrmAdd.php +++ b/plugin/ims_lti/src/Form/FrmAdd.php @@ -92,16 +92,42 @@ public function build() ); } + $showAGS = false; + + if (api_get_course_int_id()) { + $caterories = Category::load(null, null, api_get_course_id()); + + if (!empty($caterories)) { + $showAGS = true; + } + } else { + $showAGS = true; + } + $this->addHtml('