Browse Source

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

Angel Fernando Quiroz Campos 8 years ago
parent
commit
389094aa60

+ 1 - 1
main/document/document.php

@@ -1303,7 +1303,7 @@ if ($is_allowed_to_edit ||
                 $courseInfo,
                 api_get_user_id(),
                 $sessionId,
-                $groupIid,
+                $groupId,
                 $to_user_id,
                 $base_work_dir,
                 $dir_name,

+ 13 - 9
main/exercise/exercise.php

@@ -563,6 +563,8 @@ if (isset($list_ordered) && !empty($list_ordered)) {
     $exercise_list = $new_question_list;
 }
 
+$tableRows = [];
+
 /*  Listing exercises  */
 if (!empty($exercise_list)) {
     if ($origin != 'learnpath') {
@@ -895,13 +897,13 @@ if (!empty($exercise_list)) {
                 // Don't remove this marker: note-query-exe-results
                 $sql = "SELECT * FROM $TBL_TRACK_EXERCISES
                         WHERE
-                            exe_exo_id      = ".$row['id']." AND
-                            exe_user_id     = ".$userId." AND
-                            c_id    = ".api_get_course_int_id()." AND
-                            status          <> 'incomplete' AND
-                            orig_lp_id      = 0 AND
+                            exe_exo_id = ".$row['id']." AND
+                            exe_user_id = $userId AND
+                            c_id = ".api_get_course_int_id()." AND
+                            status <> 'incomplete' AND
+                            orig_lp_id = 0 AND
                             orig_lp_item_id = 0 AND
-                            session_id      =  '".api_get_session_id()."'
+                            session_id =  '".api_get_session_id()."'
                         ORDER BY exe_id DESC";
 
                 $qryres = Database::query($sql);
@@ -967,7 +969,10 @@ if (!empty($exercise_list)) {
                         if ($num > 0) {
                             $row_track = Database :: fetch_array($qryres);
                             $attempt_text = get_lang('LatestAttempt').' : ';
-                            $attempt_text .= ExerciseLib::show_score($row_track['exe_result'], $row_track['exe_weighting']);
+                            $attempt_text .= ExerciseLib::show_score(
+                                $row_track['exe_result'],
+                                $row_track['exe_weighting']
+                            );
                         } else {
                             $attempt_text = get_lang('NotAttempted');
                         }
@@ -1012,8 +1017,7 @@ if (!empty($exercise_list)) {
                     'id' => 'exercise_list_' . $my_exercise_id,
                 )
             );
-
-        } // end foreach()
+        }
     }
 }
 

+ 6 - 2
main/exercise/exercise_show.php

@@ -208,7 +208,7 @@ if (!empty($track_exercise_info)) {
         if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
             $show_results = false;
             if ($origin != 'learnpath') {
-                echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
+                /*echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
                       <tr>
                         <td colspan="2">';
                 Display::display_warning_message(
@@ -217,7 +217,7 @@ if (!empty($track_exercise_info)) {
                 );
                 echo '</td>
                 </tr>
-                </table>';
+                </table>';*/
             }
         } elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
             $show_results = false;
@@ -262,6 +262,10 @@ if ($origin == 'learnpath' && !isset($_GET['fb_type'])) {
     $show_results = false;
 }
 
