Merge 1.10.x

ofaj
Julio 10 years ago
commit 4c06ce4c10
  1. 5
      app/Migrations/Schema/V110/Version20150603181728.php
  2. 34
      app/Migrations/Schema/V111/Version20160418093800.php
  3. 24
      main/course_info/infocours.php
  4. 21
      main/exercice/answer.class.php
  5. 65
      main/exercice/exercise.class.php
  6. 20
      main/exercice/exercise_result.php
  7. 12
      main/exercice/exercise_submit.php
  8. 1
      main/inc/global.inc.php
  9. 3
      main/inc/lib/add_course.lib.inc.php
  10. 13
      main/inc/lib/api.lib.php
  11. 22
      main/inc/lib/course.lib.php
  12. 327
      main/inc/lib/ppt2png/DocumentConverter.java.orig
  13. 46
      main/inc/lib/userportal.lib.php
  14. 2
      main/install/configuration.dist.php
  15. 4608
      main/install/database.sql
  16. 4
      main/install/index.php
  17. 15152
      main/lang/english/trad4all.inc.php
  18. 15152
      main/lang/spanish/trad4all.inc.php
  19. 3
      main/template/default/user_portal/index.tpl
  20. 5
      main/template/default/user_portal/index_grid.tpl
  21. 130
      main/template/default/user_portal/session.tpl
  22. 34
      src/Chamilo/CoreBundle/EventListener/LegacyLoginListener.php
  23. 89
      src/Chamilo/CoreBundle/EventListener/LocaleListener.php
  24. 14
      src/Chamilo/CoreBundle/EventListener/UserLocaleListener.php
  25. 12
      src/Chamilo/CoreBundle/Resources/config/services.yml
  26. 25
      src/Chamilo/CourseBundle/Entity/CQuiz.php
  27. 13
      user_portal.php
  28. 22
      web/.htaccess

