skala
Julio Montoya 12 years ago
commit 4b82fad6e7
  1. 27
      main/inc/lib/usermanager.lib.php
  2. 124
      tests/migrate/fix_missing_attendances.php
  3. 41
      tests/migrate/fix_total_attendances.php
  4. 1
      tests/migrate/migrate.php
  5. 6
      tests/migrate/migration.class.php
  6. 159
      tests/migrate/migration.custom.class.php
  7. 37
      tests/migrate/transaction.cron.php
  8. 57
      tests/video/index.php

@ -2223,9 +2223,9 @@ class UserManager {
/**
* Gives a list of [session_category][session_id] for the current user.
* @param integer $user_id
* @param boolean optional true if limit time from session is over, false otherwise
* @param boolean Whether to return only a count (true) or the full result (false)
* @param boolean Whether to order by alphabetical order (false) or reverse-alphabetical
* @param boolean optional true if we want to see expired sessions, false otherwise
* @param boolean Whether to return only a count (true) or the full result (false)
* @param boolean Whether to order by alphabetical order (false) or reverse-alphabetical (used in history to show latest sessions on top)
* @return array list of statuses [session_category][session_id]
* @todo ensure multiple access urls are managed correctly
*/
@ -2243,7 +2243,10 @@ class UserManager {
$now = api_get_utc_datetime();
// Get the list of sessions per user
$condition_date_end = null;
$condition_date_start1 = null;
$condition_date_start2 = null;
$condition_date_end1 = null;
$condition_date_end2 = null;
// uncomment commented query lines to alter the query sorting
//$order = ' ORDER BY session_category_name, short_name ';
$order = ' ORDER BY session_category_name, name ';
@ -2257,10 +2260,12 @@ class UserManager {
} else {
if (api_is_allowed_to_create_course()) {
//Teachers can access the session depending in the access_coach date
$condition_date_end1 = null;
$condition_date_end2 = null;
$condition_date_start1 = " AND (session.coach_access_start_date <= '$now' OR session.coach_access_start_date = '0000-00-00 00:00:00') ";
$condition_date_start2 = " AND (session.coach_access_start_date <= '$now' OR session.coach_access_start_date = '0000-00-00 00:00:00') ";
} else {
//Student can't access before this dates
//Student can't access before the start date or after the end date
$condition_date_start1 = " AND (session.access_start_date <= '$now' OR session.access_start_date = '0000-00-00 00:00:00') ";
$condition_date_start2 = " AND (session.access_start_date <= '$now' OR session.access_start_date = '0000-00-00 00:00:00') ";
$condition_date_end1 = " AND (session.access_end_date >= '$now' OR session.access_end_date = '0000-00-00 00:00:00') ";
$condition_date_end2 = " AND (session.access_end_date >= '$now' OR session.access_end_date = '0000-00-00 00:00:00') ";
}
@ -2319,17 +2324,17 @@ class UserManager {
while ($row1 = Database::fetch_array($result1)) {
if (!in_array($row1['id'],$ids)) {
if ($reverse_order) {
while (strcmp($row1['session_category_name'],$join[$i]['session_category_name'])<=0 && isset($join[$i])) {
while (isset($join[$i]) && strcmp($row1['session_category_name'],$join[$i]['session_category_name'])<=0) {
$ordered_join[] = $join[$i];
$i++;
}
} else {
while (strcmp($row1['session_category_name'],$join[$i]['session_category_name'])>0 && isset($join[$i])) {
while (isset($join[$i]) && strcmp($row1['session_category_name'],$join[$i]['session_category_name'])>0) {
$ordered_join[] = $join[$i];
$i++;
}
if (strcmp($row1['session_category_name'],$join[$i]['session_category_name']) === 0 && isset($join[$i])) {
while (strcmp($row1['short_name'],$join[$i]['short_name'])>0) {
if (isset($join[$i]) && strcmp($row1['session_category_name'],$join[$i]['session_category_name']) === 0) {
while (isset($join[$i]) && strcmp($row1['short_name'],$join[$i]['short_name'])>0) {
$ordered_join[] = $join[$i];
$i++;
}

@ -0,0 +1,124 @@
<?php
/**
* Fix missing attendances by checking all empty attendances in the
* c_attendance_sheet table and calling, for each miss, the corresponding
* web service (transaction_34) to update the data.
*/
require '../../main/inc/global.inc.php';
require '../../main/inc/lib/attendance.lib.php';
require 'config.php';
require 'db_matches.php';
require 'migration.class.php';
require 'migration.mssql.class.php';
require 'migration.custom.class.php';
$sql = "SELECT count(*) FROM c_attendance_sheet WHERE presence = 4";
$res = Database::query($sql);
$count = Database::result($res);
echo "Found $count undefined attendances\n";
$s1 = "SELECT id FROM user_field WHERE field_variable = 'uidIdPersona'";
$r1 = Database::query($s1);
$uidf = Database::result($r1);
$s2 = "SELECT id FROM session_field WHERE field_variable = 'sede'";
$r2 = Database::query($s2);
$sedef = Database::result($r2);
$s3 = "SELECT id FROM session_field WHERE field_variable = 'uidIdPrograma'";
$r3 = Database::query($s3);
$sidf = Database::result($r3);
$sedes = array(
'8F67B2B3-667E-4EBC-8605-766D2FF71B55' => 1,
'7379A7D3-6DC5-42CA-9ED4-97367519F1D9' => 2,
'30DE73B6-8203-4F81-96C8-3B27977BB924' => 3,
'8BA65461-60B5-4716-BEB3-22BC7B71BC09' => 4,
'257AD17D-91F7-4BC8-81D4-71EBD35A4E50' => 5,
);
$a = new Attendance();
$sqlsc = "SELECT s.id_session, c.id as course_id FROM session_rel_course s INNER JOIN course c ON s.course_code=c.code ORDER BY id_session, course_id";
$ressc = Database::query($sqlsc);
$sessions_list = array();
while ($rowsc = Database::fetch_assoc($ressc)) {
$sessions_list[$rowsc['id_session']] = $rowsc['course_id'];
}
//$sessions_list = SessionManager::get_sessions_list();
$min = 145150;
$max = 145150;
// Get sessions
foreach ($sessions_list as $session_id => $course_id) {
if ($session_id < $min) { continue; }
$out1 = "Session ".$session_id.", course ".$course_id."\n";
echo $out1;
// Get branch for session
$ss1 = "SELECT field_value FROM session_field_values WHERE field_id = $sedef AND session_id = ".$session_id;
$rs1 = Database::query($ss1);
$sede = Database::result($rs1);
// Get uidIdPrograma
$ss2 = "SELECT field_value FROM session_field_values WHERE field_id = $sidf AND session_id = ".$session_id;
$rs2 = Database::query($ss2);
$sid = Database::result($rs2);
// Get users in session to build users list
$users = SessionManager::get_users_by_session($session_id);
$u = array();
foreach ($users as $user) {
$u[] = $user['user_id'];
}
// Get courses list to get the right course (only one in each session)
//$courses = SessionManager::get_course_list_by_session_id($session_id);
//if (count($courses)>0) {
// foreach ($courses as $course) {
// $course_id = $course['id'];
// break;
// }
if (!empty($course_id)) {
$out2 = "-- Course ".$course_id."\n";
// Get attendances sheets from course (only one in each course)
$att = $a->get_attendances_list($course_id,$session_id);
if (count($att)>0) {
foreach ($att as $at) {
$at_id = $at['id'];
break; //get out after first result
}
$out3 = "---- Attendance ".$at_id."\n";
$a->set_course_int_id($course_id);
$cal_list = $a->get_attendance_calendar($at_id);
$cal_count = count($cal_list);
foreach ($cal_list as $cal) {
$cal_id = $cal['id'];
$sql = "SELECT * FROM c_attendance_sheet WHERE c_id = $course_id AND attendance_calendar_id = $cal_id";
$res_att = Database::query($sql);
$att_count = Database::num_rows($res_att);
if ($att_count < count($u)) {
$out4 = "------ Found $att_count when should have found ".count($u)." attendances for ".$cal['date_time']."\n";
echo $out1.$out2.$out3.$out4;
while ($row_att = Database::fetch_assoc($res_att)) {
$atts[] = $row_att['user_id'];
}
$missing = array_diff($u,$atts);
foreach ($missing as $u1) {
$sqlu = "SELECT field_value FROM user_field_values where field_id = $uidf and user_id = $u1";
$resu = Database::query($sqlu);
$uid = Database::result($resu);
$params = array(
'item_id' => $uid,
'orig_id' => $sid,
'info' => substr($cal['date_time'],0,10),
'branch_id' => $sedes[$sede],
);
$r8 = MigrationCustom::transaction_34($params,$matches['web_service_calls']);
var_dump($r8);
}
}
}
//$a->update_users_results($u,$at_id);
} else {
//var_dump($att);
}
}
if ($session_id>=$max) { break; }
}
die('Finished processing '.$max."\n");

@ -0,0 +1,41 @@
<?php
require '../../main/inc/global.inc.php';
require '../../main/inc/lib/attendance.lib.php';
$a = new Attendance();
$sessions_list = SessionManager::get_sessions_list();
$min = 90000;
$max = 999999;
// Get sessions
foreach ($sessions_list as $session) {
if ($session['id'] < $min) { continue; }
echo "Session ".$session['id']."\n";
// Get users in session to build users list
$users = SessionManager::get_users_by_session($session['id']);
$u = array();
foreach ($users as $user) {
$u[] = $user['user_id'];
}
// Get courses list to get the right course (only one in each session)
$courses = SessionManager::get_course_list_by_session_id($session['id']);
if (count($courses)>0) {
foreach ($courses as $course) {
$course_id = $course['id'];
break;
}
echo "-- Course ".$course_id."\n";
// Get attendances sheets from course (only one in each course)
$att = $a->get_attendances_list($course_id,$session['id']);
if (count($att)>0) {
foreach ($att as $at) {
$at_id = $at['id'];
break; //get out after first result
}
echo "---- Attendance ".$at_id."\n";
$a->set_course_int_id($course_id);
$a->update_users_results($u,$at_id);
} else {
var_dump($att);
}
}
if ($session['id']>$max) { die('Finished processing '.$max."\n"); }
}

@ -28,6 +28,7 @@ if (empty($servers)) {
}
$data_list = array('users'=>array(),'courses'=>array(),'sessions'=>array());
$utc_datetime = api_get_utc_datetime();
$start = time();
echo "\n-- Starting at ".date('h:i:s')." local server time\n";

@ -623,9 +623,9 @@ class Migration {
foreach ($transaction_hardcoded as $transaction) {
$transaction['branch_id'] = 2;
if ($transaction['action'] < 31) {
/*if ($transaction['action'] < 31) {
continue;
}
}*/
self::add_transaction($transaction);
}
}
@ -683,7 +683,7 @@ class Migration {
//$extra_conditions = " AND branch_id = $branch_id ";
// Temporary patch to avoid attendances and gradebook transactions
$extra_conditions = " AND branch_id = $branch_id and action < 31";
$extra_conditions = " AND branch_id = $branch_id";
$sql = "SELECT * FROM $table WHERE status_id = $status_id $extra_conditions ORDER BY id ";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');

@ -438,6 +438,8 @@ class MigrationCustom {
//error_log('create_attendance');
$session_id = $data['session_id'];
$user_id = $data['user_id'];
$time = self::get_horario_value($session_id);
$fecha = $data['fecha']." $time:00";
if (!empty($session_id) && !empty($user_id)) {
$attendance = new Attendance();
@ -449,7 +451,7 @@ class MigrationCustom {
$course_list = SessionManager::get_course_list_by_session_id($session_id);
}
$attendance_id = null;
$attendance_sheet_id = null;
if (!empty($course_list)) {
//We know there's only one course by session. Take it.
@ -467,7 +469,7 @@ class MigrationCustom {
$attendance->set_course_int_id($course_info['real_id']);
$attendance->set_session_id($session_id);
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions']) {
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions'] && isset($data_list['sessions_attendances'][$course_info['real_id']][$session_id])) {
$list = $data_list['sessions_attendances'][$course_info['real_id']][$session_id];
foreach ($list as $at_id) {
$attendance_list[] = array('id' => $at_id);
@ -482,52 +484,58 @@ class MigrationCustom {
//$attendance->set_attendance_weight($_POST['attendance_weight']);
$link_to_gradebook = false;
//$attendance->category_id = $_POST['category_id'];
$attendance_id = $attendance->attendance_add($link_to_gradebook, self::default_admin_id);
$attendance_sheet_id = $attendance->attendance_add($link_to_gradebook, self::default_admin_id);
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions']) {
$data_list['sessions_attendances'][$course_info['real_id']][$session_id][] = $attendance_id;
$data_list['sessions_attendances'][$course_info['real_id']][$session_id][] = $attendance_sheet_id;
}
//error_log("Attendance added course code: {$course['code']} - session_id: $session_id");
//only 1 course per session
} else {
// Only one attendance sheet by course and session (at least during migration)
$attendance_data = current($attendance_list);
$attendance_id = $attendance_data['id'];
//error_log("Attendance found in attendance_id = $attendance_id - course code: {$course['code']} - session_id: $session_id");
$attendance_sheet_id = $attendance_data['id'];
//error_log("Attendance found in attendance_sheet_id = $attendance_sheet_id - course code: {$course['code']} - session_id: $session_id");
}
if ($attendance_id) {
// Now the attendance_sheet has been found or created, check the date
if ($attendance_sheet_id) {
//error_log('Processing attendance sheet '.$attendance_sheeet_id.' for session '.$session_id.', course '.$course_info['real_id'].', date '.$fecha);
//Attendance date exists?
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions']) {
$cal_info['id'] = $data_list['sessions_attendance_dates'][$attendance_id][$data['fecha']];
$cal_info = array();
$cal_id = null;
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions'] && $data_list['sessions_attendance_dates'][$attendance_sheet_id][$fecha]) {
$cal_info['id'] = $data_list['sessions_attendance_dates'][$attendance_sheet_id][$fecha];
} else {
$cal_info = $attendance->get_attendance_calendar_data_by_date($attendance_id, $data['fecha']);
$cal_info = $attendance->get_attendance_calendar_data_by_date($attendance_sheet_id, $fecha);
}
if ($cal_info && isset($cal_info['id'])) {
// Get (or create) the attendance date ID
if (isset($cal_info['id'])) {
$cal_id = $cal_info['id'];
} else {
//Creating the attendance date
$attendance->set_date_time($data['fecha']);
$cal_id = $attendance->attendance_calendar_add($attendance_id, true);
$attendance->set_date_time($fecha);
//Creating the attendance date and get ID
$cal_id = $attendance->attendance_calendar_add($attendance_sheet_id, true);
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions']) {
$data_list['sessions_attendance_dates'][$attendance_id][$data['fecha']] = $cal_id;
$data_list['sessions_attendance_dates'][$attendance_sheet_id][$fecha] = $cal_id;
}
//error_log("Creating attendance calendar $cal_id");
}
//Adding presence for the user (by default everybody is present)
$users_present = array($user_id => $data['status']);
if (is_array($data_list['create_attendance'])) {
$data_list['create_attendance'][] = array($cal_id, $user_id, $data['status'], $attendance_id, $course_info['real_id'], $data['fecha']);
$data_list['create_attendance'][] = array($cal_id, $user_id, $data['status'], $attendance_sheet_id, $course_info['real_id'], $fecha);
$limit = 100;
if (count($data_list['create_attendance']) == $limit) {
//error_log('Flushing attendances list because reached '.$limit);
//error_log('Flushing attendances list because reached '.$limit.": \n".print_r($data_list['create_attendance'],1));
$attendance->attendance_sheet_group_add($data_list['create_attendance'],false,true);
$data_list['create_attendance'] = array();
}
} else {
$attendance->attendance_sheet_add($cal_id, $users_present, $attendance_id, false, true);
$attendance->attendance_sheet_add($cal_id, $users_present, $attendance_sheet_id, false, true);
}
//error_log("Adding calendar to user: $user_id to calendar: $cal_id");
} else {
error_log('No attendance_id created');
// We should never get here
error_log('No attendance_sheet_id created');
}
} else {
error_log("Course not found for session: $session_id");
@ -625,10 +633,16 @@ class MigrationCustom {
if (!empty($course_list)) {
$course_data = current($course_list);
if (isset($course_data['code'])) {
//Get gradebook
$gradebook = array('id' => $data_list['session_course_gradebook'][$course_data['code']][$session_id]);
//$gradebook = new Gradebook();
//$gradebook = $gradebook->get_first(array('where' => array('course_code = ? AND session_id = ?' => array($course_data['code'], $session_id))));
//Get gradebook (if does not exist, create it)
$gradebook = null;
if (!empty($data_list['session_course_gradebook'][$course_data['code']][$session_id])) {
$gradebook = array('id' => $data_list['session_course_gradebook'][$course_data['code']][$session_id]);
} else {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$gradebook = array('id' => create_default_course_gradebook($course_data['code'], false, $session_id));
error_log('Gradebook not found. Creating one with ID '.$gradebook['id']);
$data_list['session_course_gradebook'][$course_data['code']][$session_id] = $gradebook['id'];
}
if (!empty($gradebook)) {
//Check if gradebook exists
$eval = 0;
@ -637,7 +651,7 @@ class MigrationCustom {
return null;
}
$eval = new Evaluation();
$evals_found = $eval->load(null, null, $course_data['code'], null, null, null, $data['gradebook_description']);
$evals_found = $eval->load(null, null, $course_data['code'], $gradebook['id'], null, null, $data['gradebook_description']);
if (empty($evals_found)) {
$eval->set_name($data['gradebook_description']);
@ -961,6 +975,7 @@ class MigrationCustom {
$uidIdPersona = $data['item_id'];
$uidIdPrograma = $data['orig_id'];
$uidIdProgramaDestination = $data['dest_id'];
$status = (!empty($data['info'])?$data['info']:null);
global $data_list;
$user_id = self::get_user_id_by_persona_id($uidIdPersona,$data_list);
@ -1037,7 +1052,20 @@ class MigrationCustom {
$session_id = self::get_session_id_by_programa_id($uidIdProgramaDestination, $data_list);
if (!empty($session_id)) {
$before = SessionManager::get_user_status_in_session($session_id, $user_id);
SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
if (isset($status) && $status == 1) {
$course_list = SessionManager::get_course_list_by_session_id($session_id);
if (!empty($course_list)) {
$course_data = current($course_list);
SessionManager::set_coach_to_course_session($user_id, $session_id, $course_data['code']);
} else {
return array(
'message' => 'Could not subscribe to course: no course in session '.$uidIdProgramaDestination,
'status_id' => self::TRANSACTION_STATUS_FAILED
);
}
} else {
SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
}
$message = 'Move empty to Session';
return self::check_if_user_is_subscribe_to_session($user_id, $session_id, $message, $before);
} else {
@ -1697,10 +1725,16 @@ class MigrationCustom {
if (!empty($course_list)) {
$course_data = current($course_list);
if (isset($course_data['code'])) {
//Look for gradebook and create it if it does not exist yet
$gradebook = new Gradebook();
$gradebook = $gradebook->get_first(array('where' => array('course_code = ? AND session_id = ?' => array($course_data['code'], $session_id))));
error_log("Looking gradebook in course code: {$course_data['code']} - session_id: $session_id");
if (count($gradebook)===0) {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$gradebook = array('id' => create_default_course_gradebook($course_data['code'], false, $session_id));
error_log('Gradebook not found. Creating one with ID '.$gradebook['id']);
$data_list['session_course_gradebook'][$course_data['code']][$session_id] = $gradebook['id'];
}
if (!empty($gradebook)) {
//Check if gradebook exists
$eval = new Evaluation();
@ -1805,9 +1839,22 @@ class MigrationCustom {
if (!empty($course_list)) {
$course_data = current($course_list);
if (isset($course_data['code'])) {
$gradebook = new Gradebook();
$gradebook = $gradebook->get_first(array('where' => array('course_code = ? AND session_id = ?' => array($course_data['code'], $session_id))));
error_log("Looking gradebook in course code: {$course_data['code']} - session_id: $session_id");
$gradebook = null;
if (!empty($data_list['session_course_gradebook'][$course_data['code']][$session_id])) {
$gradebook['id'] = $data_list['session_course_gradebook'][$course_data['code']][$session_id];
} else {
$gradebook = new Gradebook();
$gradebook = $gradebook->get_first(array('where' => array('course_code = ? AND session_id = ?' => array($course_data['code'], $session_id))));
error_log("Searching for gradebook in course code: {$course_data['code']} - session_id: $session_id");
if (count($gradebook)===0) {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$gradebook = array('id' => create_default_course_gradebook($course_data['code'], false, $session_id));
error_log('Gradebook not found. Creating one with ID '.$gradebook['id']);
$data_list['session_course_gradebook'][$course_data['code']][$session_id] = $gradebook['id'];
}
}
// At this point we tried 3 different ways of obtaining a
// gradebook id, so no chance to fail (hopefully)
if (!empty($gradebook)) {
//Check if gradebook exists
$eval = new Evaluation();
@ -1994,7 +2041,7 @@ class MigrationCustom {
$data = Migration::soap_call($web_service_details, 'asistenciaDetalles', array(
'uididpersona' => $original_data['item_id'],
'uididprograma'=> $original_data['orig_id'],
'sdtfecha' => $original_data['info'],
'uididfecha' => $original_data['info'],
'intIdSede' => $original_data['branch_id']
));
@ -2039,7 +2086,8 @@ class MigrationCustom {
'status_id' => self::TRANSACTION_STATUS_FAILED
);
}
// attendance are registered with date + time, so get time
// from session schedule
$time = self::get_horario_value($session_id);
$attendance_date .= " $time:00";
@ -2049,16 +2097,34 @@ class MigrationCustom {
$attendance->set_course_id($course_info['code']);
$attendance->set_course_int_id($course_info['real_id']);
$attendance->set_session_id($session_id);
$attendance_list = array();
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions'] && isset($data_list['sessions_attendances'][$course_info['real_id']][$session_id])) {
//error_log('Found reference to an existing sheet in data_list');
$list = $data_list['sessions_attendances'][$course_info['real_id']][$session_id];
foreach ($list as $at_id) {
$attendance_list[$at_id] = array('id' => $at_id);
//error_log('attendance sheet is '.$at_id);
}
} else {
$attendance_list = $attendance->get_attendances_list($course_info['real_id'], $session_id);
//error_log('Gotten attendance_sheet from table '.$attendance_list[0]['id']);
}
$attendance_list = $attendance->get_attendances_list($course_info['real_id'], $session_id);
if (empty($attendance_list)) {
if (count($attendance_list)==0) {
$d = array(
'session_id' => $session_id,
'user_id' => $user_id,
'fecha' => $attendance_date,
'status' => $attendance_user_status,
);
$attendance->set_name('Asistencia');
$attendance->set_description('');
$link_to_gradebook = false;
$attendance_id = $attendance->attendance_add($link_to_gradebook, self::default_admin_id);
if (is_array($data_list) && isset($data_list) && $data_list['boost_sessions']) {
$data_list['sessions_attendances'][$course_info['real_id']][$session_id][] = $attendance_sheet_id;
}
//error_log("Attendance created in attendance_id = $attendance_id - course code: {$course_info['code']} - session_id: $session_id - $attendance_date");
//self::create_attendance($d);
/*return array(
'entity' => 'attendance_sheet',
@ -2067,16 +2133,18 @@ class MigrationCustom {
'message' => "Attendance sheet added with id: $result",
'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL
);*/
// return array(
// 'message' => "Attendance not found for course code: {$course_info['code']} - session_id: $session_id",
// 'status_id' => self::TRANSACTION_STATUS_FAILED
// );
/*
return array(
'message' => "Attendance not found for course code: {$course_info['code']} - session_id: $session_id",
'status_id' => self::TRANSACTION_STATUS_FAILED
);
*/
//only 1 course per session
} else {
$attendance_data = current($attendance_list);
$attendance_id = $attendance_data['id'];
error_log("Attendance found in attendance_id = $attendance_id - course code: {$course_info['code']} - session_id: $session_id - $attendance_date");
//error_log("Attendance found in attendance_id = $attendance_id - course code: {$course_info['code']} - session_id: $session_id - $attendance_date");
}
$cal_info = $attendance->get_attendance_calendar_data_by_date($attendance_id, $attendance_date);
@ -2087,9 +2155,10 @@ class MigrationCustom {
//Creating the attendance date
$attendance->set_date_time($attendance_date);
error_log('Setting date '.$attendance_date);
$cal_id = $attendance->attendance_calendar_add($attendance_id, true);
error_log("Creating a new calendar item $cal_id");
//error_log("Creating a new calendar item $cal_id");
/*return array(
'message' => "Attendance calendar does not exist for date: $attendance_date in attendance_id = $attendance_id - course code: {$course_info['code']} - session_id: $session_id",
@ -2147,7 +2216,7 @@ class MigrationCustom {
$data = Migration::soap_call($web_service_details, 'asistenciaDetalles', array(
'uididpersona' => $original_data['item_id'],
'uididprograma'=> $original_data['orig_id'],
'sdtfecha' => $original_data['info'],
'uididfecha' => $original_data['info'],
'intIdSede' => $original_data['branch_id']
));
@ -2986,9 +3055,9 @@ class MigrationCustom {
if (isset($horario_info) && isset($horario_info[0])) {
$horario = $horario_info[0]['option_display_text'];
$horario_array = explode(' ', $horario);
if (isset($horario_array[0])) {
$time = $horario_array[0];
//Schedule format is "(01) 07:00 09:00" in this case. Adapt to your case
if (isset($horario_array[1])) {
$time = $horario_array[1];
}
}
return $time;

@ -10,6 +10,7 @@
if (PHP_SAPI != 'cli') {
exit;
}
$num_trans = 500; //how many transactions to process during each execution
// Check for pidfile. Normally, no concurrent write is possible as transactions
// should be started at about 120 seconds intervals.
$pidfile = __DIR__.'/chamilo.transaction.pid';
@ -48,13 +49,18 @@ $branch_id = 0;
// We need $branch_id defined before calling db_matches.php
// The only thing we need from db_matches is the definition of the web service
require_once 'db_matches.php';
/**
* Process
*/
$migration = new Migration();
$migration->set_web_service_connection_info($matches);
require $migration->web_service_connection_info['filename'];
$mig = new $migration->web_service_connection_info['class'];
error_log('Building in-memory data_list for speed-up '.time());
$data_list = array('boost_users'=>true, 'boost_courses'=>true, 'boost_sessions'=>true);
/**
* Build an array of in-memory database data to reduce time spent querying
*/
if (count($data_list['users'])<1) {
MigrationCustom::fill_data_list($data_list);
}
@ -62,42 +68,29 @@ error_log('Built in-memory data_list for speed-up '.time());
// Counter for transactions found and dealt with
$count_transactions = 0;
// Check all branches one by one
/**
* Check each branch for transactions to execute (and execute them)
*/
$branches = $migration->get_branches();
foreach ($branches as $id => $branch) {
$response = '';
$branch_id = $branch['branch_id'];
if ($mode == 'process') {
//Load transactions saved before
$params = array('branch_id' => $branch_id, 'number_of_transactions' => '500');
$params = array('branch_id' => $branch_id, 'number_of_transactions' => $num_trans);
$migration->get_transactions_from_webservice($params);
$count_transactions += $migration->execute_transactions($params);
// $trans_id = $migration->get_latest_transaction_id_by_branch($branch_id);
// error_log("Last transaction was $trans_id for branch $branch_id");
// $params = array(
// 'ultimo' => $trans_id,
// 'cantidad' => 100,
// 'intIdSede' => $branch_id,
// );
// $result = $mig->process_transactions($params,$migration->web_service_connection_info);
} else {
//if mode==fix
error_log('Fixing transactions');
$params = array('branch_id' => $branch_id, 'number_of_transactions' => '500');
$params = array('branch_id' => $branch_id, 'number_of_transactions' => $num_trans);
$migration->execute_transactions($params);
}
//$result = $migration->load_transaction_by_third_party_id($trans_id, $branch_id);
//$response .= $result['message'];
//if (isset($result['raw_reponse'])) {
// $response .= $result['raw_reponse'];
//}
//if (!empty($response)) {
// error_log($response);
//}
}
// Free the PID file
/**
* Free the PID file used as semaphore
*/
if (is_file($pidfile)) {
$opid = trim(file_get_contents($pidfile));
if (intval($opid) == intval($pid)) {

@ -0,0 +1,57 @@
<?php
ini_set('memory_limit',0);
ini_set('max_execution_time',0);
ini_set('upload_max_filesize',0);
ini_set('post_max_size',0);
require_once dirname(__FILE__).'../../main/inc/global.inc.php';
?>
<html>
<body>
<p>
<form method="post" action="" enctype="multipart/form-data">
<table>
<tr><td>Video to convert:</td><td><input type="file" name="video"/></td></tr>
<tr><td>Desired CODEC:</td>
<td>
<select name="codec">
<option value="webm" selected>WebM</option>
<option value="ogv">OGV</option>
</select>
</td>
</tr>
<tr><td colspan="2"><input type="submit" name="Convert" value="Convert"></tr>
</table>
</form>
</p>
<p>
<?php
if (!empty($_FILES['video'])) {
error_log($_FILES['video']['name']);
$orig = dirname(__FILE__).'/upload/'.md5(uniqid(rand(),true)).'-'.$_FILES['video']['name'];
$dest = dirname(__FILE__).'/upload/'.md5(uniqid(rand(),true)).'-'.substr($_FILES['video']['name'],0,-3).(($_POST['codec']!='ogv')?'webm':'ogv');
error_log($dest);
$res = @move_uploaded_file($_FILES['video']['tmp_name'],$orig);
if ($res === false) { error_log("Error moving video: ".$php_error_msg); }
error_log('Calling '.'ffmpeg -i '.$orig.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -v quiet -s 1080x720 '.$dest);
$ffmpeg = @exec('ffmpeg -i '.$orig.' -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -v quiet -s 1080x720 '.$dest);
if ($ffmpeg === false) { error_log('no'); }
}
?>
</p>
<p>
<?php
echo "Files on disk:<br />";
$list = scandir(dirname(__FILE__).'/upload');
if (is_array($list)) {
foreach ($list as $file) {
if (substr($file,0,1) == '.') {
continue;
} else {
echo '<a href="'.api_get_path(WEB_PATH).'video/upload/'.$file.'">'.$file.'</a><br />'."\n";
}
}
}
?>
</p>
</body>
</html>
Loading…
Cancel
Save