Added Scorm time to lp - Refs #8211

pull/2487/head
José Loguercio 10 years ago
parent b264ab7c8f
commit a2c9fca654
  1. 36
      app/Migrations/Schema/V111/Version20160705190000.php
  2. 36
      app/Migrations/Schema/V111/Version20160705192000.php
  3. 2
      main/lp/learnpath.class.php
  4. 12
      main/lp/learnpathItem.class.php
  5. 13
      main/lp/lp_add.php
  6. 27
      src/Chamilo/CourseBundle/Entity/CLp.php

@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160705190000
* Add accumulate scorm time to c_lp table
* @package Application\Migrations\Schema\V111
*/
class Version20160705190000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("ALTER TABLE c_lp ADD COLUMN accumulate_scorm_time VARCHAR(5)");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("ALTER TABLE c_lp DROP COLUMN accumulate_scorm_time");
}
}

@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160705192000
* Add accumulate scorm time to c_lp table
* @package Application\Migrations\Schema\V111
*/
class Version20160705192000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
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'");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
}
}

@ -44,6 +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
// Tells if all the items of the learnpath can be tried again. Defaults to "no" (=1).
public $prevent_reinit = 1;
@ -150,6 +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';
if (!empty($row['publicated_on'])) {
$this->publicated_on = $row['publicated_on'];

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

@ -117,6 +117,13 @@ $form->addElement('html', '<div id="advanced_params_options" style="display:none
$items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true);
$form->addElement('select', 'category_id', get_lang('Category'), $items);
// accumulate_scorm_time
$form->addElement(
'checkbox',
'accumulate_scorm_time',
[get_lang('AccumulateScormTime'), get_lang('AccumulateScormTimeInfo')]
);
// Start date
$form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
$form->addElement('html','<div id="start_date_div" style="display:block;">');
@ -133,6 +140,12 @@ $form->addElement('html','</div>');
$defaults['activate_start_date_check'] = 1;
if (api_get_setting('scorm_cumulative_session_time') == 'true') {
$defaults['accumulate_scorm_time'] = 1;
} else {
$defaults['accumulate_scorm_time'] = 0;
}
$defaults['publicated_on'] = date('Y-m-d 08:00:00');
$defaults['expired_on'] = date('Y-m-d 08:00:00',time()+86400);

@ -258,6 +258,13 @@ class CLp
*/
private $expiredOn;
/**
* @var \DateTime
*
* @ORM\Column(name="accumulate_scorm_time", type="boolean", nullable=false)
*/
private $accumulateScormTime;
/**
* Constructor
*/
@ -980,4 +987,24 @@ class CLp
return $this;
}
/**
* @return boolean
*/
public function getAccumulateScormTime()
{
return $this->accumulateScormTime;
}
/**
* @param boolean $accumulateScormTime
* @return CLp
*/
public function setAccumulateScormTime($accumulateScormTime)
{
$this->accumulateScormTime = $accumulateScormTime;
return $this;
}
}

Loading…
Cancel
Save