@ -73,7 +73,10 @@ class Version20150603181728 extends AbstractMigrationChamilo
$this->addSql("DELETE FROM c_item_property WHERE c_id = 0");
// Remove inconsistencies about non-existing users
$this->addSql("DELETE FROM course_rel_user WHERE user_id = 0");
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)');
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course(id)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C181330D47E9 FOREIGN KEY (to_group_id) REFERENCES c_group_info (iid)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18129F6EE60 FOREIGN KEY (to_user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C1819C859CC3 FOREIGN KEY (insert_user_id) REFERENCES user (id)');

@ -0,0 +1,34 @@
<?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 Version20160418093800
* Add save_correct_answers column to c_quiz table
* @package Application\Migrations\Schema\V111
*/
class Version20160418093800 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$cQuizTable = $schema->getTable('c_quiz');
$cQuizTable->addColumn('save_correct_answers', Type::BOOLEAN);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

@ -178,6 +178,13 @@ $form->addElement(
);
$form->addElement('select_language', 'course_language', array(get_lang('Ln'), get_lang('TipLang')));
$group = array(
$form->createElement('radio', 'show_course_in_user_language', null, get_lang('Yes'), 1),
$form->createElement('radio', 'show_course_in_user_language', null, get_lang('No'), 2),
);
$form->addGroup($group, '', array(get_lang("ShowCourseInUserLanguage")), '');
$form->addText('department_name', get_lang('Department'), false);
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
@ -204,8 +211,12 @@ $form->addHtml('
');
$form->addHidden('cropResult', '');
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
//$form->addElement('html', '<div class="form-group "><div class="col-md-2"></div> <div class="col-md-8 help-image">'.get_lang('UniqueAnswerImagePreferredSize200x150').'</div></div>');
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
'filetype',
$allowed_picture_types
);
$form->addElement('checkbox', 'delete_picture', null, get_lang('DeletePicture'));
if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
@ -213,8 +224,7 @@ if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
$form->addText('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.
Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>');
}
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
@ -453,12 +463,14 @@ $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
$form->addElement('html', '</div></div>');
// Document settings
$form->addElement('html', '<div><h3>'.Display::return_icon('folder.png', Security::remove_XSS(get_lang('Documents')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Documents')).'</h3><div>');
$form->addElement(
'html',
'<div><h3>'.Display::return_icon('folder.png', Security::remove_XSS(get_lang('Documents')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Documents')).'</h3><div>'
);
$group = array(
$form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1),
$form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2),
);
$form->addGroup($group, '', array(get_lang("ShowSystemFolders")), '');
$form->addButtonSave(get_lang('SaveSettings'), 'submit_save');

@ -832,4 +832,25 @@ class Answer
</script>";
}
/**
* Check if a answer is correct by an answer auto id
* @param $needle int The answer auto id
* @return bool
*/
public function isCorrectByAutoId($needle)
{
$key = 0;
foreach ($this->autoId as $autoIdKey => $autoId) {
if ($autoId == $needle) {
$key = $autoIdKey;
}
}
if (!$key) {
return false;
}
return $this->isCorrect($key) ? true : false;
}
}

@ -35,6 +35,7 @@ class Exercise
public $course;
public $course_id;
public $propagate_neg;
public $saveCorrectAnswers;
public $review_answers;
public $randomByCat;
public $text_when_finished;
@ -91,6 +92,7 @@ class Exercise
$this->results_disabled = 1;
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->saveCorrectAnswers = 0;
$this->review_answers = false;
$this->randomByCat = 0;
$this->text_when_finished = '';
@ -152,6 +154,7 @@ class Exercise
$this->attempts = $object->max_attempt;
$this->feedback_type = $object->feedback_type;
$this->propagate_neg = $object->propagate_neg;
$this->saveCorrectAnswers = $object->save_correct_answers;
$this->randomByCat = $object->random_by_category;
$this->text_when_finished = $object->text_when_finished;
$this->display_category_name = $object->display_category_name;
@ -1133,6 +1136,14 @@ class Exercise
return $this->propagate_neg;
}
/**
* @return int
*/
public function selectSaveCorrectAnswers()
{
return $this->saveCorrectAnswers;
}
/**
* Selects questions randomly in the question list
*
@ -1275,6 +1286,14 @@ class Exercise
$this->propagate_neg = $value;
}
/**
* @param $value int
*/
public function updateSaveCorrectAnswers($value)
{
$this->saveCorrectAnswers = $value;
}
/**
* @param $value
*/
@ -1523,6 +1542,7 @@ class Exercise
$random_answers = $this->random_answers;
$active = $this->active;
$propagate_neg = $this->propagate_neg;
$saveCorrectAnswers = isset($this->saveCorrectAnswers) && $this->saveCorrectAnswers ? true : false;
$review_answers = isset($this->review_answers) && $this->review_answers ? 1 : 0;
$randomByCat = intval($this->randomByCat);
$text_when_finished = $this->text_when_finished;
@ -1573,6 +1593,7 @@ class Exercise
'max_attempt' => $attempts,
'expired_time' => $expired_time,
'propagate_neg' => $propagate_neg,
'save_correct_answers' => $saveCorrectAnswers,
'review_answers' => $review_answers,
'random_by_category' => $randomByCat,
'text_when_finished' => $text_when_finished,
@ -1643,7 +1664,8 @@ class Exercise
'random_by_category' => $randomByCat,
'text_when_finished' => $text_when_finished,
'display_category_name' => $display_category_name,
'pass_percentage' => $pass_percentage
'pass_percentage' => $pass_percentage,
'save_correct_answers' => $saveCorrectAnswers
];
$this->id = Database::insert($TBL_EXERCISES, $params);
@ -2154,6 +2176,11 @@ class Exercise
//$check_option=$this->selectType();
$diplay = 'block';
$form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
$form->addCheckBox(
'save_correct_answers',
null,
get_lang('Save the correct answers for the next attempt')
);
$form->addElement('html','<div class="clear">&nbsp;</div>');
$form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
@ -2275,6 +2302,7 @@ class Exercise
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['save_correct_answers'] = $this->selectSaveCorrectAnswers();
$defaults['review_answers'] = $this->review_answers;
$defaults['randomByCat'] = $this->selectRandomByCat();
$defaults['text_when_finished'] = $this->selectTextWhenFinished();
@ -2366,6 +2394,7 @@ class Exercise
$this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
$this->updateSaveCorrectAnswers($form->getSubmitValue('save_correct_answers'));
$this->updateRandomByCat($form->getSubmitValue('randomByCat'));
$this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
$this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));
@ -8238,4 +8267,38 @@ class Exercise
}
return 1;
}
/**
* Get the correct answers in all attempts
* @param int $learnPathId
* @param int $learnPathItemId
* @return array
*/
public function getCorrectAnswersInAllAttempts($learnPathId = 0, $learnPathItemId = 0)
{
$attempts = Event::getExerciseResultsByUser(
api_get_user_id(),
$this->id,
api_get_course_int_id(),
api_get_session_id(),
$learnPathId,
$learnPathItemId,
'asc'
);
$corrects = [];
foreach ($attempts as $attempt) {
foreach ($attempt['question_list'] as $answer) {
$objAnswer = new Answer($answer['question_id']);
$isCorrect = $objAnswer->isCorrectByAutoId($answer['answer']);
if ($isCorrect) {
$corrects[$answer['question_id']][] = $answer;
}
}
}
return $corrects;
}
}

@ -144,6 +144,26 @@ if ($objExercise->selectAttempts() > 0) {
Display::display_footer();
}
exit;
} else {
$attempt_count++;
$remainingAttempts = $objExercise->selectAttempts() - $attempt_count;
if ($remainingAttempts) {
$attemptButton = Display::toolbarButton(
get_lang('AnotherAttempt'),
api_get_patth(WEB_CODE_PATH) . 'exercice/overview.php?' . api_get_cidreq() . '&' . http_build_query([
'exerciseId' => $objExercise->id
]),
'pencil-square-o',
'info'
);
$attemptMessage = sprintf(get_lang('RemainingXAttempts'), $remainingAttempts);
Display::display_normal_message(
sprintf("<p>%s</p> %s", $attemptMessage, $attemptButton),
false
);
}
}
}

