def db_configured_basic_lti_launch(self): """ Respond to a DB-configured assignment launch. DB-configured assignment launch requests don't have any kind of file ID or document URL in the request. Instead the document URL is stored in our own DB. This happens with LMS's that don't support LTI content item selection/deep linking, so they don't support storing the document URL in the LMS and passing it back to us in each launch request. Instead we retrieve the document URL from the DB and pass it to Via. """ self.sync_lti_data_to_h() self.store_lti_data() self.context.js_config.maybe_enable_grading() resource_link_id = self.request.params["resource_link_id"] tool_consumer_instance_guid = self.request.params["tool_consumer_instance_guid"] # The ``db_configured=True`` view predicate ensures that this view # won't be called if there isn't a matching ModuleItemConfiguration in # the DB. So here we can safely assume that the ModuleItemConfiguration # exists. document_url = ModuleItemConfiguration.get_document_url( self.request.db, tool_consumer_instance_guid, resource_link_id ) self.context.js_config.add_document_url(document_url) return {}
def test_get_document_url_returns_None_if_theres_no_matching_document_url( self, db_session): document_url = ModuleItemConfiguration.get_document_url( db_session, "test_tool_consumer_instance_guid", "test_resource_link_id") assert document_url is None
def __call__(self, context, request): resource_link_id = request.params.get("resource_link_id") tool_consumer_instance_guid = request.params.get( "tool_consumer_instance_guid") has_module_item_configuration = ( ModuleItemConfiguration.get_document_url( request.db, tool_consumer_instance_guid, resource_link_id) is not None) return has_module_item_configuration == self.value
def test_get_document_url_returns_the_document_url(self, db_session): db_session.add( ModuleItemConfiguration( tool_consumer_instance_guid="test_tool_consumer_instance_guid", resource_link_id="test_resource_link_id", document_url="test_document_url", )) document_url = ModuleItemConfiguration.get_document_url( db_session, "test_tool_consumer_instance_guid", "test_resource_link_id") assert document_url == "test_document_url"