Fix cumulative_scorm_time in individual LPs - refs CT#8211

pull/2487/head
Yannick Warnier 9 years ago
parent ca91fc063a
commit 65c9464ef5
  1. 2
      app/Migrations/Schema/V111/Version20160705190000.php
  2. 12
      app/Migrations/Schema/V111/Version20160705192000.php
  3. 35
      main/lp/learnpath.class.php
  4. 6
      main/lp/learnpathItem.class.php
  5. 7
      main/lp/lp_controller.php
  6. 8
      main/lp/lp_edit.php
  7. 2
      src/Chamilo/CourseBundle/Entity/CLp.php

@ -21,7 +21,7 @@ class Version20160705190000 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("ALTER TABLE c_lp ADD COLUMN accumulate_scorm_time VARCHAR(5)");
$this->addSql("ALTER TABLE c_lp ADD COLUMN accumulate_scorm_time INT NOT NULL DEFAULT 1");
}
/**

@ -21,7 +21,17 @@ class Version20160705192000 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql("UPDATE c_lp SET accumulate_scorm_time = (SELECT selected_value FROM settings_current WHERE variable = 'scorm_cumulative_session_time'");
$em = $this->getEntityManager();
$result = $em
->getRepository('ChamiloCoreBundle:SettingsCurrent')
->findOneBy(['variable' => 'scorm_cumulative_session_time']);
$cumulativeScormTime = 1;
if ($result->getSelectedValue() === 'false') {
$cumulativeScormTime = 0;
}
$this->addSql("UPDATE c_lp SET accumulate_scorm_time = $cumulativeScormTime");
}
/**

@ -44,7 +44,7 @@ class learnpath
public $path = ''; // Path inside the scorm directory (if scorm).
public $theme; // The current theme of the learning path.
public $preview_image; // The current image of the learning path.
public $accumulate_scorm_time; // Flag to accumulate scorm time
public $accumulateScormTime; // Flag to decide whether to accumulate SCORM time or not
// Tells if all the items of the learnpath can be tried again. Defaults to "no" (=1).
public $prevent_reinit = 1;
@ -151,7 +151,7 @@ class learnpath
$this->modified_on = $row['modified_on'];
$this->ref = $row['ref'];
$this->categoryId = $row['category_id'];
$this->accumulate_scorm_time = isset($row['accumulate_scorm_time']) ? $row['accumulate_scorm_time'] : 'false';
$this->accumulateScormTime = isset($row['accumulate_scorm_time']) ? $row['accumulate_scorm_time'] : 'true';
if (!empty($row['publicated_on'])) {
$this->publicated_on = $row['publicated_on'];
@ -865,7 +865,8 @@ class learnpath
'seriousgame_mode' => 0,
'autolaunch' => 0,
'max_attempts' => 0,
'subscribe_users' => 0
'subscribe_users' => 0,
'accumulate_scorm_time' => 1
];
$id = Database::insert($tbl_lp, $params);
@ -11122,6 +11123,34 @@ EOD;
return $answer;
}
/**
* Get whether this is a learning path with the accumulated SCORM time or not
* @return int
*/
public function getAccumulateScormTime()
{
return $this->accumulateScormTime;
}
/**
* Set whether this is a learning path with the accumulated SCORM time or not
* @param int $value (0 = false, 1 = true)
* @return bool Always returns true
*/
public function setAccumulateScormTime($value)
{
if ($this->debug > 0) {
error_log('New LP - In learnpath::setAccumulateScormTime()', 0);
}
$this->accumulateScormTime = intval($value);
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
$sql = "UPDATE $lp_table SET accumulate_scorm_time = ".$this->accumulateScormTime."
WHERE c_id = ".$this->course_int_id." AND id = $lp_id";
Database::query($sql);
return true;
}
}
if (!function_exists('trim_value')) {

@ -3632,13 +3632,13 @@ class learnpathItem
$sql = "SELECT * FROM $lp_table
WHERE id = $lp_id AND c_id = $course_id";
$res = Database::query($sql);
$accumulate_scorm_time = 'false';
$accumulateScormTime = 'false';
if (Database::num_rows($res) > 0) {
$accumulate_scorm_time = $row['accumulate_scorm_time'];
$accumulateScormTime = $row['accumulate_scorm_time'];
}
//Step 2.1 : if normal mode total_time = total_time + total_sec
if ($accumulate_scorm_time != 'false') {
if ($accumulateScormTime != 0) {
$total_time += $total_sec;
//$this->last_scorm_session_time = $total_sec;
} else {

@ -581,6 +581,10 @@ switch ($action) {
$new_lp_id,
api_get_user_id()
);
$accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
$_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
//require 'lp_build.php';
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq();
header("Location: $url&isStudentView=false");
@ -958,6 +962,9 @@ switch ($action) {
$subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0;
$_SESSION['oLP']->setSubscribeUsers($subscribeUsers);
$accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
$_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
$publicated_on = $_REQUEST['publicated_on'];
} else {

@ -136,6 +136,7 @@ $defaults['lp_name'] = Security::remove_XSS($_SESSION['oLP']->get_name());
$defaults['lp_author'] = Security::remove_XSS($_SESSION['oLP']->get_author());
$defaults['hide_toc_frame'] = Security::remove_XSS($_SESSION['oLP']->get_hide_toc_frame());
$defaults['category_id'] = intval($_SESSION['oLP']->getCategoryId());
$defaults['accumulate_scorm_time'] = $_SESSION['oLP']->getAccumulateScormTime();
$expired_on = $_SESSION['oLP']->expired_on;
$publicated_on = $_SESSION['oLP']->publicated_on;
@ -192,6 +193,13 @@ if (api_is_platform_admin()) {
$form->addElement('checkbox', 'subscribe_users', null, get_lang('SubscribeUsersToLp'));
// accumulate_scorm_time
$form->addElement(
'checkbox',
'accumulate_scorm_time',
[get_lang('AccumulateScormTime'), get_lang('AccumulateScormTimeInfo')]
);
$enableLpExtraFields = false;
if ($enableLpExtraFields) {

@ -261,7 +261,7 @@ class CLp
/**
* @var string
*
* @ORM\Column(name="accumulate_scorm_time", type="string", length=5, nullable=false)
* @ORM\Column(name="accumulate_scorm_time", type="integer", nullable=false, options={"default":1})
*/
private $accumulateScormTime;

Loading…
Cancel
Save