@ -1116,7 +1116,17 @@ if (!empty($error)) {
}
}
$user_choice = isset($attempt_list[$questionId]) ? $attempt_list[$questionId] : null;
$user_choice = null;
if (isset($attempt_list[$questionId])) {
$user_choice = $attempt_list[$questionId];
} elseif ($objExercise->saveCorrectAnswers) {
$correctAnswers = $objExercise->getCorrectAnswersInAllAttempts($learnpath_id, $learnpath_item_id);
if (isset($correctAnswers[$questionId])) {
$user_choice = $correctAnswers[$questionId];
}
}
$remind_highlight = '';

@ -437,6 +437,7 @@ if (!empty($valid_languages)) {
} else {
$language_interface = api_get_setting('platformLanguage');
}
if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) {
$language_interface = api_get_language_from_type($language_priority3);

@ -689,7 +689,8 @@ class AddCourse
'default' => api_get_setting('allow_public_certificates') === 'true' ? 1 : '',
'category' =>'certificates'
],
'documents_default_visibility' => ['default' =>'visible', 'category' =>'document']
'documents_default_visibility' => ['default' =>'visible', 'category' =>'document'],
'show_course_in_user_language' => ['default' => 2],
];
$counter = 1;

@ -1392,7 +1392,7 @@ function api_get_user_info(
) {
if (empty($user_id)) {
$userFromSession = Session::read('_user');
$userFromSession = Session::read('_user');
if (isset($userFromSession)) {
return _api_format_user($userFromSession);
}
@ -4245,6 +4245,7 @@ function api_get_language_from_type($lang_type)
global $_course;
$cidReq = null;
if (empty($_course)) {
// Code modified because the local.inc.php file it's declarated after this work
// causing the function api_get_course_info() returns a null value
$cidReq = isset($_GET["cidReq"]) ? Database::escape_string($_GET["cidReq"]) : null;
@ -4257,8 +4258,16 @@ function api_get_language_from_type($lang_type)
}
}
$_course = api_get_course_info($cidReq);
if (isset($_course['language']) && !empty($_course['language']))
if (isset($_course['language']) && !empty($_course['language'])) {
$return = $_course['language'];
$showCourseInUserLanguage = api_get_course_setting('show_course_in_user_language');
if ($showCourseInUserLanguage == 1) {
$userInfo = api_get_user_info();
if (isset($userInfo['language'])) {
$return = $userInfo['language'];
}
}
}
break;
default:
$return = false;

@ -3522,6 +3522,7 @@ class CourseManager
$result = Database::query($sql);
$html = null;
$courseCount = 0;
$items = [];
while ($row = Database::fetch_array($result)) {
// We simply display the title of the category.
$params = array(
@ -3538,10 +3539,14 @@ class CourseManager
$load_dirs
);
$html .= self::course_item_parent(
$item = self::course_item_parent(
self::course_item_html($params, true),
$courseInCategory['html']
);
$html .= $item;
$items[] = $item;
$courseCount += $courseInCategory['course_count'];
}
@ -3549,10 +3554,16 @@ class CourseManager
$courseInCategory = self::displayCoursesInCategory(0, $load_dirs);
$html .= $courseInCategory['html'];
if (!empty($courseInCategory['items'])) {
$items = array_merge($items, $courseInCategory['items']);
}
$courseCount += $courseInCategory['course_count'];
return [
'html' => $html,
'items' => $items,
'course_count' => $courseCount
];
}
@ -3611,6 +3622,7 @@ class CourseManager
$result = Database::query($sql);
$html = '';
$items = [];
$course_list = array();
$showCustomIcon = api_get_setting('course_images_in_courses_list');
@ -3729,11 +3741,14 @@ class CourseManager
if (empty($user_category_id)) {
$isSubContent = false;
}
$html .= self::course_item_html($params, $isSubContent);
$item = self::course_item_html($params, $isSubContent);
$html .= $item;
$items[] = $item;
}
return [
'html' => $html,
'items' => $items,
'course_count' => $courseCount
];
}
@ -5018,7 +5033,8 @@ class CourseManager
'pdf_export_watermark_text',
'show_system_folders',
'exercise_invisible_in_session',
'enable_forum_auto_launch'
'enable_forum_auto_launch',
'show_course_in_user_language'
);
$allowLPReturnLink = api_get_setting('allow_lp_return_link');

