format code

pull/2487/head
jmontoyaa 9 years ago
parent 7373961cd8
commit b362d92fe2
  1. 2
      tests/datafiller/data_courses.php
  2. 6
      tests/datafiller/data_users.php
  3. 25
      tests/datafiller/fill_all.php
  4. 59
      tests/datafiller/fill_many_users.php
  5. 6
      tests/datafiller/fill_users.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
);

@ -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',

@ -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.
@ -9,9 +9,6 @@
* @author Yannick Warnier <yannick.warnier@dokeos.com>
*/
/**
* Initialisation section
*/
$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
*/

@ -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;
}

@ -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

Loading…
Cancel
Save