Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent deec802c04
commit dbb55f9048
  1. 392
      main/admin/ldap_import_students.php
  2. 244
      main/admin/user_move_stats.php
  3. 56
      main/inc/lib/attendance.lib.php
  4. 8
      main/inc/lib/exercise.lib.php

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Script to import students from LDAP * Script to import students from LDAP
* @package chamilo.admin * @package chamilo.admin
@ -21,25 +22,25 @@ $tool_name = get_lang('LDAPImport');
// setting breadcrumbs // setting breadcrumbs
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript"> $htmlHeadXtra[] = '<script>
var buttoncheck = 1; var buttoncheck = 1;
function checkAll() { function checkAll() {
//var boxes = document.form.elements[\'checkboxes[]\']; //var boxes = document.form.elements[\'checkboxes[]\'];
var boxes = document.getElementsByName(\'checkboxes[]\'); var boxes = document.getElementsByName(\'checkboxes[]\');
if (buttoncheck == 0) { if (buttoncheck == 0) {
for (i = 0; i < boxes.length; i++) { for (i = 0; i < boxes.length; i++) {
boxes[i].checked = true; boxes[i].checked = true;
} }
buttoncheck = 1; buttoncheck = 1;
return "'.get_lang('None').'"; return "'.get_lang('None').'";
} }
else { else {
for (i = 0; i < boxes.length; i++) { for (i = 0; i < boxes.length; i++) {
boxes[i].checked = false; boxes[i].checked = false;
} }
buttoncheck = 0; buttoncheck = 0;
return " '.get_lang('All').' "; return " '.get_lang('All').' ";
} }
} }
</script>'; </script>';
@ -47,276 +48,107 @@ $annee = $_GET['annee'];
$composante = $_GET['composante']; $composante = $_GET['composante'];
$etape = $_GET['etape']; $etape = $_GET['etape'];
$course = $_POST['course']; $course = $_POST['course'];
// form1 annee = 0; composante= 0 etape = 0 // form1 annee = 0; composante= 0 etape = 0
//if ($annee == "" && $composante == "" && $etape == "") { //if ($annee == "" && $composante == "" && $etape == "") {
if (empty($annee) && empty($course)) if (empty($annee) && empty($course)) {
{ Display::display_header($tool_name);
Display::display_header($tool_name); echo '<div style="align:center">';
echo '<div style="align:center">'; Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU'));
Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')); echo get_lang('LDAPSelectFilterOnUsersOU');
echo get_lang('LDAPSelectFilterOnUsersOU'); //echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />';
//echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />'; ///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />';
///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />';
echo '<form method="get" action="'.api_get_self().'"><br />';
echo '<form method="get" action="'.api_get_self().'"><br />'; echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> '; echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />';
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />'; echo '<input type="submit" value="'.get_lang('Submit').'">';
echo '<input type="submit" value="'.get_lang('Submit').'">'; echo '</form>';
echo '</form>'; echo '</div>';
echo '</div>'; } elseif (!empty($annee) && empty($course)) {
Display::display_header($tool_name);
} echo '<div style="align:center">';
/* echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />';
elseif ($annee <> "" && $composante == "" && $etape == "") // form 2 annee != 0; composante= 0 etape = 0 echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
{ echo '<select name="course">';
Display::display_header($tool_name); $courses = CourseManager::get_courses_list();
foreach ($courses as $row) {
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
ldap_set_version($ds); }
echo '</select>';
if ($ds) { echo '<input type="submit" value="'.get_lang('Submit').'">';
$r = false; echo '</form>';
$res = ldap_handle_bind($ds, $r); echo '</div>';
} elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed'])) {
//$sr = @ ldap_search($ds, "o=groups,$ldap_basedn", "(&(description=etape*)(cn=*$annee))", array ('cn')); // form4 annee != 0; composante != 0 etape != 0
//$sr = @ ldap_search($ds, "ou=$annee, ou=diploma, o=paris1, $ldap_basedn", "ou=02*", array ('description')); //elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') {
//$sr = @ ldap_search($ds, "ou=structures, o=paris1, $ldap_basedn", "businessCategory=pedagogy", array ('ou','description')); Display::display_header($tool_name);
$sr = ldap_search($ds, $ldap_basedn, "(ou=*$annee)", array ('ou','description')); echo '<div style="align: center;">';
// "ou=2006,ou=diploma,o=Paris1,dc=univ-paris1,dc=fr echo '<br />';
echo '<br />';
$info = ldap_get_entries($ds, $sr); echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
$composante = array(); //echo "Connection ...";
for($i = 0; $i < $info['count']; $i ++) $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
{ ldap_set_version($ds);
//presupose LDAP server is UTF-8
$composante[$info[$i]['ou'][0]] = api_utf8_decode($info[$i]['description'][0], api_get_system_encoding()); if ($ds) {
} $r = false;
$oucompotab3=$composante; $res = ldap_handle_bind($ds, $r);
echo '<div style="align: center">'; //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
echo '<br />'; //echo "(ou=*$annee,ou=$composante)";
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectComponent')).' '.get_lang('SelectComponent').'</h3>'; $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
echo '<form method="get" action="'.api_get_self().'">';
echo '<b>'.get_lang('RegistrationYear').'</b> : '; $info = ldap_get_entries($ds, $sr);
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee.'">';
echo '<b>'.get_lang('Component').' : </b> '; for ($key = 0; $key < $info["count"]; $key++) {
echo '<select name="composante" size="1">'; $nom_form[] = $info[$key]["sn"][0];
while (list ($key, $val) = each($oucompotab3)) { $prenom_form[] = $info[$key]["givenname"][0];
echo '<option value="'.$key.'">'.$oucompotab3[$key].'</option>'; $email_form[] = $info[$key]["mail"][0];
} // Get uid from dn
echo '</select>'; //$dn_array=ldap_explode_dn($info[$key]["dn"],1);
echo '<br />'; //$username_form[] = $dn_array[0]; // uid is first key
echo '<br />'; $username_form[] = $info[$key]['uid'][0];
echo '<input type="submit" name="valider" value="'.get_lang('Submit').'">'; $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
echo '</form>'; //$val = ldap_get_values_len($ds, $entry, "userPassword");
ldap_close($ds); //$password_form[] = $val[0];
$password_form[] = $info[$key]['userPassword'][0];
} }
echo '<br />'; ldap_unbind($ds);
echo '<br />'; asort($nom_form);
echo '<br />'; reset($nom_form);
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
echo '<br />'; $statut = 5;
echo '</div>'; include 'ldap_form_add_users_group.php';
} } else {
elseif ($annee <> "" && $composante <> "" && $etape == "") // form3 :annee!=0composante=0etape=0 echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
{ }
echo '<br /><br />';
Display::display_header($tool_name);
echo '<div style="align: center">';
echo '<h3>'.Display::return_icon('group.gif', get_lang('SearchResults')).' '.get_lang('SearchResults').'</h3>';
$ds = ldap_connect($ldap_host, $ldap_port);
ldap_set_version($ds);
if ($ds) {
$r = false;
$res = ldap_handle_bind($ds, $r);
// $sr = @ ldap_search($ds, "ou=groups, $LDAPbasedn", "(&(cn=*$annee*)(cn=*$composante*))");
$sr = @ ldap_search($ds, $ldap_basedn, "ou=$composante", array ('ou','description'));
//echo "Le nombre de resultats est : ".ldap_count_entries($ds,$sr)."<p>";
$info = ldap_get_entries($ds, $sr);
for ($i = 0; $i <= $info['count']; $i ++) {
$description = $info[$i]['description'];
$ouetapetab[$i] = $description[0];
$description2 = $info[$i]['ou'];
$ouetapetab2[$i] = $description2[0];
}
asort($ouetapetab);
reset($ouetapetab);
echo '<form method="get" action="'.api_get_self().'">';
echo '<b>'.get_lang('RegistrationYear').':</b><input type="text" name="annee" size="4" maxlength="30" value="'.$annee.'">';
echo '<br /><br />';
echo '<b>'.get_lang('Component').' :</b><input type="text" name="composante" size="4" maxlength="30" value="'.$composante.'">';
echo '<br />';
echo '<h4>'.get_lang('SelectStepAcademicYear').'</h4>';
echo '<br />';
echo '<b>'.get_lang('Step').': </b>';
echo '<select name="etape" size="1">';
$tempcomp = "";
while (list ($key, $val) = each($ouetapetab)) {
if ($ouetapetab[$key] != $tempcomp) {
$etape = $ouetapetab2[$key];
$tempcomp = '"'.$ouetapetab[$key].'"';
$tempcomp = api_utf8_decode($tempcomp, api_get_system_encoding());
$annee = str_word_count($etape, 1);
echo '<option value="'.$etape.'">'.$tempcomp.'</option>';
}
}
echo '</select>';
echo '<input type="hidden" name="displayname" value="'.$displayname.'">';
echo '<br />';
echo '<input type="submit" name="envoi" value="'.get_lang('Submit').'">';
echo '</form>';
ldap_close($ds);
} else {
// echo "<h4>Unable to connect to LDAP server</h4>";
}
echo '<br />';
echo '<br />';
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
echo '</div>';
}
*/
elseif (!empty($annee) && empty($course))
{
Display::display_header($tool_name);
echo '<div style="align:center">';
echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />';
echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
echo '<select name="course">';
$courses = CourseManager::get_courses_list();
foreach ($courses as $row)
{
echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
}
echo '</select>';
echo '<input type="submit" value="'.get_lang('Submit').'">';
echo '</form>';
echo '</div>';
}
// form4 annee != 0; composante != 0 etape != 0
//elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') {
elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed']))
{
Display::display_header($tool_name);
echo '<div style="align: center;">';
echo '<br />';
echo '<br />';
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
//echo "Connection ...";
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
ldap_set_version($ds);
if ($ds) {
$r = false;
$res = ldap_handle_bind($ds, $r);
//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
//echo "(ou=*$annee,ou=$composante)";
$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
$info = ldap_get_entries($ds, $sr);
for ($key = 0; $key < $info["count"]; $key++) {
$nom_form[] = $info[$key]["sn"][0];
$prenom_form[] = $info[$key]["givenname"][0];
$email_form[] = $info[$key]["mail"][0];
// Get uid from dn
//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
//$username_form[] = $dn_array[0]; // uid is first key
$username_form[] = $info[$key]['uid'][0];
$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
//$val = ldap_get_values_len($ds, $entry, "userPassword");
//$password_form[] = $val[0];
$password_form[] = $info[$key]['userPassword'][0];
}
ldap_unbind($ds);
/*-----------------------------------------------*/
asort($nom_form);
reset($nom_form);
$statut = 5;
include ('ldap_form_add_users_group.php');
} else {
echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
}
echo '<br /><br />';
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
echo '<br /><br />'; echo '<br /><br />';
echo '</div>'; echo '</div>';
} elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) {
} $id = $_POST['username_form'];
elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) $UserList = array();
{ $userid_match_login = array();
$id = $_POST['username_form']; foreach ($id as $form_index => $user_id) {
$UserList = array(); if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) {
$userid_match_login = array(); $tmp = ldap_add_user($user_id);
foreach ($id as $form_index=>$user_id) $UserList[] = $tmp;
{ $userid_match_login[$tmp] = $user_id;
if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) }
{ }
$tmp = ldap_add_user($user_id); if (!empty($_POST['course'])) {
$UserList[] = $tmp; foreach ($UserList as $user_id) {
$userid_match_login[$tmp] = $user_id; CourseManager::add_user_to_course($user_id, $_POST['course']);
} }
} header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
if (!empty($_POST['course'])) } else {
{ $message = get_lang('NoUserAdded');
foreach ($UserList as $user_id) Display::addFlash(Display::return_message($message, 'normal', false));
{
CourseManager::add_user_to_course($user_id, $_POST['course']);
}
header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
}
/*
else
{
Display :: display_header($tool_name);
if(count($userid_match_login)>0)
{
$message=get_lang('LDAPUsersAddedOrUpdated').':<br />';
foreach($userid_match_login as $user_id => $login)
{
$message .= '- '.$login.'<br />';
}
}
else
{
$message=get_lang('NoUserAdded');
}
Display::addFlash(Display::return_message($message, 'normal', false));
}
*/
else
{
$message = get_lang('NoUserAdded');
Display::addFlash(Display::return_message($message, 'normal', false));
Display::display_header($tool_name); Display::display_header($tool_name);
} }
echo '<br /><br />'; echo '<br /><br />';
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
echo '<br /><br />'; echo '<br /><br />';
} }
Display::display_footer(); Display::display_footer();
?>