@ -1,327 +0,0 @@
import java.awt.Event;
//import sun.text.Normalizer;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPTransferType;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.XBridge;
import com.sun.star.bridge.XBridgeFactory;
import com.sun.star.connection.NoConnectException;
import com.sun.star.connection.XConnection;
import com.sun.star.connection.XConnector;
import com.sun.star.container.XNamed;
import com.sun.star.document.XExporter;
import com.sun.star.document.XFilter;
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XDrawPages;
import com.sun.star.drawing.XDrawPagesSupplier;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
/**
* The class <CODE>DocumentConverter</CODE> allows you to convert all
* documents in a given directory and in its subdirectories to a given type. A
* converted document will be created in the same directory as the origin
* document.
*
*/
public class DocumentConverter {
/**
* Containing the loaded documents
*/
static XComponentLoader xcomponentloader = null;
/**
* Connecting to the office with the component UnoUrlResolver and calling
* the static method traverse
*
* @param args
* The array of the type String contains the directory, in which
* all files should be converted, the favoured converting type
* and the wanted extension
*/
public static void main(String args[]) {
String cnx, ftpuser, host, port, url, ftpPasswd, destinationFolder, remoteFolderFullPath, remoteFolder;
int width, height;
try {
host = args[0];
port = args[1];
url = args[2];
destinationFolder = args[3];
width = Integer.parseInt(args[4]);
height = Integer.parseInt(args[5]);
if(args.length == 8){
ftpuser = args[6];
ftpPasswd = args[7];
}
else{
ftpuser = "";
ftpPasswd = "";
}
if(host.equals("localhost")){
String prefix = "file://";
if(url.charAt(0)!='/')
prefix += '/';
url = prefix+url;
remoteFolder = destinationFolder;
remoteFolderFullPath = prefix;
}
else {
remoteFolderFullPath = "file:///home/"+ftpuser+"/";
remoteFolder = url.replace('/','_');
remoteFolder = removeAccents(remoteFolder);
}
cnx = "socket,host="+host+",port="+port;
XComponentContext xComponentContext = com.sun.star.comp.helper.Bootstrap
.createInitialComponentContext(null);
XComponentContext xRemoteContext = xComponentContext;
Object x = xRemoteContext
.getServiceManager()
.createInstanceWithContext(
"com.sun.star.connection.Connector", xRemoteContext);
XConnector xConnector = (XConnector) UnoRuntime.queryInterface(
XConnector.class, x);
XConnection connection = xConnector.connect(cnx);
//if (connection == null)
//System.out.println("Connection is null");
x = xRemoteContext.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", xRemoteContext);
XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime
.queryInterface(XBridgeFactory.class, x);
// this is the bridge that you will dispose
XBridge bridge = xBridgeFactory.createBridge("", "urp", connection,null);
/*XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
XComponent.class, bridge);*/
// get the remote instance
x = bridge.getInstance("StarOffice.ServiceManager");
// Query the initial object for its main factory interface
XMultiComponentFactory xMultiComponentFactory = (XMultiComponentFactory) UnoRuntime
.queryInterface(XMultiComponentFactory.class, x);
XPropertySet xProperySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, xMultiComponentFactory);
// Get the default context from the office server.
Object oDefaultContext = xProperySet
.getPropertyValue("DefaultContext");
// Query for the interface XComponentContext.
xComponentContext = (XComponentContext) UnoRuntime.queryInterface(
XComponentContext.class, oDefaultContext);
while (xcomponentloader == null) {
try {
xcomponentloader = (XComponentLoader) UnoRuntime
.queryInterface(
XComponentLoader.class,
xMultiComponentFactory
.createInstanceWithContext(
"com.sun.star.frame.Desktop",
xComponentContext));
//System.out.println("Loading document "+url);
FTPClient ftp = new FTPClient();
if(!host.equals("localhost")){
//ftp connexion
ftp.setRemoteHost(host);
ftp.connect();
ftp.login(ftpuser, ftpPasswd);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.setType(FTPTransferType.BINARY);
try{
ftp.mkdir(remoteFolder);
}catch(Exception e){}
ftp.chdir(remoteFolder);
ftp.put(url,"presentation.ppt");
url = remoteFolderFullPath+"/"+remoteFolder+"/presentation.ppt";
}
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
// open the document
XComponent component = xcomponentloader
.loadComponentFromURL(url,
"_blank", 0, loadProps);
//System.out.println("Document Opened");
// filter
loadProps = new PropertyValue[4];
// type of image
loadProps[0] = new PropertyValue();
loadProps[0].Name = "MediaType";
loadProps[0].Value = "image/png";
// Height and width
PropertyValue[] filterDatas = new PropertyValue[4];
for(int i = 0; i<4 ; i++){
filterDatas[i] = new PropertyValue();
}
filterDatas[0].Name = "PixelWidth";
filterDatas[0].Value = new Integer(width);
filterDatas[1].Name = "PixelHeight";
filterDatas[1].Value = new Integer(height);
filterDatas[2].Name = "LogicalWidth";
filterDatas[2].Value = new Integer(2000);
filterDatas[3].Name = "LogicalHeight";
filterDatas[3].Value = new Integer(2000);
XDrawPagesSupplier pagesSupplier = (XDrawPagesSupplier) UnoRuntime
.queryInterface(XDrawPagesSupplier.class, component);
//System.out.println(pagesSupplier.toString());
XDrawPages pages = pagesSupplier.getDrawPages();
int nbPages = pages.getCount();
for (int i = 0; i < nbPages; i++) {
XDrawPage page = (XDrawPage) UnoRuntime.queryInterface(
com.sun.star.drawing.XDrawPage.class, pages
.getByIndex(i));
XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class,page);
xPageName.setName("slide"+(i+1));
//if(!xPageName.getName().equals("slide"+(i+1)) && !xPageName.getName().equals("page"+(i+1)))
//xPageName.setName((i+1)+"-"+xPageName.getName());
Object GraphicExportFilter = xMultiComponentFactory
.createInstanceWithContext(
"com.sun.star.drawing.GraphicExportFilter",
xComponentContext);
XExporter xExporter = (XExporter) UnoRuntime
.queryInterface(XExporter.class,
GraphicExportFilter);
XComponent xComp = (XComponent) UnoRuntime
.queryInterface(XComponent.class, page);
xExporter.setSourceDocument(xComp);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "URL";
loadProps[1].Value = remoteFolderFullPath+remoteFolder+"/"+xPageName.getName()+".png";
loadProps[2] = new PropertyValue();
loadProps[2].Name = "FilterData";
loadProps[2].Value = filterDatas;
loadProps[3] = new PropertyValue();
loadProps[3].Name = "Quality";
loadProps[3].Value = new Integer(100);
XFilter xFilter = (XFilter) UnoRuntime.queryInterface(XFilter.class, GraphicExportFilter);
xFilter.filter(loadProps);
System.out.println(xPageName.getName()+".png");
//System.out.println("Page saved to url "+loadProps[1].Value);
}
if(!host.equals("localhost")){
String[] files = ftp.dir();
for (int i = 0; i < files.length; i++){
//System.out.println("Transfer of "+files[i]+ "to "+destinationFolder+"/"+files[i]);
if(!files[i].equals("presentation.ppt"))
ftp.get(destinationFolder+"/"+files[i],files[i]);
ftp.delete(files[i]);
}
ftp.chdir("..");
ftp.rmdir(remoteFolder);
ftp.quit();
}
//System.out.println("Closing Document");
component.dispose();
//System.out.println("Document close");
System.exit(0);
}
catch (NoConnectException e) {
System.out.println(e.toString());
e.printStackTrace();
System.exit(255);
}
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
System.exit(255);
}
}
}
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
System.exit(255);
}
}
public static String removeAccents(String text) {
/*
String newText = Normalizer.decompose(text, false, 0)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");*/
/*
newText = newText.replace('\u00B4','_');
newText = newText.replace('\u02CA','_');
newText = newText.replace('\u02B9','_');
newText = newText.replace('\u02BC','_');
newText = newText.replace('\u02B9','_');
newText = newText.replace('\u03D8','_');
newText = newText.replace('\u0374','_');
newText = newText.replace('\u0384','_');
newText = newText.replace('\u055A','_');
*/
/*
newText = newText.replace('\u2019','_');
newText = newText.replace('\u00B4','_');
newText = newText.replace('\u055A','_');
newText = newText.replace('?','_');
newText = newText.replace('\'','_');
newText = newText.replace(' ','_');
return newText;*/
return java.text.Normalizer.normalize(text, java.text.Normalizer.Form.NFD).replaceAll("[\u0300-\u036F]", "");
}
public boolean handleEvent(Event evt) {
// Traitement de l'evenement de fin de programme
if ( evt.id == evt.WINDOW_DESTROY ) {
System.exit(0) ;
return true ;
}
return false ;
}
}

