Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into julio6666

1.9.x
Julio Montoya 11 years ago
commit 33fe03110e
  1. 2
      documentation/changelog.html
  2. 10
      main/coursecopy/classes/Course.class.php
  3. 8
      main/coursecopy/classes/CourseArchiver.class.php
  4. 22
      main/coursecopy/classes/CourseBuilder.class.php
  5. 25
      main/coursecopy/classes/CourseRecycler.class.php
  6. 40
      main/coursecopy/classes/CourseRestorer.class.php
  7. 1
      main/coursecopy/classes/CourseSelectForm.class.php
  8. 3
      main/coursecopy/classes/Resource.class.php
  9. 36
      main/coursecopy/classes/Work.class.php
  10. 22
      main/webservices/webservice_report.php

@ -642,7 +642,7 @@ This version of Chamilo includes a few new features.
<li>Assignments: The teacher can now download all files from a specific assignment in one Zip (#4687)</li>
<li>Documents: Added Flash(TM) webcam photoboot, whereby teachers (or students through groups) can take pictures from their webcam, wich get uploaded to the documents tool directly (#4856) (enable through admin settings)</li>
<li>Plugins: Added plugin for School Server of OLPC Perú project (Squid proxy filtering from course) (#4925)</li>
<li>Exerciss: Added new type of questions that automate the repartition of score between available answers (#5012)</li>
<li>Exercises: Added new type of questions that automate the repartition of score between available answers (#5012)</li>
<li>Exercises: Time counter now changes color at 3, then 1 minute to increase awareness of student, and appears nicely in all-questions-on-one-page exercises (#5043, #5267)</li>
<li>System: The stats collection of Chamilo.org is now automatic. If you want to disable this feature, edit admin/index.php and look for fsockopen() (#5104)</li>
<li>Global: Improvements for iPad(TM) and iPhone(TM) by disabling auto-capitalization (#5116)</li>

@ -181,6 +181,10 @@ class Course
$title = $resource->params['name'];
$description = $resource->params['description'];
break;
case RESOURCE_WORK:
$title = $resource->title;
$description = $resource->description;
break;
default:
break;
}
@ -320,7 +324,11 @@ class Course
$resource->content = api_to_system_encoding($resource->content, $this->encoding);
$resource->reflink = api_to_system_encoding($resource->reflink, $this->encoding);
break;
case RESOURCE_WORK:
$resource->url = api_to_system_encoding($resource->url, $this->encoding);
$resource->title = api_to_system_encoding($resource->title, $this->encoding);
$resource->description = api_to_system_encoding($resource->description, $this->encoding);
break;
default:
break;
}

@ -120,6 +120,14 @@ class CourseArchiver
copyDirTo($course->path . 'upload/announcements/', $doc_dir, false);
}
// Copy work folders (only folders)
if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) {
$doc_dir = dirname($backup_dir . '/upload/work/');
@mkdir($doc_dir, $perm_dirs, true);
// @todo: adjust to only create subdirs, but not copy files
copyDirTo($course->path . 'upload/work/', $doc_dir, false);
}
// Zip the course-contents
$zip = new PclZip($zip_dir . $zip_file);
$zip->create($zip_dir . $tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir . $tmp_dir_name . '/');

@ -23,6 +23,7 @@ require_once 'CourseSession.class.php';
require_once 'wiki.class.php';
require_once 'Thematic.class.php';
require_once 'Attendance.class.php';
require_once 'Work.class.php';
/**
* Class which can build a course-object from a Chamilo-course.
@ -51,7 +52,8 @@ class CourseBuilder
'surveys',
'tool_intro',
'thematic',
'wiki'
'wiki',
'works'
);
/* With this array you can filter wich elements of the tools are going to be added in the course obj (only works with LPs) */
@ -986,7 +988,7 @@ class CourseBuilder
}
/**
* Build the Surveys
* Build the attendances
*/
function build_attendance($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
@ -1007,4 +1009,20 @@ class CourseBuilder
$this->course->add_resource($obj);
}
}
/**
* Build the works (or "student publications", or "assignments")
*/
function build_works($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) {
$table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
//$table_work_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$table_work.' WHERE c_id = '.$course_id.' AND session_id = 0 AND filetype = \'folder\' AND parent_id = 0 AND active = 1';
$db_result = Database::query($sql);
while ($row = Database::fetch_array($db_result,'ASSOC')) {
$obj = new Work($row);
$this->course->add_resource($obj);
}
}
}

@ -56,6 +56,7 @@ class CourseRecycler
$this->recycle_glossary();
$this->recycle_thematic();
$this->recycle_attendance();
$this->recycle_work();
foreach ($this->course->resources as $type => $resources) {
foreach ($resources as $id => $resource) {
@ -528,4 +529,28 @@ class CourseRecycler
}
}
}
/**
* Recycle Works
*/
function recycle_work($session_id = 0) {
if ($this->course->has_resources(RESOURCE_WORK)) {
$table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$table_work_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$resources = $this->course->resources;
foreach ($resources[RESOURCE_WORK] as $last_id => $obj) {
if (is_numeric($last_id)) {
$cond = array('publication_id = ? AND c_id = ? '=>array($last_id, $this->course_id));
Database::delete($table_work_assignment, $cond);
// The following also deletes student tasks
$cond = array('parent_id = ? AND c_id = ?'=>array($last_id, $this->course_id));
Database::delete($table_work, $cond);
// Finally, delete the main task registry
$cond = array('id = ? AND c_id = ?'=>array($last_id, $this->course_id));
Database::delete($table_work, $cond);
api_item_property_update($this->course_info, TOOL_STUDENTPUBLICATION, $last_id,'StudentPublicationDeleted', api_get_user_id());
}
}
}
}
}

