Merge branch 'master' of git.beeznest.com:minedu-chamilo

skala
Julio Montoya 12 years ago
commit c04a6ec240
  1. 1
      console.php
  2. 3
      main/exercice/exercise.class.php
  3. 50
      src/ChamiloLMS/Command/Modulation/ModulationIsolateKeyCommand.php
  4. 55
      src/ChamiloLMS/Command/Modulation/ModulationUsersInExamCommand.php
  5. 1
      src/ChamiloLMS/Component/Auth/LoginSuccessHandler.php

@ -88,6 +88,7 @@ $cli->addCommands(
new ChamiloLMS\Command\Modulation\ModulationStopTurnCommand(),
new ChamiloLMS\Command\Modulation\ModulationIsolateKeyCommand(),
new ChamiloLMS\Command\Modulation\ModulationDuplicateInstallCommand(),
new ChamiloLMS\Command\Modulation\ModulationUsersInExamCommand(),
// Chash commands.
new Chash\Command\Database\RunSQLCommand(),

@ -6910,7 +6910,6 @@ class Exercise
array()
);
/*
$log_transactions_settings = TransactionLog::getTransactionSettings();
if (isset($log_transactions_settings['exercise_attempt'])) {
$transaction_controller = new TransactionLogController();
@ -6931,7 +6930,7 @@ class Exercise
$transaction = $transaction_controller->createTransaction('exercise_attempt', $transaction_data);
}
$transaction->save();
}*/
}
}
// Send notification.

@ -39,6 +39,9 @@ class ModulationIsolateKeyCommand extends Command
Session::setSession($app['session']);
Session::write('_user', api_get_user_info(1));
$destDir = '/var/opt/keys';
$certServ = 'http://debian4.beeznest.org/keys/';
$branchId = intval($input->getArgument('key'));
$sql = "SELECT session_id FROM branch_rel_session WHERE branch_id = $branchId ORDER BY display_order";
$res = Database::query($sql);
@ -64,37 +67,60 @@ class ModulationIsolateKeyCommand extends Command
// optional clean-up. Delete if necessary
$sql2 = "DELETE FROM branch_sync where branch_id != $branchId";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM session WHERE id NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM session_rel_course WHERE id_session NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM session_rel_course_rel_user WHERE id_session NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM session_rel_user WHERE id_session NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM c_quiz_distribution_rel_session WHERE session_id NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM access_url_rel_session WHERE session_id NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM branch_rel_session WHERE session_id NOT IN (".implode(', ',$sessions).")";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql2 = "DELETE FROM user WHERE user_id NOT IN (".implode(', ',$sessionUsers).") AND user_id > 1";
echo $sql2."\n";
//Database::query($sql2);
Database::query($sql2);
$sql3 = "SELECT count(*) FROM user";
$res3 = Database::query($sql3);
$count = Database::fetch_row($res3);
// Set the local branch accordindly.
// See if it's there before.
$local_branch_settings = api_get_settings_params_simple(array('variable = ?' => 'local_branch_id'));
if (empty($local_branch_settings['selected_value'])) {
$insert_local_branch_sql = sprintf("INSERT INTO settings_current (variable, type, category, selected_value, title, comment, access_url_changeable)
VALUES ('local_branch_id', 'textfield', 'LogTransactions', %d, 'LogTransactionsDefaultBranch', 'LogTransactionsDefaultBranchComment', 1)", $branchId);
Database::query($insert_local_branch_sql);
}
else {
$update_local_branch_sql = sprintf("UPDATE settings_current SET selected_value = %d WHERE variable = 'local_branch_id'", $branchId);
Database::query($update_local_branch_sql);
}
$output->writeln("$count users remain");
$output->writeln('The database should now be isolated.');
return true;
//$output->writeln("$count users remain");
//$output->writeln('The database should now be isolated.');
// Make dir if not present. Assume the command succeeds as everything
// executes as root anyway
if (!is_dir($destDir)) {
@mkdir($destDir);
}
// Get the SSL certificate from the server, at
// http://server/keys/24.p12
$cert = file_get_contents($certServ.$branchId.'.p12');
@file_put_contents($destDir.'/'.$branchId.'.p12',$cert);
$caPub = file_get_contents($certServ.'ca-cert.pem');
@file_put_contents($destDir.'/ca-cert.pem',$caPub);
}
}

@ -0,0 +1,55 @@
<?php
namespace ChamiloLMS\Command\Modulation;
use Database;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use \ChamiloSession as Session;
use \UserManager as UserManager;
use Entity;
/**
* This command "starts a turn" (in Chamilo language, makes a session available)
* for all its users (they need to already be subscribed to the session)
*
* Assumptions:
* - the session exists but has start and end date previous to the real exam date
* - the session is made available simply by making the start and end date period so large that there's no chance it wouldn't work
* - users need to be subscribed to the session already
* - the context must be very limited: the turn is defined by the display_order field in the branch_rel_session table. The value of display_order must be unique in this table (you cannot have more than one branch with sessions)
*/
class ModulationUsersInExamCommand extends Command
{
protected function configure()
{
$this
->setName('modulation:users-in-exam')
->setDescription('Gets the number of users still busy taking an exam');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// This is just wrong, but was requested. Used to pass a session_id to
// be used on the MineduAuthHttpsPostSend plugin.
global $session_id, $app;
Session::setSession($app['session']);
Session::write('_user', api_get_user_info(1));
$sql = "SELECT NOW()";
$res = Database::query($sql);
$row = Database::fetch_row($res);
$current_date = $row[0];
$query = "SELECT count(distinct(user_id)) ".
" FROM track_e_attempt ".
" WHERE DATE_ADD(tms, ".
" INTERVAL 2 MINUTE) >= '".$current_date."' ";
$res = Database::query($query);
$row = Database::fetch_row($res);
$output->writeln($row[0]);
return true;
}
}

@ -79,6 +79,7 @@ class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
foreach ($personal_course_list as $course) {
if (!empty($course['session_id'])) {
if (api_get_session_visibility($course['session_id'],$course['id']) != SESSION_AVAILABLE) { continue; }
$my_session_list[$course['session_id']] = true;
$count_of_courses_with_sessions++;
} else {

Loading…
Cancel
Save