Plugin: Whispeak don't progress when auth is not passed in LP - refs BT#15816

pull/3377/head
Angel Fernando Quiroz Campos 7 years ago
parent af2c426dbe
commit a60ed51884
  1. 5
      main/lp/learnpath.class.php
  2. 5
      main/lp/learnpathItem.class.php
  3. 5
      main/lp/lp_ajax_switch_item.php
  4. 17
      main/lp/lp_content.php
  5. 24
      main/lp/lp_view.php
  6. 29
      plugin/whispeakauth/WhispeakAuthPlugin.php

@ -5758,7 +5758,10 @@ class learnpath
$item_type = $this->items[$this->current]->get_type();
if (($type == 2 && $item_type != 'sco') ||
($type == 3 && $item_type != 'au') ||
($type == 1 && $item_type != TOOL_QUIZ && $item_type != TOOL_HOTPOTATOES)
(
$type == 1 && $item_type != TOOL_QUIZ && $item_type != TOOL_HOTPOTATOES &&
WhispeakAuthPlugin::isAllowedToSaveLpItem($this->current)
)
) {
if ($debug) {
error_log('item type: '.$item_type);

@ -3031,6 +3031,11 @@ class learnpathItem
if ($debug) {
error_log("type: $type");
}
if (!WhispeakAuthPlugin::isAllowedToSaveLpItem($this->iId)) {
return false;
}
switch ($type) {
case 'asset':
if ($prereqs_complete) {

@ -86,6 +86,11 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
}
break;
}
if (WhispeakAuthPlugin::isLpItemMarked($new_item_id)) {
ChamiloSession::write(WhispeakAuthPlugin::SESSION_LP_ITEM, ['id' => $new_item_id, 'src' => '']);
}
$mylp->start_current_item(true);
if ($mylp->force_commit) {
$mylp->save_current();

@ -61,18 +61,13 @@ if ($dir) {
$learnPath->start_current_item(); // starts time counter manually if asset
$src = $learnPath->fixBlockedLinks($src);
if (WhispeakAuthPlugin::create()->isEnabled()) {
$itemIsMarked = WhispeakAuthPlugin::checkLpItemIsMarked($lpItemId);
if (WhispeakAuthPlugin::isLpItemMarked($lpItemId)) {
ChamiloSession::write(
WhispeakAuthPlugin::SESSION_LP_ITEM,
['id' => $lpItemId, 'src' => $src]
);
if ($itemIsMarked) {
ChamiloSession::write(
WhispeakAuthPlugin::SESSION_LP_ITEM,
['id' => $lpItemId, 'src' => $src]
);
$src = api_get_path(WEB_PLUGIN_PATH).'whispeakauth/authentify.php';
break;
}
$src = api_get_path(WEB_PLUGIN_PATH).'whispeakauth/authentify.php';
}
break;
}

@ -251,21 +251,17 @@ if (!isset($src)) {
$src = $lp->fixBlockedLinks($src);
$lp->start_current_item(); // starts time counter manually if asset
if (WhispeakAuthPlugin::create()->isEnabled()) {
$itemIsMarked = WhispeakAuthPlugin::checkLpItemIsMarked($lp_item_id);
if ($itemIsMarked) {
ChamiloSession::write(
WhispeakAuthPlugin::SESSION_LP_ITEM,
['id' => $lp_item_id, 'src' => $src]
);
$src = api_get_path(WEB_PLUGIN_PATH).'whispeakauth/authentify.php';
break;
}
if (WhispeakAuthPlugin::isLpItemMarked($lp_item_id)) {
ChamiloSession::write(
WhispeakAuthPlugin::SESSION_LP_ITEM,
['id' => $lp_item_id, 'src' => $src]
);
$src = api_get_path(WEB_PLUGIN_PATH).'whispeakauth/authentify.php';
break;
}
$lp->start_current_item(); // starts time counter manually if asset
} else {
$src = 'blank.php?error=prerequisites';
}

@ -181,8 +181,12 @@ class WhispeakAuthPlugin extends Plugin implements HookPluginInterface
*
* @return bool
*/
public static function checkLpItemIsMarked($lpItemId)
public static function isLpItemMarked($lpItemId)
{
if (!self::create()->isEnabled()) {
return false;
}
$value = self::getLpItemValue($lpItemId);
return !empty($value) && !empty($value['value']);
@ -698,8 +702,27 @@ class WhispeakAuthPlugin extends Plugin implements HookPluginInterface
return parent::isEnabled() && 'true' === api_get_plugin_setting('whispeakauth', self::SETTING_ENABLE);
}
public function is()
/**
* @param int $lpItemId
*
* @return bool
*/
public static function isAllowedToSaveLpItem($lpItemId)
{
if (!self::isLpItemMarked($lpItemId)) {
return true;
}
$markedItem = ChamiloSession::read(self::SESSION_LP_ITEM, []);
if (empty($markedItem)) {
return true;
}
if ((int) $lpItemId !== (int) $markedItem['id']) {
return true;
}
return false;
}
}

Loading…
Cancel
Save