@ -24,6 +24,7 @@ require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php';
require_once 'Glossary.class.php';
require_once 'wiki.class.php';
require_once 'Thematic.class.php';
require_once 'Work.class.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
@ -72,7 +73,8 @@ class CourseRestorer
//'scorm_documents', ??
'tool_intro',
'thematic',
'wiki'
'wiki',
'works',
);
/** Setting per tool */
@ -2008,6 +2010,42 @@ class CourseRestorer
}
}
/**
* Restore Work
*/
function restore_works($session_id = 0)
{
$perm = api_get_permissions_for_new_directories();
if ($this->course->has_resources(RESOURCE_WORK)) {
$table_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$table_work_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$resources = $this->course->resources;
foreach ($resources[RESOURCE_WORK] as $id => $obj) {
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
$obj->params['id'] = null;
$obj->params['c_id'] = $this->destination_course_id;
$last_id = Database::insert($table_work, $obj->params);
// re-create dir
// @todo check security against injection of dir in crafted course backup here!
$path = $obj->params['url'];
$path = '/'.str_replace('/','',substr($path,1));
$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/work'.$path;
$r = @mkdir($destination_path, $perm);
if ($r === false) {
error_log('Failed creating directory '.$destination_path.' in course restore for work tool');
}
if (is_numeric($last_id)) {
api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id());
}
}
}
}
function DBUTF8($str)
{
if (UTF8_CONVERT) {

@ -35,6 +35,7 @@ class CourseSelectForm
$resource_titles[RESOURCE_WIKI] = get_lang('Wiki');
$resource_titles[RESOURCE_THEMATIC] = get_lang('Thematic');
$resource_titles[RESOURCE_ATTENDANCE] = get_lang('Attendance');
$resource_titles[RESOURCE_WORK] = get_lang('ToolStudentPublication');
?>
<script>
function exp(item) {

@ -30,6 +30,7 @@ define('RESOURCE_SURVEYINVITATION', 'survey_invitation');
define('RESOURCE_WIKI', 'wiki');
define('RESOURCE_THEMATIC', 'thematic');
define('RESOURCE_ATTENDANCE', 'attendance');
define('RESOURCE_WORK', 'work');
/**
* Representation of a resource in a Chamilo-course.
@ -179,6 +180,8 @@ class Resource {
return TOOL_COURSE_PROGRESS;
case RESOURCE_ATTENDANCE:
return TOOL_ATTENDANCE;
case RESOURCE_WORK:
return TOOL_STUDENTPUBLICATION;
default:
return null;
}

@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Work/Assignment/Student publication backup script
* @package chamilo.backup
*/
/**
* Code
*/
require_once 'Resource.class.php';
/**
* An event
* @author Yannick Warnier <yannick.warnier@beeznest.com>
* @package chamilo.backup
*/
class Work extends Resource
{
public $params = array();
/**
* Create a new Work
*
* @param array parameters
*/
public function __construct($params)
{
parent::Resource($params['id'], RESOURCE_WORK);
$this->params = $params;
}
public function show()
{
parent::show();
echo $this->params['title'];
}
}

@ -145,10 +145,11 @@ class WSReport extends WS {
* @param string User id value
* @param string Course id field name
* @param string Course id value
* @param string Learnpath ID
* @param int Learnpath ID
* @param int Learnpath *ITEM* ID
* @return double Generally between 0 and 100
*/
public function GetLearnpathScoreSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) {
public function GetLearnpathScoreSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id, $learnpath_item_id) {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
return $user_id;
@ -160,12 +161,13 @@ class WSReport extends WS {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
}
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php';
$lp = new learnpath($course_code, $learnpath_id, $user_id);
$return = array(
'min_score' => $lp->items[$learnpath_id]->min_score,
'max_score' => $lp->items[$learnpath_id]->max_score,
'mastery_score' => $lp->items[$learnpath_id]->mastery_score,
'current_score' => $lp->items[$learnpath_id]->current_score,
'min_score' => $lp->items[$learnpath_item_id]->min_score,
'max_score' => $lp->items[$learnpath_item_id]->max_score,
'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score,
'current_score' => $lp->items[$learnpath_item_id]->current_score,
);
return $return;
}
@ -178,10 +180,11 @@ class WSReport extends WS {
* @param string User id value
* @param string Course id field name (use chamilo_course_id if none)
* @param string Course id value
* @param string Learnpath ID
* @param int Learnpath ID
* @param int Learnpath *ITEM* ID
* @return string "not attempted", "passed", "completed", "failed", "incomplete"
*/
public function GetLearnpathStatusSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) {
public function GetLearnpathStatusSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id, $learnpath_item_id) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
@ -197,8 +200,9 @@ class WSReport extends WS {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
}
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php';
$lp = new learnpath($course_code, $learnpath_id, $user_id);
return $lp->items[$learnpath_id]->status;
return $lp->items[$learnpath_item_id]->status;
}
}

Loading…
Cancel
Save