You are here

protected function OpignoTincanQuestionTypeResponse::getLrsConnection in Opigno TinCan Question Type 7

This method returns the connection to the LRS.

If there is a problem, this method will show an error message and return FALSE.

Return value

bool|\TinCan\RemoteLRS FALSE in case of error. The LRS connection if connection was success.

1 call to OpignoTincanQuestionTypeResponse::getLrsConnection()
OpignoTincanQuestionTypeResponse::getScoreFromLrs in includes/opigno_tincan_question_type.response.inc
This method will return the score from the LRS system for this response.

File

includes/opigno_tincan_question_type.response.inc, line 241
This file contains the class OpignoTincanQuestionTypeResponse.

Class

OpignoTincanQuestionTypeResponse
This class goal is to manage the user's answer(s).

Code

protected function getLrsConnection() {

  // Check first if the TinCanPHP library is installed
  // If not, return FALSE
  $libraries = libraries_get_libraries();
  if (!isset($libraries['TinCanPHP'])) {
    drupal_set_message(t('Please install the !tincanphp_library in the <em>sites/all/library/TinCanPHP</em> folder.', array(
      '!tincanphp_library' => l(t('TinCanPHP library'), 'https://github.com/RusticiSoftware/TinCanPHP/releases'),
    )), 'error');
    return FALSE;
  }
  $endpoint = variable_get('opigno_tincan_api_endpoint', '');
  $username = variable_get('opigno_tincan_api_username', '');
  $password = variable_get('opigno_tincan_api_password', '');
  if (empty($endpoint) || empty($username) || empty($password)) {
    drupal_set_message(t('Please configure first the Opigno TinCan API module.'));
    if (drupal_valid_path('admin/opigno/system/tincan')) {
      drupal_set_message(t('Go to !url', array(
        '!url' => l(t('the settings page.'), 'admin/opigno/system/tincan'),
      )));
    }
    return FALSE;
  }
  return new RemoteLRS($endpoint, '1.0.1', $username, $password);
}