@ -1045,6 +1045,7 @@ class IndexManager
$sessionCount = 0;
$courseCount = 0;
$items = [];
// If we're not in the history view...
if (!isset($_GET['history'])) {
// Display special courses.
@ -1059,6 +1060,7 @@ class IndexManager
$this->load_directories_preview
);
$courses_html .= $courses['html'];
$items = $courses['items'];
$courseCount = $specialCourses['course_count'] + $courses['course_count'];
}
@ -1203,10 +1205,12 @@ class IndexManager
$this->tpl->assign('session', $params);
$this->tpl->assign('gamification_mode', $gamificationModeIsActive);
$sessions_with_no_category .= $this->tpl->fetch(
$item = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/session.tpl')
);
$sessions_with_no_category .= $item;
$items[] = $item;
$sessionCount++;
}
}
@ -1288,9 +1292,7 @@ class IndexManager
$sessionParams['id'] = $session_id;
$sessionParams['show_link_to_session'] = !api_is_drh() && $sessionTitleLink;
$sessionParams['title'] = $session_box['title'];
$sessionParams['subtitle'] = (!empty($session_box['coach'])
? $session_box['coach'] . ' | '
: '') . $session_box['dates'];
$sessionParams['subtitle'] = (!empty($session_box['coach']) ? $session_box['coach'] . ' | ': '') . $session_box['dates'];
$sessionParams['show_actions'] = api_is_platform_admin();
$sessionParams['courses'] = $html_courses_session;
$sessionParams['show_simple_session_info'] = false;
@ -1303,10 +1305,14 @@ class IndexManager
}
$this->tpl->assign('session', $sessionParams);
$html_sessions .= $this->tpl->fetch(
$item = $this->tpl->fetch(
$this->tpl->get_template('user_portal/session.tpl')
);
$html_sessions .= $item;
$items[] = $item;
$sessionCount++;
}
}
@ -1352,16 +1358,19 @@ class IndexManager
}
$this->tpl->assign('session_category', $categoryParams);
$sessions_with_category .= $this->tpl->fetch(
"{$this->tpl->templateFolder}/user_portal/session_category.tpl"
);
$item = $this->tpl->fetch("{$this->tpl->templateFolder}/user_portal/session_category.tpl");
$sessions_with_category .= $item;
$items[] = $item;
}
}
}
}
$items = array_reverse($items);
return [
'html' => $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses,
'items' => $items,
'session_count' => $sessionCount,
'course_count' => $courseCount
];
@ -1421,7 +1430,7 @@ class IndexManager
if ($load_history) {
$html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
if (empty($session_categories)) {
$html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
$html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
}
}
@ -1473,7 +1482,7 @@ class IndexManager
$listUserCategories[0] = '';
$html = '<div class="session-view-block">';
$items = [];
foreach ($listUserCategories as $userCategoryId => $userCatTitle) {
// add user category
$userCategoryHtml = '';
@ -1529,7 +1538,7 @@ class IndexManager
}
$htmlSessionCategory .= '</div>'; // end session cat block
$htmlCategory .= $htmlSessionCategory .'</div>' ;
$htmlCategory .= ''; // end course block
$items[] = $htmlSessionCategory;
}
$userCategoryHtml .= $htmlCategory;
}
@ -1538,32 +1547,35 @@ class IndexManager
// if course not already added
$htmlCategory = '';
foreach ($listCoursesInfo as $i => $listCourse) {
$item = '';
if ($listCourse['userCatId'] == $userCategoryId && !isset($listCoursesAlreadyDisplayed[$listCourse['id']])) {
if ($userCategoryId != 0) {
$htmlCategory .= '<div class="session-view-row" >';
$item .= '<div class="session-view-row" >';
} else {
$htmlCategory .= '<div class="session-view-well well">';
$item .= '<div class="session-view-well well">';
}
$htmlCategory .= self::getHtmlForCourse(
$item .= self::getHtmlForCourse(
$listCourse['course'],
$userCategoryId,
0,
$loadDirs
);
$htmlCategory .= '</div>';
$item .= '</div>';
$htmlCategory .= $item;
$items[] = $item;
}
}
$htmlCategory .= '';
$userCategoryHtml .= $htmlCategory; // end user cat block
if ($userCategoryId != 0) {
$userCategoryHtml .= '</div>';
}
$html .= $userCategoryHtml; //
$html .= $userCategoryHtml;
}
$html .= '</div>';
return [
'html' => $html.$specialCourses,
'items' => $items,
'session_count' => $sessionCount,
'course_count' => $courseCount
];