+if ($is_allowedToEdit && in_array($action, ['qualify', 'edit'])) {
+    $show_results = true;
+}
+
 if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) {
     $user_info = api_get_user_info($student_id);
     //Shows exercise header

+ 10 - 6
main/glossary/index.php

@@ -198,10 +198,8 @@ switch ($action) {
         );
         $form->addElement('header', '', get_lang('ImportGlossary'));
         $form->addElement('file', 'file', get_lang('ImportCSVFileLocation'));
-
         $form->addElement('checkbox', 'replace', null, get_lang('DeleteAllGlossaryTerms'));
         $form->addElement('checkbox', 'update', null, get_lang('UpdateExistingGlossaryTerms'));
-
         $form->addButtonImport(get_lang('Import'), 'SubmitImport');
         $content = $form->returnForm();
 
@@ -316,13 +314,19 @@ switch ($action) {
 
             if (count($badList) > 0) {
                 Display::addFlash(
-                    Display::return_message(get_lang("GlossaryTermAlreadyExists").': ' . implode(', ', $badList), 'error')
+                    Display::return_message(
+                        get_lang("GlossaryTermAlreadyExists").': ' . implode(', ', $badList),
+                        'error'
+                    )
                 );
             }
 
             if (count($doubles) > 0) {
                 Display::addFlash(
-                    Display::return_message(get_lang("TermsDuplicatedInFile").': '.implode(', ', $doubles), 'warning')
+                    Display::return_message(
+                        get_lang("TermsDuplicatedInFile").': '.implode(', ', $doubles),
+                        'warning'
+                    )
                 );
             }
 
@@ -343,9 +347,9 @@ switch ($action) {
 
         usort($data, "sorter");
         $list = array();
-        $list[] = array('term','definition');
+        $list[] = array('term', 'definition');
         foreach ($data as $line) {
-            $list[] = array ($line[0], $line[1]);
+            $list[] = array($line[0], $line[1]);
         }
         $filename = 'glossary_course_'.api_get_course_id();
         Export::arrayToCsv($list, $filename);

+ 7 - 5
main/inc/lib/api.lib.php

@@ -5045,7 +5045,7 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
         // Found item for this access_url.
         $row = Database::fetch_array($res);
         $sql = "UPDATE $t_settings SET selected_value = '$value'
-                WHERE id = ".$row['id'] ;
+                WHERE id = ".$row['id'];
         Database::query($sql);
     } else {
         // Item not found for this access_url, we have to check if it exist with access_url = 1
@@ -5071,8 +5071,9 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
                         "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
                         "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
                 Database::query($insert);
-            } else { // Such a setting does not exist.
-                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0);
+            } else {
+                // Such a setting does not exist.
+                //error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0);
             }
         } else {
             // Other access url.
@@ -5084,7 +5085,8 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
             }
             $res = Database::query($select);
 
-            if (Database::num_rows($res) > 0) { // We have a setting for access_url 1, but none for the current one, so create one.
+            if (Database::num_rows($res) > 0) {
+                // We have a setting for access_url 1, but none for the current one, so create one.
                 $row = Database::fetch_array($res);
                 if ($row['access_url_changeable'] == 1) {
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
@@ -5098,7 +5100,7 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url
                     Database::query($insert);
                 }
             } else { // Such a setting does not exist.
-                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
+                //error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
             }
         }
     }

+ 1 - 1
main/inc/lib/export.lib.inc.php