@ -15,9 +15,9 @@ api_protect_admin_script();
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$debug = 0; $debug = 0;
function compare_data($result_message) { function compare_data($result_message)
foreach ($result_message as $table=>$data) { {
foreach ($result_message as $table => $data) {
$title = $table; $title = $table;
if ($table == 'TRACK_E_EXERCISES') { if ($table == 'TRACK_E_EXERCISES') {
$title = get_lang('Exercises'); $title = get_lang('Exercises');
@ -30,7 +30,6 @@ function compare_data($result_message) {
if (is_array($data)) { if (is_array($data)) {
foreach ($data as $id => $item) { foreach ($data as $id => $item) {
if ($table == 'TRACK_E_EXERCISES' || $table == 'TRACK_E_EXERCISES_IN_LP') { if ($table == 'TRACK_E_EXERCISES' || $table == 'TRACK_E_EXERCISES_IN_LP') {
echo "<br /><h3>".get_lang('Attempt')." #$id</h3>"; echo "<br /><h3>".get_lang('Attempt')." #$id</h3>";
echo '<h3>'; echo '<h3>';
@ -42,8 +41,12 @@ function compare_data($result_message) {
echo '</h3>'; echo '</h3>';
} }
//Process data //Process data
$array = array('exe_date' =>get_lang('Date'), 'exe_result' =>get_lang('Score'), 'exe_weighting'=>get_lang('Weighting')); $array = array(
foreach ($item as $key=> $value) { 'exe_date' => get_lang('Date'),
'exe_result' => get_lang('Score'),
'exe_weighting' => get_lang('Weighting')
);
foreach ($item as $key => $value) {
if (in_array($key, array_keys($array))) { if (in_array($key, array_keys($array))) {
$key = $array[$key]; $key = $array[$key];
echo "$key = $value <br />"; echo "$key = $value <br />";
@ -52,7 +55,7 @@ function compare_data($result_message) {
} else { } else {
echo "<br /><h3>".get_lang('Id')." #$id</h3>"; echo "<br /><h3>".get_lang('Id')." #$id</h3>";
//process data //process data
foreach ($item as $key=> $value) { foreach ($item as $key => $value) {
echo "$key = $value <br />"; echo "$key = $value <br />";
} }
} }
@ -64,16 +67,18 @@ function compare_data($result_message) {
} }
if (isset($_REQUEST['load_ajax'])) { if (isset($_REQUEST['load_ajax'])) {
//Checking the variable $_SESSION['combination'] that has all the information of the selected course (instead of using a lots of hidden variables ... ) //Checking the variable $_SESSION['combination'] that has all the
// information of the selected course (instead of using a lots of
// hidden variables ... )
if (isset($_SESSION['combination']) && !empty($_SESSION['combination'])) { if (isset($_SESSION['combination']) && !empty($_SESSION['combination'])) {
$combinations = $_SESSION['combination']; $combinations = $_SESSION['combination'];
$combination_result = $combinations[$_REQUEST['unique_id']]; $combination_result = $combinations[$_REQUEST['unique_id']];
if (empty($combination_result)) { if (empty($combination_result)) {
echo get_lang('ThereWasAnError'); echo get_lang('ThereWasAnError');
} else { } else {
$origin_course_code = $combination_result['course_code']; $origin_course_code = $combination_result['course_code'];
$origin_session_id = intval($combination_result['session_id']); $origin_session_id = intval($combination_result['session_id']);
$new_session_id = intval($_REQUEST['session_id']); $new_session_id = intval($_REQUEST['session_id']);
$session = $em->find('ChamiloCoreBundle:Session', $new_session_id); $session = $em->find('ChamiloCoreBundle:Session', $new_session_id);
//if (!isset($_REQUEST['view_stat'])) { //if (!isset($_REQUEST['view_stat'])) {
@ -93,7 +98,7 @@ if (isset($_REQUEST['load_ajax'])) {
} }
} }
$result_message = array(); $result_message = array();
$result_message_compare = array(); $result_message_compare = array();
$update_database = true; $update_database = true;
@ -103,29 +108,34 @@ if (isset($_REQUEST['load_ajax'])) {
//Check if the same course exist in the session destination //Check if the same course exist in the session destination
if ($course_founded) { if ($course_founded) {
//Check if the user is registered in the session otherwise we will add it //Check if the user is registered in the session otherwise we will add it
$result = SessionManager::get_users_by_session($new_session_id); $result = SessionManager::get_users_by_session($new_session_id);
if (empty($result) || !in_array($user_id, array_keys($result))) { if (empty($result) || !in_array($user_id, array_keys($result))) {
if ($debug) echo 'User added to the session'; if ($debug) {
echo 'User added to the session';
}
//Registering user to the new session //Registering user to the new session
SessionManager::subscribe_users_to_session($new_session_id, array($user_id), false); SessionManager::subscribe_users_to_session(
$new_session_id,
array($user_id),
false
);
} }
//Begin with the import process //Begin with the import process
$course_info = api_get_course_info($origin_course_code); $course_info = api_get_course_info($origin_course_code);
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
$TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_E_COURSE_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $TBL_TRACK_E_COURSE_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$TBL_TRACK_E_LAST_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); $TBL_TRACK_E_LAST_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
$TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK); $TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK);
$TBL_STUDENT_PUBLICATION = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $TBL_STUDENT_PUBLICATION = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE); $TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE);
$TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST); $TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST);
@ -142,8 +152,8 @@ if (isset($_REQUEST['load_ajax'])) {
$list[$row['exe_id']] = $row; $list[$row['exe_id']] = $row;
} }
if (!empty($list)) if (!empty($list)) {
foreach ($list as $exe_id =>$data) { foreach ($list as $exe_id => $data) {
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id"; $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id";
$res = Database::query($sql); $res = Database::query($sql);
@ -156,23 +166,27 @@ if (isset($_REQUEST['load_ajax'])) {
} }
} }
} }
}
//DESTINY COURSE // DESTINY COURSE
if (!$update_database) { if (!$update_database) {
$sql = "SELECT * FROM $TABLETRACK_EXERCICES $sql = "SELECT * FROM $TABLETRACK_EXERCICES
WHERE c_id = $course_id AND session_id = $new_session_id AND exe_user_id = $user_id "; WHERE
c_id = $course_id AND
session_id = $new_session_id AND
exe_user_id = $user_id ";
$res = Database::query($sql); $res = Database::query($sql);
$list = array(); $list = array();
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list[$row['exe_id']] = $row; $list[$row['exe_id']] = $row;
} }
if (!empty($list)) if (!empty($list)) {
foreach ($list as $exe_id =>$data) { foreach ($list as $exe_id => $data) {
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id"; $sql = "UPDATE $TABLETRACK_EXERCICES
SET session_id = '$new_session_id'
WHERE exe_id = $exe_id";
$res = Database::query($sql); $res = Database::query($sql);
$result_message[$TABLETRACK_EXERCICES]++; $result_message[$TABLETRACK_EXERCICES]++;
} else { } else {
@ -183,6 +197,7 @@ if (isset($_REQUEST['load_ajax'])) {
} }
} }
} }
}
} }
//2.track_e_attempt, track_e_attempt_recording, track_e_downloads //2.track_e_attempt, track_e_attempt_recording, track_e_downloads
@ -197,10 +212,12 @@ if (isset($_REQUEST['load_ajax'])) {
$list[$row['course_access_id']] = $row; $list[$row['course_access_id']] = $row;
} }
if (!empty($list)) if (!empty($list)) {
foreach ($list as $id => $data) { foreach ($list as $id => $data) {
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_TRACK_E_COURSE_ACCESS SET session_id = $new_session_id WHERE course_access_id = $id"; $sql = "UPDATE $TBL_TRACK_E_COURSE_ACCESS
SET session_id = $new_session_id
WHERE course_access_id = $id";
if ($debug) { if ($debug) {
echo $sql; echo $sql;
} }
@ -208,8 +225,9 @@ if (isset($_REQUEST['load_ajax'])) {
$result_message[$TBL_TRACK_E_COURSE_ACCESS]++; $result_message[$TBL_TRACK_E_COURSE_ACCESS]++;
} }
} }
//4. track_e_lastaccess }
//4. track_e_lastaccess
$sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS $sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS
WHERE c_id = $course_id WHERE c_id = $course_id
AND access_session_id = $origin_session_id AND access_session_id = $origin_session_id
@ -219,20 +237,24 @@ if (isset($_REQUEST['load_ajax'])) {
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list[] = $row['access_id']; $list[] = $row['access_id'];
} }
if (!empty($list)) if (!empty($list)) {
foreach ($list as $id) { foreach ($list as $id) {
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_TRACK_E_LAST_ACCESS SET access_session_id = $new_session_id WHERE access_id = $id"; $sql = "UPDATE $TBL_TRACK_E_LAST_ACCESS
if ($debug) echo $sql; SET access_session_id = $new_session_id
WHERE access_id = $id";
if ($debug) {
echo $sql;
}
$res = Database::query($sql); $res = Database::query($sql);
//if ($debug) var_dump($res); //if ($debug) var_dump($res);
$result_message[$TBL_TRACK_E_LAST_ACCESS]++; $result_message[$TBL_TRACK_E_LAST_ACCESS]++;
} }
} }
}
//5. lp_item_view //5. lp_item_view
//CHECK ORIGIN //CHECK ORIGIN
$sql = "SELECT * FROM $TBL_LP_VIEW $sql = "SELECT * FROM $TBL_LP_VIEW
WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id "; WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id ";
$res = Database::query($sql); $res = Database::query($sql);
@ -249,22 +271,41 @@ if (isset($_REQUEST['load_ajax'])) {
} }
} }
if (!empty($list)) if (!empty($list)) {
foreach ($list as $id=>$data) { foreach ($list as $id => $data) {
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_LP_VIEW SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id "; $sql = "UPDATE $TBL_LP_VIEW
if ($debug) var_dump($sql); SET session_id = $new_session_id
WHERE c_id = $course_id AND id = $id ";
if ($debug) {
var_dump($sql);
}
$res = Database::query($sql); $res = Database::query($sql);
if ($debug) var_dump($res); if ($debug) {
var_dump($res);
}
$result_message[$TBL_LP_VIEW]++; $result_message[$TBL_LP_VIEW]++;
} else { } else {
//Getting all information of that lp_item_id //Getting all information of that lp_item_id
$score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $origin_session_id); $score = Tracking::get_avg_student_score(
$progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $origin_session_id); $user_id,
$result_message['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); $origin_course_code,
array($data['lp_id']),
$origin_session_id
);
$progress = Tracking::get_avg_student_progress(
$user_id,
$origin_course_code,
array($data['lp_id']),
$origin_session_id
);
$result_message['LP_VIEW'][$data['lp_id']] = array(
'score' => $score,
'progress' => $progress
);
} }
} }
}
//CHECk DESTINY //CHECk DESTINY
if (!$update_database) { if (!$update_database) {
@ -282,20 +323,33 @@ if (isset($_REQUEST['load_ajax'])) {
$list[$row['id']] = $row; $list[$row['id']] = $row;
} }
} }
if (!empty($list)) if (!empty($list)) {
foreach ($list as $id=>$data) { foreach ($list as $id => $data) {
//Getting all information of that lp_item_id //Getting all information of that lp_item_id
$score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); $score = Tracking::get_avg_student_score(
$progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); $user_id,
$result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); $origin_course_code,
array($data['lp_id']),
$new_session_id
);
$progress = Tracking::get_avg_student_progress(
$user_id,
$origin_course_code,
array($data['lp_id']),
$new_session_id
);
$result_message_compare['LP_VIEW'][$data['lp_id']] = array(
'score' => $score,
'progress' => $progress
);
} }
}
} }
//6. Agenda //6. Agenda
//calendar_event_attachment no problems no session_id //calendar_event_attachment no problems no session_id
$sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'calendar_event' AND insert_user_id = $user_id AND c_id = $course_id "; $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY
WHERE tool = 'calendar_event' AND insert_user_id = $user_id AND c_id = $course_id ";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$id = $row['ref']; $id = $row['ref'];
@ -309,12 +363,9 @@ if (isset($_REQUEST['load_ajax'])) {
} }
//7. Forum ?? So much problems when trying to import data //7. Forum ?? So much problems when trying to import data
//8. Student publication - Works //8. Student publication - Works
$sql = "SELECT ref FROM $TBL_ITEM_PROPERTY
//echo '<h1>Student publication</h1>'; WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id";
$sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id";
if ($debug) echo $sql; if ($debug) echo $sql;
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
@ -327,18 +378,23 @@ if (isset($_REQUEST['load_ajax'])) {
if ($debug) var_dump($data); if ($debug) var_dump($data);
$parent_id = $data['parent_id']; $parent_id = $data['parent_id'];
if (isset($data['parent_id']) && !empty($data['parent_id'])) { if (isset($data['parent_id']) && !empty($data['parent_id'])) {
$sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $parent_id AND c_id = $course_id"; $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION
$select_res = Database::query($sql); WHERE id = $parent_id AND c_id = $course_id";
$parent_data = Database::fetch_array($select_res, 'ASSOC'); $select_res = Database::query($sql);
if ($debug) var_dump($parent_data); $parent_data = Database::fetch_array(
$select_res,
'ASSOC'
);
if ($debug) {
var_dump($parent_data);
}
$sys_course_path = api_get_path(SYS_COURSE_PATH); $sys_course_path = api_get_path(SYS_COURSE_PATH);
$course_dir = $sys_course_path.$course_info['path']; $course_dir = $sys_course_path.$course_info['path'];
$base_work_dir = $course_dir.'/work'; $base_work_dir = $course_dir.'/work';
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
//Creating the parent folder in the session if does not exists already // Creating the parent folder in the session if does not exists already
//@todo ugly fix //@todo ugly fix
$search_this = "folder_moved_from_session_id_$origin_session_id"; $search_this = "folder_moved_from_session_id_$origin_session_id";
$search_this2 = $parent_data['url']; $search_this2 = $parent_data['url'];
@ -354,9 +410,7 @@ if (isset($_REQUEST['load_ajax'])) {
$created_dir = $new_result['url']; $created_dir = $new_result['url'];
$new_parent_id = $new_result['id']; $new_parent_id = $new_result['id'];
} else { } else {
if ($update_database) { if ($update_database) {
$dir_name = substr($parent_data['url'], 1); $dir_name = substr($parent_data['url'], 1);
$created_dir = create_unexisting_work_directory($base_work_dir, $dir_name); $created_dir = create_unexisting_work_directory($base_work_dir, $dir_name);
$created_dir = '/'.$created_dir; $created_dir = '/'.$created_dir;
@ -411,8 +465,6 @@ if (isset($_REQUEST['load_ajax'])) {
WHERE id = ".$new_parent_id; WHERE id = ".$new_parent_id;
if ($debug) echo $sql_update; if ($debug) echo $sql_update;
$rest_update = Database::query($sql_update); $rest_update = Database::query($sql_update);
if ($debug) var_dump($sql_update); if ($debug) var_dump($sql_update);
$result_message[$TBL_STUDENT_PUBLICATION_ASSIGNMENT]++; $result_message[$TBL_STUDENT_PUBLICATION_ASSIGNMENT]++;
} }
@ -445,8 +497,8 @@ if (isset($_REQUEST['load_ajax'])) {
api_item_property_update($course_info, 'work', $id, 'DocumentAdded', $user_id); api_item_property_update($course_info, 'work', $id, 'DocumentAdded', $user_id);
$result_message[$TBL_STUDENT_PUBLICATION]++; $result_message[$TBL_STUDENT_PUBLICATION]++;
$full_file_name = $course_dir.'/'.$doc_url; $full_file_name = $course_dir.'/'.$doc_url;
$new_file = $course_dir.'/'.$new_url; $new_file = $course_dir.'/'.$new_url;
if (file_exists($full_file_name)) { if (file_exists($full_file_name)) {
//deleting old assignment //deleting old assignment
@ -461,15 +513,13 @@ if (isset($_REQUEST['load_ajax'])) {
} }
} }
} }
} }
} }
//9. Survey Pending //9. Survey Pending
//10. Dropbox - not neccesary to move categories (no presence of session_id) //10. Dropbox - not neccesary to move categories (no presence of session_id)
$sql = "SELECT id FROM $TBL_DROPBOX_FILE
$sql = "SELECT id FROM $TBL_DROPBOX_FILE WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id"; WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id";
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
@ -499,7 +549,9 @@ if (isset($_REQUEST['load_ajax'])) {
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$id = $row['notebook_id']; $id = $row['notebook_id'];
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_NOTEBOOK SET session_id = $new_session_id WHERE c_id = $course_id AND notebook_id = $id"; $sql = "UPDATE $TBL_NOTEBOOK
SET session_id = $new_session_id
WHERE c_id = $course_id AND notebook_id = $id";
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$res = Database::query($sql); $res = Database::query($sql);
if ($debug) var_dump($res); if ($debug) var_dump($res);
@ -509,7 +561,7 @@ if (isset($_REQUEST['load_ajax'])) {
if ($update_database) { if ($update_database) {
echo '<h2>'.get_lang('StatsMoved').'</h2>'; echo '<h2>'.get_lang('StatsMoved').'</h2>';
if (is_array($result_message)) if (is_array($result_message))
foreach ($result_message as $table=>$times) { foreach ($result_message as $table => $times) {
echo 'Table '.$table.' - '.$times.' records updated <br />'; echo 'Table '.$table.' - '.$times.' records updated <br />';
} }
} else { } else {
@ -547,8 +599,7 @@ if (isset($_REQUEST['load_ajax'])) {
} }
exit; exit;
} }
$htmlHeadXtra[] = '<script type="text/javascript"> $htmlHeadXtra[] = '<script>
function moveto (unique_id, user_id) { function moveto (unique_id, user_id) {
var session_id = document.getElementById(unique_id).options[document.getElementById(unique_id).selectedIndex].value; var session_id = document.getElementById(unique_id).options[document.getElementById(unique_id).selectedIndex].value;
$.ajax({ $.ajax({
@ -582,7 +633,8 @@ $htmlHeadXtra[] = '<script type="text/javascript">
</script>'; </script>';
function get_courses_list_by_user_id_based_in_exercises($user_id) { function get_courses_list_by_user_id_based_in_exercises($user_id)
{
$TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$user_id = intval($user_id); $user_id = intval($user_id);
$sql = "SELECT DISTINCT exe_user_id, c_id, session_id $sql = "SELECT DISTINCT exe_user_id, c_id, session_id
@ -598,7 +650,13 @@ function get_courses_list_by_user_id_based_in_exercises($user_id) {
return $course_list; return $course_list;
} }
Display::addFlash(Display::return_message(get_lang('CompareUserResultsBetweenCoursesAndCoursesInASession'), 'normal', false)); Display::addFlash(
Display::return_message(
get_lang('CompareUserResultsBetweenCoursesAndCoursesInASession'),
'normal',
false
)
);
Display::display_header(get_lang('MoveUserStats')); Display::display_header(get_lang('MoveUserStats'));
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM).'</a>'; echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM).'</a>';
@ -610,12 +668,11 @@ if (isset($_GET['page']) && !empty($_GET['page'])) {
$page = intval($_GET['page']); $page = intval($_GET['page']);
} }
$default = 20; $default = 20;
$count = UserManager::get_number_of_users(); $count = UserManager::get_number_of_users();
$nro_pages = round($count / $default) + 1; $nro_pages = round($count / $default) + 1;
$begin = $default * ($page - 1); $begin = $default * ($page - 1);
$end = $default * $page; $end = $default * $page;
$navigation = "$begin - $end / $count<br />";
$navigation = "$begin - $end / $count<br />";
if ($page > 1) { if ($page > 1) {
$navigation .= '<a href="'.api_get_self().'?page='.($page - 1).'">'.get_lang('Previous').'</a>'; $navigation .= '<a href="'.api_get_self().'?page='.($page - 1).'">'.get_lang('Previous').'</a>';
@ -624,14 +681,15 @@ if ($page > 1) {
} }
$navigation .= '&nbsp;'; $navigation .= '&nbsp;';
$page++; $page++;
if ($page < $nro_pages) if ($page < $nro_pages) {
$navigation .= '<a href="'.api_get_self().'?page='.$page.'">'.get_lang('Next').'</a>'; $navigation .= '<a href="'.api_get_self().'?page='.$page.'">'.get_lang('Next').'</a>';
else } else {
$navigation .= get_lang('Next'); $navigation .= get_lang('Next');
}
echo $navigation; echo $navigation;
$user_list = UserManager::get_user_list(array(), array(), $begin, $default); $user_list = UserManager::get_user_list(array(), array(), $begin, $default);
$session_list = SessionManager::get_sessions_list(array(), array('name')); $session_list = SessionManager::get_sessions_list(array(), array('name'));
$options = ''; $options = '';
$options .= '<option value="0">--'.get_lang('SelectASession').'--</option>'; $options .= '<option value="0">--'.get_lang('SelectASession').'--</option>';
foreach ($session_list as $session_data) { foreach ($session_list as $session_data) {

@ -352,9 +352,9 @@ class Attendance
/** /**
* edit attendances inside table * edit attendances inside table
* @param int attendance id * @param int attendance id
* @param bool true for adding link in gradebook or false otherwise (optional) * @param bool true for adding link in gradebook or false otherwise (optional)
* @return int last id * @return int last id
*/ */
public function attendance_edit($attendance_id, $link_to_gradebook = false) public function attendance_edit($attendance_id, $link_to_gradebook = false)
{ {
@ -663,7 +663,6 @@ class Attendance
$value = array(); $value = array();
$uid = $user_data['user_id']; $uid = $user_data['user_id'];
$userInfo = api_get_user_info($uid); $userInfo = api_get_user_info($uid);
$status = $user_data['status']; $status = $user_data['status'];
if (!empty($groupId)) { if (!empty($groupId)) {
@ -759,10 +758,10 @@ class Attendance
$rs = Database::query($sql); $rs = Database::query($sql);
if (Database::num_rows($rs) == 0) { if (Database::num_rows($rs) == 0) {
$sql = "INSERT INTO $tbl_attendance_sheet SET $sql = "INSERT INTO $tbl_attendance_sheet SET
c_id = $course_id, c_id = $course_id,
user_id = '$uid', user_id = '$uid',
attendance_calendar_id = '$calendar_id', attendance_calendar_id = '$calendar_id',
presence = 1"; presence = 1";
$result = Database::query($sql); $result = Database::query($sql);
$affected_rows += Database::affected_rows($result); $affected_rows += Database::affected_rows($result);
@ -843,7 +842,6 @@ class Attendance
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$attendance_id = intval($attendance_id); $attendance_id = intval($attendance_id);
// fill results about presence of students // fill results about presence of students
$attendance_calendar = $this->get_attendance_calendar( $attendance_calendar = $this->get_attendance_calendar(
@ -913,7 +911,6 @@ class Attendance
// update attendance qualify max // update attendance qualify max
$count_done_calendar = self::get_done_attendance_calendar($attendance_id); $count_done_calendar = self::get_done_attendance_calendar($attendance_id);
$sql = "UPDATE $tbl_attendance SET $sql = "UPDATE $tbl_attendance SET
attendance_qualify_max = '$count_done_calendar' attendance_qualify_max = '$count_done_calendar'
WHERE c_id = $course_id AND id = '$attendance_id'"; WHERE c_id = $course_id AND id = '$attendance_id'";
@ -1123,7 +1120,10 @@ class Attendance
$user_id = intval($user_id); $user_id = intval($user_id);
$results = array(); $results = array();
$total_faults = $total_weight = $porcent = 0; $total_faults = $total_weight = $porcent = 0;
$attendances_by_course = $this->get_attendances_list($course_info['real_id'], $session_id); $attendances_by_course = $this->get_attendances_list(
$course_info['real_id'],
$session_id
);
foreach ($attendances_by_course as $attendance) { foreach ($attendances_by_course as $attendance) {
// Get total faults and total weight // Get total faults and total weight
@ -1157,6 +1157,7 @@ class Attendance
* Get registered users' attendance sheet inside current course * Get registered users' attendance sheet inside current course
* @param int $attendance_id * @param int $attendance_id
* @param int $user_id for showing data for only one user (optional) * @param int $user_id for showing data for only one user (optional)
* @param int $groupId
* @return array users attendance sheet data * @return array users attendance sheet data
*/ */
public function get_users_attendance_sheet( public function get_users_attendance_sheet(
@ -1285,9 +1286,9 @@ class Attendance
/** /**
* Get user' score from current attendance * Get user' score from current attendance
* @param int $user_id * @param int $user_id
* @param int $attendance_id * @param int $attendance_id
* @return int score * @return int score
*/ */
public function get_user_score($user_id, $attendance_id, $groupId = null) public function get_user_score($user_id, $attendance_id, $groupId = null)
{ {
@ -1454,9 +1455,9 @@ class Attendance
/** /**
* Get number of attendance calendar inside current attendance * Get number of attendance calendar inside current attendance
* @param int $attendance_id * @param int $attendance_id
* @param int $groupId * @param int $groupId
* @return int number of dates in attendance calendar * @return int number of dates in attendance calendar
*/ */
public static function get_number_of_attendance_calendar( public static function get_number_of_attendance_calendar(
$attendance_id, $attendance_id,
@ -1547,8 +1548,8 @@ class Attendance
/** /**
* Get count dates inside attendance calendar by attendance id * Get count dates inside attendance calendar by attendance id
* @param int $attendance_id * @param int $attendance_id
* @return int count of dates * @return int count of dates
*/ */
public static function get_count_dates_inside_attendance_calendar($attendance_id) public static function get_count_dates_inside_attendance_calendar($attendance_id)
{ {
@ -1863,11 +1864,14 @@ class Attendance
* delete a datetime from attendance calendar table * delete a datetime from attendance calendar table
* @param int attendance calendar id * @param int attendance calendar id
* @param int attendance id * @param int attendance id
* @param bool true for removing all calendar inside current attendance, false for removing by calendar id * @param bool true for removing all calendar inside current attendance, false for removing by calendar id
* @return int affected rows * @return int affected rows
*/ */
public function attendance_calendar_delete($calendar_id, $attendance_id, $all_delete = false) public function attendance_calendar_delete(
{ $calendar_id,
$attendance_id,
$all_delete = false
) {
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
@ -1995,8 +1999,12 @@ class Attendance
*/ */
public function getAttendanceLogin($startDate, $endDate) public function getAttendanceLogin($startDate, $endDate)
{ {
if (empty($startDate) || $startDate == '0000-00-00' || $startDate == '0000-00-00 00:00:00' || if (empty($startDate) ||
empty($endDate) || $endDate == '0000-00-00' || $endDate == '0000-00-00 00:00:00' $startDate == '0000-00-00' ||
$startDate == '0000-00-00 00:00:00' ||
empty($endDate) ||
$endDate == '0000-00-00' ||
$endDate == '0000-00-00 00:00:00'
) { ) {
return false; return false;
} }

@ -59,7 +59,10 @@ class ExerciseLib
$pictureName = $objQuestionTmp->getPictureFilename(); $pictureName = $objQuestionTmp->getPictureFilename();
$s = ''; $s = '';
if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION && $answerType != ANNOTATION) { if ($answerType != HOT_SPOT &&
$answerType != HOT_SPOT_DELINEATION &&
$answerType != ANNOTATION
) {
// Question is not a hotspot // Question is not a hotspot
if (!$only_questions) { if (!$only_questions) {
$questionDescription = $objQuestionTmp->selectDescription(); $questionDescription = $objQuestionTmp->selectDescription();
@ -312,7 +315,6 @@ class ExerciseLib
//no break //no break
case READING_COMPREHENSION: case READING_COMPREHENSION:
$input_id = 'choice-'.$questionId.'-'.$answerId; $input_id = 'choice-'.$questionId.'-'.$answerId;
if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) {
$attributes = array( $attributes = array(
'id' => $input_id, 'id' => $input_id,
@ -1054,9 +1056,7 @@ HTML;
} }
$s .= '</td></tr>'; $s .= '</td></tr>';
$lines_count++; $lines_count++;
if (($lines_count - 1) == $num_suggestions) { if (($lines_count - 1) == $num_suggestions) {
while (isset($select_items[$lines_count])) { while (isset($select_items[$lines_count])) {
$s .= <<<HTML $s .= <<<HTML

Loading…
Cancel
Save