@ -238,3 +238,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['messaging_gdc_project_number'] = '';
//Api Key in the Google Developer Console
//$_configuration['messaging_gdc_api_key'] = '';
// Userportal template located in main/template/default/user_portal
//$_configuration['user_portal_tpl'] = 'index_grid.tpl';

File diff suppressed because it is too large Load Diff

@ -215,6 +215,9 @@ if ($installType == 'update' && in_array($my_old_version, $update_from_version_8
}
}
$session_lifetime = 360000;
if (!isset($_GET['running'])) {
$dbHostForm = 'localhost';
$dbUsernameForm = 'root';
@ -252,7 +255,6 @@ if (!isset($_GET['running'])) {
$allowSelfReg = 1;
$allowSelfRegProf = 1;
$encryptPassForm = 'sha1';
$session_lifetime = 360000;
if (!empty($_GET['profile'])) {
$installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,3 @@
{% for item in items %}
{{ item }}
{% endfor %}

@ -0,0 +1,5 @@
{% for item in items %}
<div class="well">
{{ item }}
</div>
{% endfor %}

@ -21,83 +21,83 @@
{% endif %}
<div class="sessions panel-body">
{% if session.show_simple_session_info %}
<div class="row">
<div class="col-md-7">
<h3>
{{ session.title ~ session.notifications }}
</h3>
{% if session.show_simple_session_info %}
<div class="row">
<div class="col-md-7">
<h3>
{{ session.title ~ session.notifications }}
</h3>
{% if session.show_description %}
<div>
{{ session.description }}
</div>
{% endif %}
{% if session.show_description %}
<div>
{{ session.description }}
</div>
{% endif %}
{% if session.subtitle %}
<small>{{ session.subtitle }}</small>
{% endif %}
{% if session.subtitle %}
<small>{{ session.subtitle }}</small>
{% endif %}
{% if session.teachers %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.teachers }}</h5>
{% endif %}
{% if session.teachers %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.teachers }}</h5>
{% endif %}
{% if session.coaches %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.coaches }}</h5>
{% endif %}
</div>
{% if session.coaches %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.coaches }}</h5>
{% endif %}
</div>
{% if session.show_actions %}
<div class="col-md-5 text-right">
<a href="{{ _p.web_main ~ "session/resume_session.php?id_session=" ~ session.id }}">
<img src="{{ "edit.png"|icon(22) }}" width="22" height="22" alt="{{ "Edit"|get_lang }}" title="{{ "Edit"|get_lang }}">
</a>
{% if session.show_actions %}
<div class="col-md-5 text-right">
<a href="{{ _p.web_main ~ "session/resume_session.php?id_session=" ~ session.id }}">
<img src="{{ "edit.png"|icon(22) }}" width="22" height="22" alt="{{ "Edit"|get_lang }}" title="{{ "Edit"|get_lang }}">
</a>
</div>
{% endif %}
</div>
{% else %}
<div class="row">
<div class="col-md-12">
{% if session.subtitle %}
<div class="subtitle-session">
<em class="fa fa-clock-o"></em> {{ session.subtitle }}
</div>
{% endif %}
</div>
{% else %}
<div class="row">
<div class="col-md-12">
{% if session.subtitle %}
<div class="subtitle-session">
<em class="fa fa-clock-o"></em> {{ session.subtitle }}
</div>
{% endif %}
{% if session.show_description %}
<div class="description-session">
{{ session.description }}
</div>
{% endif %}
<div class="sessions-items">
{% for item in session.courses %}
<div class="row">
<div class="col-md-2">
{% if item.link %}
<a href="{{ item.link }}" class="thumbnail">{{ item.icon }}</a>
{% else %}
{{ item.icon }}
{% endif %}
</div>
<div class="col-md-10">
{{ item.title }}
{% if session.show_description %}
<div class="description-session">
{{ session.description }}
</div>
{% endif %}
<div class="sessions-items">
{% for item in session.courses %}
<div class="row">
<div class="col-md-2">
{% if item.link %}
<a href="{{ item.link }}" class="thumbnail">{{ item.icon }}</a>
{% else %}
{{ item.icon }}
{% endif %}
</div>
<div class="col-md-10">
{{ item.title }}
{% if item.coaches|length > 0 %}
<img src="{{ 'teacher.png'|icon(16) }}" width="16" height="16">
{% if item.coaches|length > 0 %}
<img src="{{ 'teacher.png'|icon(16) }}" width="16" height="16">
{% for coach in item.coaches %}
{{ loop.index > 1 ? ' | ' }}
{% for coach in item.coaches %}
{{ loop.index > 1 ? ' | ' }}
<a href="{{ _p.web_ajax ~ 'user_manager.ajax.php?' ~ {'a': 'get_user_popup', 'user_id': coach.user_id}|url_encode() }}" data-title="{{ coach.full_name }}" class="ajax">
{{ coach.full_name }}
</a>
{% endfor %}
{% endif %}
</div>
<a href="{{ _p.web_ajax ~ 'user_manager.ajax.php?' ~ {'a': 'get_user_popup', 'user_id': coach.user_id}|url_encode() }}" data-title="{{ coach.full_name }}" class="ajax">
{{ coach.full_name }}
</a>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>