@@ -43,7 +43,6 @@ class Export
     public static function arrayToCsv($data, $filename = 'export')
     {
         if (empty($data)) {
-
             return false;
         }
 
@@ -53,6 +52,7 @@ class Export
         $writer->setStream(fopen($filePath, 'w'));
 
         foreach ($data as $item) {
+            $item = array_map('trim', $item);
             $writer->writeItem($item);
         }
         $writer->finish();

+ 1 - 1
main/mySpace/myStudents.php

@@ -733,7 +733,7 @@ if (!empty($student_id)) {
                         }
 
                         $scoretotal_display = '0/0 (0%)';
-                        if (!empty($scoretotal)) {
+                        if (!empty($scoretotal) && !empty($scoretotal[1])) {
                             $scoretotal_display =
                                 round($scoretotal[0], 1 ).'/'.
                                 round($scoretotal[1], 1).

+ 2 - 2
main/upload/upload.document.php

@@ -56,7 +56,7 @@ if (isset($_FILES['user_upload'])) {
             $base_work_dir,
             $_POST['curdirpath'],
             api_get_user_id(),
-            $to_group_id,
+            api_get_group_id(),
             $to_user_id,
             $_POST['unzip'],
             $_POST['if_exists']
@@ -138,7 +138,7 @@ if (isset($_POST['create_dir']) && $_POST['dirname']!='') {
         $_course,
         api_get_user_id(),
         api_get_session_id(),
-        $to_group_id,
+        api_get_group_id(),
         $to_user_id,
         $base_work_dir,
         $dir_name,

+ 4 - 5
main/work/work.lib.php

@@ -510,11 +510,11 @@ function showStudentWorkGrid()
     );
 
     $columnModel = array(
-        array('name'=>'type', 'index'=>'type', 'width'=>'30',   'align'=>'center', 'sortable' => 'false'),
+        array('name'=>'type', 'index'=>'type', 'width'=>'30', 'align'=>'center', 'sortable' => 'false'),
         array('name'=>'title', 'index'=>'title', 'width'=>'250',   'align'=>'left'),
         array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'80',  'align'=>'center', 'sortable'=>'false'),
-        array('name'=>'feedback', 'index'=>'feedback', 'width'=>'80',  'align'=>'center'),
-        array('name'=>'last_upload', 'index'=>'feedback', 'width'=>'125',  'align'=>'center'),
+        array('name'=>'feedback', 'index'=>'feedback', 'width'=>'80',  'align'=>'center', 'sortable'=>'false'),
+        array('name'=>'last_upload', 'index'=>'feedback', 'width'=>'125',  'align'=>'center', 'sortable'=>'false')
     );
 
     if ($courseInfo['show_score'] == 0) {
@@ -554,7 +554,7 @@ function showTeacherWorkGrid()
         array('name'=>'title', 'index'=>'title',  'width'=>'300',   'align'=>'left', 'wrap_cell' => "true"),
         array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'125',  'align'=>'center'),
         array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'125',  'align'=>'center'),
-        array('name'=>'amount', 'index'=>'end_on', 'width'=>'110',  'align'=>'center'),
+        array('name'=>'amount', 'index'=>'amount', 'width'=>'110',  'align'=>'center', 'sortable' => 'false'),
         array('name'=>'actions', 'index'=>'actions', 'width'=>'110', 'align'=>'left', 'sortable'=>'false')
     );
 
@@ -1414,7 +1414,6 @@ function getWorkListStudent(
             $work['last_upload'] .= api_get_local_time($lastWork['sent_date']);
         }
 
-
         $work['title'] = Display::url($work['title'], $url.'&id='.$work['id']);
         $work['others'] = Display::url(
             Display::return_icon('group.png', get_lang('Others')),

+ 2 - 4
main/work/work.php

@@ -1,8 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
 
-use ChamiloSession as Session;
-
 /**
  *	@package chamilo.work
  **/
@@ -333,9 +331,9 @@ switch ($action) {
                 get_lang('Description').':'.Security::remove_XSS($my_folder_data['description'], STUDENT).
                 '</div>';
         }
-        if (api_is_allowed_to_edit() || api_is_coach()) {
-            // Work list
 
+        // Work list
+        if (api_is_allowed_to_edit() || api_is_coach()) {
             $content .= '<div class="row">';
             $content .= '<div class="col-md-12">';
             $content .= '<div class="table-responsive">';

+ 3 - 1
src/Chamilo/CoreBundle/Component/Utils/ChamiloApi.php

@@ -129,13 +129,15 @@ class ChamiloApi
 
         return \Display::url($image, api_get_path(WEB_PATH) . 'index.php');
     }
+
     /**
      * Like strip_tags(), but leaves an additional space and removes only the given tags
      * @param string $string
      * @param array $tags Tags to be removed
      * @return  string The original string without the given tags
      */
-    public static function stripGivenTags($string, $tags) {
+    public static function stripGivenTags($string, $tags)
+    {
         foreach ($tags as $tag) {
             $string2 = preg_replace('#</' . $tag . '[^>]*>#i', ' ', $string);
             if ($string2 != $string) {

+ 1 - 1
tests/datafiller/data_courses.php

@@ -130,6 +130,6 @@ $courses[] = array(
     'course_language' => 'english',
     'user_id' => 1,
     'expiration_date' => '2020-09-01 00:00:00',
-    'exemplary_content' => true,
+    'exemplary_content' => true
 );
 

+ 2 - 4
tests/datafiller/data_users.php

@@ -1,4 +1,4 @@
-<?php //$id$
+<?php
 /**
  * This script contains the data to fill (or empty) the database with using
  * the fillers in this directory.
@@ -7,9 +7,7 @@
  * @author Yannick Warnier <yannick.warnier@dokeos.com>
  *
  */
-/**
- * Initialisation section
- */
+
 $users = array();
 $users[] = array(
     'username' => 'ywarnier',

+ 14 - 15
tests/datafiller/fill_all.php

@@ -1,4 +1,4 @@
-<?php //$id$
+<?php
 /**
  * This script contains calls to the various filling scripts that allow a
  * demo presenter to fill his Dokeos with demo data.
@@ -8,11 +8,8 @@
  * on your system and t launch this script manually using: php5 fill_all.php
  * @author Yannick Warnier <yannick.warnier@dokeos.com>
  */
- 
-/**
- * Initialisation section
- */
-$incdir = dirname(__FILE__).'/../../main/inc/'; 
+
+$incdir = dirname(__FILE__).'/../../main/inc/';
 require $incdir.'global.inc.php';
 
 /**
@@ -24,23 +21,25 @@ $eol = PHP_EOL;
 $output = '';
 $files = scandir(dirname(__FILE__));
 foreach ($files as $file) {
-	if (substr($file,0,1) == '.' or substr($file,0,5) != 'fill_') { ; } //skip
-    else {    	
-    	if ($file == basename(__FILE__)) {
-    		//skip, this is the current file
-    	} else {
+    if (substr($file, 0, 1) == '.' or substr($file, 0, 5) != 'fill_') {
+        ;
+    } else {
+        if ($file == basename(__FILE__)) {
+            //skip, this is the current file
+        } else {
             $output .= $eol.'Reading file: '.$file.$eol;
-    		require_once $file;
-            $function = basename($file,'.php');
+            require_once $file;
+            $function = basename($file, '.php');
             if (function_exists($function)) {
-            	$output .= $eol.'Executing function '.$function.$eol;
+                $output .= $eol.'Executing function '.$function.$eol;
                 $function();
             } else {
                 //function not found
             }
-    	}
+        }
     }
 }
+
 /**
  * Display
  */

+ 41 - 18
tests/datafiller/fill_many_users.php

@@ -1,38 +1,61 @@
-<?php //$id$
+<?php
 /**
  * This script contains a data filling procedure for users
  * @author Yannick Warnier <yannick.warnier@beeznest.com>
  *
  */
-/**
- * Initialisation section
- */
+
 require '../../main/inc/global.inc.php';
+
 /**
  * Executing
  */
-fill_many_users(100000);
+//fill_many_users(100000);
+
 /**
  * Loads the data and injects it into the Chamilo database, using the Chamilo
  * internal functions.
  * @return  array  List of user IDs for the users that have just been inserted
  */
-function fill_many_users($num) {
-	$eol = PHP_EOL;
+function fill_many_users($num)
+{
     $users = array(); //declare only to avoid parsing notice
     require_once 'data_users.php'; //fill the $users array
     $i = 1;
+    $output = [];
+
+    $batchSize = 20;
+    $em = Database::getManager();
+
     while ($i < $num) {
-      $output = array();
-      $output[] = array('title'=>'Users Filling Report:');
-      foreach ($users as $j => $user) {
-        //first check that the first item doesn't exist already
-    	$output[$i]['line-init'] = $user['firstname'];
-        $res = UserManager::create_user($user['firstname'],$user['lastname'],$user['status'],$user['email'],$user['username'].$i,$user['pass'],null,null,null,null,$user['auth_source'],null,$user['active']);
-    	$output[$i]['line-info'] = ($res ? get_lang('Inserted') : get_lang('NotInserted')).' '.$user['username'].$i;
-    	$i++;
-      }
-      print_r($output);
+        $output[] = array('title' => 'Users Filling Report:');
+        foreach ($users as $j => $user) {
+            //first check that the first item doesn't exist already
+            $output[$i]['line-init'] = $user['firstname'];
+            $res = UserManager::create_user(
+                $user['firstname'],
+                $user['lastname'],
+                $user['status'],
+                $i.'_'.$user['email'],
+                $i.'_'.$user['username'],
+                $user['pass'],
+                null,
+                null,
+                null,
+                null,
+                $user['auth_source'],
+                null,
+                $user['active']
+            );
+            $output[$i]['line-info'] = ($res ? get_lang('Inserted') : get_lang('NotInserted')).' '.$user['username'].$i;
+            $i++;
+
+            if (($i % $batchSize) === 0) {
+                $em->flush();
+                $em->clear(); // Detaches all objects from Doctrine!
+            }
+        }
     }
-    //return $output;
+
+    return $output;
 }

+ 2 - 4
tests/datafiller/fill_users.php

@@ -1,12 +1,10 @@
-<?php //$id$
+<?php
+
 /**
  * This script contains a data filling procedure for users
  * @author Yannick Warnier <yannick.warnier@beeznest.com>
  *
  */
-/**
- * Initialisation section
- */
 
 /**
  * Loads the data and injects it into the Chamilo database, using the Chamilo