@ -3,6 +3,8 @@
namespace Chamilo\CoreBundle\EventListener;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@ -45,6 +47,7 @@ class LegacyLoginListener implements EventSubscriberInterface
return;
}
$token = $this->tokenStorage->getToken();
if ($token) {
$isGranted = $this->container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
@ -67,23 +70,33 @@ class LegacyLoginListener implements EventSubscriberInterface
}
$languages = ['german' => 'de', 'english' => 'en', 'spanish' => 'es', 'french' => 'fr'];
if ($user && isset($languages[$user->getLanguage()])) {
$locale = $languages[$user->getLanguage()];
$locale = isset($languages[$user->getLanguage()]) ? $languages[$user->getLanguage()] : '';
if ($user && !empty($locale)) {
error_log('legacyloginlistener');
error_log($locale);
$user->setLocale($locale);
$request->getSession()->set('_locale_user', $locale);
//$request->getSession()->set('_locale_user', $locale);
// if no explicit locale has been set on this request, use one from the session
$request->setLocale($locale);
$request->getSession()->set('_locale', $locale);
$request->setLocale($locale);
}
$token = new UsernamePasswordToken($user, null, "main", $user->getRoles());
$this->tokenStorage->setToken($token); //now the user is logged in
//now dispatch the login event
$event = new InteractiveLoginEvent($request, $token);
$this->container->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$this->container->get("event_dispatcher")->addListener(
KernelEvents::RESPONSE, array($this, 'redirectUser')
);
}
}
}
@ -98,7 +111,18 @@ class LegacyLoginListener implements EventSubscriberInterface
{
return array(
// must be registered before the default Locale listener
KernelEvents::REQUEST => array(array('onKernelRequest', 17)),
KernelEvents::REQUEST => array(array('onKernelRequest', 15)),
);
}
/**
* @param FilterResponseEvent $event
*/
public function redirectUser(FilterResponseEvent $event)
{
$uri = $event->getRequest()->getUri();
// on effectue la redirection
$response = new RedirectResponse($uri);
$event->setResponse($response);
}
}

@ -0,0 +1,89 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Chamilo\CoreBundle\Controller\LegacyController;
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter;
use Chamilo\CoreBundle\Framework\Container;
use Doctrine\ORM\EntityManager;
use Chamilo\UserBundle\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Chamilo\CourseBundle\Controller\ToolInterface;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Chamilo\CourseBundle\Event\CourseAccess;
use Chamilo\CourseBundle\Event\SessionAccess;
/**
* Class LocaleListener
* @package Chamilo\CoreBundle\EventListener
*/
class LocaleListener implements EventSubscriberInterface
{
private $defaultLocale;
/** @var ContainerInterface */
protected $container;
/**
* @param string $defaultLocale
*/
public function __construct($defaultLocale = 'en', $container)
{
$this->defaultLocale = $defaultLocale;
$this->container = $container;
}
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
if (!$request->hasPreviousSession()) {
return;
}
// try to see if the locale has been set as a _locale routing parameter
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $locale);
} else {
$locale = $this->defaultLocale;
// 2. Check user locale
// _locale_user is set when user logins the system check UserLocaleListener
$userLocale = $request->getSession()->get('_locale');
if (!empty($userLocale)) {
$locale = $userLocale;
}
// if no explicit locale has been set on this request, use one from the session
$request->setLocale($locale);
$request->getSession()->set('_locale', $locale);
}
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return array(
// must be registered before the default Locale listener
KernelEvents::REQUEST => array(array('onKernelRequest', 15)),
);
}
}

@ -51,18 +51,10 @@ class UserLocaleListener
if ($token) {
$user = $token->getUser();
if ($user && isset($languages[$user->getLanguage()])) {
$user->setLocale($languages[$user->getLanguage()]);
$event->getRequest()->setLocale($user->getLocale());
$this->session->set('_locale', $user->getLocale());
$this->session->set('_locale_user', $user->getLocale());
$locale = isset($languages[$user->getLanguage()]) ? $languages[$user->getLanguage()] : '';
if ($user && !empty($locale)) {
$this->session->set('_locale', $locale);
}
}
/*if (null !== $user->getLocale()) {
$this->session->set('_locale', $user->getLocale());
$this->session->set('_locale_user', $user->getLocale());
}*/
}
}

@ -145,7 +145,15 @@ services:
arguments: ["@session"]
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
# - { name: kernel.event_listener, event: kernel.request, method: setLocaleForUnauthenticatedUser}
chamilo_core.listener.locale:
class: Chamilo\CoreBundle\EventListener\LocaleListener
arguments: ["%kernel.default_locale%", "@service_container"]
tags:
- { name: kernel.event_subscriber }
#
# # Settings listener
# chamilo_core.listener.settings:
@ -177,7 +185,7 @@ services:
# tags:
# - { name: kernel.event_listener, event: theme.messages, method: onListMessages }
#
# # Login listener - When user logs in
# Login listener - When user logs in
# chamilo_core.listener.login_success_handler:
# class: Chamilo\CoreBundle\EventListener\LoginSuccessHandler
# arguments: [@router, @security.authorization_checker]

@ -154,6 +154,12 @@ class CQuiz
*/
private $propagateNeg;
/**
* @var boolean
* @ORm\Column(name="save_correct_answers", type="boolean", nullable=false)
*/
private $saveCorrectAnswers;
/**
* @var integer
*
@ -564,6 +570,25 @@ class CQuiz
return $this->propagateNeg;
}
/**
* @param $saveCorrectAnswers boolean
* @return CQuiz
*/
public function setSaveCorrectAnswers($saveCorrectAnswers)
{
$this->saveCorrectAnswers = $saveCorrectAnswers;
return $this;
}
/**
* @return boolean
*/
public function getSaveCorrectAnswers()
{
return $this->saveCorrectAnswers;
}
/**
* Set reviewAnswers
*

@ -185,13 +185,20 @@ if (api_get_setting('go_to_course_after_login') == 'true') {
}
}
//Show the chamilo mascot
// Show the chamilo mascot
if (empty($courseAndSessions['html']) && !isset($_GET['history'])) {
$controller->tpl->assign('welcome_to_course_block', $controller->return_welcome_to_course_block());
}
$controller->tpl->assign('content', $courseAndSessions['html']);
$template = api_get_configuration_value('user_portal_tpl');
if (empty($template)) {
$controller->tpl->assign('content', $courseAndSessions['html']);
} else {
$controller->tpl->assign('items', $courseAndSessions['items']);
$userPortalTemplate = $controller->tpl->get_template('user_portal/'.$template);
$content = $controller->tpl->fetch($userPortalTemplate);
$controller->tpl->assign('content', $content);
}
if (api_get_setting('allow_browser_sniffer') == 'true') {
if (isset($_SESSION['sniff_navigator']) && $_SESSION['sniff_navigator'] != "checked") {

@ -5,18 +5,6 @@
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks
# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
# to the front controller "/app.php" but be rewritten to "/app.php/app".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@ -30,10 +18,6 @@ DirectoryIndex app.php
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/app.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
@ -46,15 +30,15 @@ DirectoryIndex app.php
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule .? - [L]
# Rewrite all other queries to the front controller.
RewriteRule ^ %{ENV:BASE}/app.php [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>

Loading…
Cancel
Save