Exemplo n.º 1
0
 /**
  * Shows statistics about the time of last visit to each course.
  */
 static function print_course_last_visit()
 {
     $access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     $current_url_id = api_get_current_access_url_id();
     $columns[0] = 'c_id';
     $columns[1] = 'access_date';
     $sql_order[SORT_ASC] = 'ASC';
     $sql_order[SORT_DESC] = 'DESC';
     $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10;
     $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1;
     $column = isset($_GET['column']) ? intval($_GET['column']) : 0;
     $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60;
     if (!in_array($_GET['direction'], array(SORT_ASC, SORT_DESC))) {
         $direction = SORT_ASC;
     } else {
         $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC;
     }
     $form = new FormValidator('courselastvisit', 'get');
     $form->addElement('hidden', 'report', 'courselastvisit');
     $form->add_textfield('date_diff', get_lang('Days'), true);
     $form->addRule('date_diff', 'InvalidNumber', 'numeric');
     $form->addElement('style_submit_button', 'submit', get_lang('Search'), 'class="search"');
     if (!isset($_GET['date_diff'])) {
         $defaults['date_diff'] = 60;
     } else {
         $defaults['date_diff'] = Security::remove_XSS($_GET['date_diff']);
     }
     $form->setDefaults($defaults);
     $form->display();
     $values = $form->exportValues();
     $date_diff = $values['date_diff'];
     $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
     $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
     if (api_is_multiple_url_enabled()) {
         $sql = "SELECT access_date, c.code FROM {$table} s , {$access_url_rel_course_table} u, {$tableCourse} c\n                    WHERE c.id = u.c_id AND c.id = s.c_id AND access_url_id='" . $current_url_id . "' " . "GROUP BY access_cours_code " . "HAVING s.c_id <> '' " . "AND DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff;
     } else {
         $sql = "SELECT access_date, c.code FROM {$table} , {$tableCourse} c\n                    WHERE c_id = c.id\n                    GROUP BY c_id\n                    HAVING c_id <> ''AND\n                    DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff;
     }
     $res = Database::query($sql);
     $number_of_courses = Database::num_rows($res);
     $sql .= ' ORDER BY ' . $columns[$column] . ' ' . $sql_order[$direction];
     $from = ($page_nr - 1) * $per_page;
     $sql .= ' LIMIT ' . $from . ',' . $per_page;
     echo '<p>' . get_lang('LastAccess') . ' &gt;= ' . $date_diff . ' ' . get_lang('Days') . '</p>';
     $res = Database::query($sql);
     if (Database::num_rows($res) > 0) {
         $courses = array();
         while ($obj = Database::fetch_object($res)) {
             $course = array();
             $course[] = '<a href="' . api_get_path(WEB_PATH) . 'courses/' . $obj->code . '">' . $obj->code . ' <a>';
             //Allow sort by date hiding the numerical date
             $course[] = '<span style="display:none;">' . $obj->access_date . '</span>' . api_convert_and_format_date($obj->access_date);
             $courses[] = $course;
         }
         $parameters['date_diff'] = $date_diff;
         $parameters['report'] = 'courselastvisit';
         $table_header[] = array(get_lang("CourseCode"), true);
         $table_header[] = array(get_lang("LastAccess"), true);
         Display::display_sortable_table($table_header, $courses, array('column' => $column, 'direction' => $direction), array(), $parameters);
     } else {
         echo get_lang('NoSearchResults');
     }
 }
Exemplo n.º 2
0
 /**
  * Displays the form to register users in a blog (in a course)
  * The listed users are users subcribed in the course.
  * @author Toon Keppens
  *
  * @param Integer $blog_id
  *
  * @return Html Form with sortable table with users to unsubcribe from a blog.
  */
 public static function display_form_user_unsubscribe($blog_id)
 {
     $_user = api_get_user_info();
     $is_western_name_order = api_is_western_name_order();
     // Init
     $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
     echo '<legend>' . get_lang('UnsubscribeMembers') . '</legend>';
     $properties["width"] = "100%";
     //table column titles
     $column_header[] = array('', false, '');
     if ($is_western_name_order) {
         $column_header[] = array(get_lang('FirstName'), true, '');
         $column_header[] = array(get_lang('LastName'), true, '');
     } else {
         $column_header[] = array(get_lang('LastName'), true, '');
         $column_header[] = array(get_lang('FirstName'), true, '');
     }
     $column_header[] = array(get_lang('Email'), false, '');
     $column_header[] = array(get_lang('TaskManager'), true, '');
     $column_header[] = array(get_lang('UnRegister'), false, '');
     $course_id = api_get_course_int_id();
     $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username\n                FROM {$tbl_users} user INNER JOIN {$tbl_blogs_rel_user} blogs_rel_user\n                ON user.user_id = blogs_rel_user.user_id\n                WHERE blogs_rel_user.c_id = {$course_id} AND  blogs_rel_user.blog_id = '" . (int) $blog_id . "'";
     if (!($sql_result = Database::query($sql))) {
         return false;
     }
     $user_data = array();
     while ($myrow = Database::fetch_array($sql_result)) {
         $row = array();
         $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" ' . (isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe" ? ' checked="checked" ' : '') . '/>';
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
         if ($is_western_name_order) {
             $row[] = $myrow["firstname"];
             $row[] = Display::tag('span', $myrow["lastname"], array('title' => $username));
         } else {
             $row[] = Display::tag('span', $myrow["lastname"], array('title' => $username));
             $row[] = $myrow["firstname"];
         }
         $row[] = Display::icon_mailto_link($myrow["email"]);
         $sql = "SELECT bt.title task\n\t\t\t\t\tFROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu\n\t\t\t\t\tINNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt\n\t\t\t\t\tON btu.task_id = bt.task_id\n\t\t\t\t\tWHERE \tbtu.c_id \t= {$course_id}  AND\n\t\t\t\t\t\t\tbt.c_id \t= {$course_id}  AND\n\t\t\t\t\t\t\tbtu.blog_id = {$blog_id} AND\n\t\t\t\t\t\t\tbtu.user_id = " . $myrow['user_id'];
         $sql_res = Database::query($sql);
         $task = '';
         while ($r = Database::fetch_array($sql_res)) {
             $task .= stripslashes($r['task']) . ', ';
         }
         //echo $task;
         $task = api_strlen(trim($task)) != 0 ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
         $row[] = $task;
         //Link to register users
         if ($myrow["user_id"] != $_user['user_id']) {
             $row[] = "<a class=\"btn btn-primary\" href=\"" . api_get_self() . "?action=manage_members&blog_id={$blog_id}&unregister=yes&user_id=" . $myrow['user_id'] . "\">" . get_lang('UnRegister') . "</a>";
         } else {
             $row[] = '';
         }
         $user_data[] = $row;
     }
     $query_vars['action'] = 'manage_members';
     $query_vars['blog_id'] = $blog_id;
     echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
     Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
     $link = '';
     $link .= isset($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
     $link .= "blog_id={$blog_id}&";
     echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
     echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
     echo get_lang('WithSelected') . ' : ';
     echo '<select name="action">';
     echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
     echo '</select>';
     echo '<input type="hidden" name="unregister" value="true" />';
     echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
     echo '</form>';
 }
Exemplo n.º 3
0
        // This function checks if the question can be read
        $question_type = get_question_type_for_question($selected_course, $question['id']);
        if (empty($question_type)) {
            continue;
        }
        $sessionId = isset($question['session_id']) ? $question['session_id'] : null;
        $exerciseName = isset($question['exercise_name']) ? '<br />(' . $question['exercise_id'] . ') ' : null;
        $row[] = get_a_tag_for_question($questionTagA, $fromExercise, $question['id'], $question['type'], $question['question'], $sessionId) . $exerciseName;
        $row[] = $question_type;
        $row[] = get_question_categorie_for_question($selected_course, $question['id']);
        $row[] = $question['level'];
        $row[] = get_action_icon_for_question($actionIcon1, $fromExercise, $question['id'], $question['type'], $question['question'], $selected_course, $courseCategoryId, $exerciseLevel, $answerType, $session_id, $exerciseId) . "&nbsp;" . get_action_icon_for_question($actionIcon2, $fromExercise, $question['id'], $question['type'], $question['question'], $selected_course, $courseCategoryId, $exerciseLevel, $answerType, $session_id, $exerciseId);
        $data[] = $row;
    }
}
Display::display_sortable_table($header, $data, '', array('per_page_default' => 999, 'per_page' => 999, 'page_nr' => 1));
if (!$nbrQuestions) {
    echo get_lang('NoQuestion');
}
Display::display_footer();
/**
*	Put the menu entry for level and type to default "Choice"
*	It is useful if you change the exercise, you need to reset the other menus
*   @author hubert.borderiou 13-10-2011
*/
function reset_menu_lvl_type()
{
    global $exerciseLevel, $answerType;
    $answerType = -1;
    $exerciseLevel = -1;
}
echo get_lang('Close');
?>
</a></div>
<h4>
<?php 
echo get_lang('AllowedHTMLTags');
?>
</h4>
<?php 
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML : STUDENT_HTML;
$fullpage = intval($_GET['fullpage']) != 0;
$tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($html_type, $fullpage);
$table_header = array();
$table_header[] = array('tag', true);
$table_header[] = array('attributes', false);
foreach ($tags as $tag => &$attributes) {
    $row = array();
    $row[] = '<kbd>' . $tag . '</kbd>';
    $row[] = '<kbd>&nbsp;' . implode(', ', array_keys($attributes)) . '</kbd>';
    $table_data[] = $row;
}
Display::display_sortable_table($table_header, $table_data, array(), array(), array('fullpage' => intval($_GET['fullpage'])));
?>
<div style="text-align:right;"><a href="javascript: window.close();"><?php 
echo get_lang('Close');
?>
</a></div>
</div>
</body>
</html>
echo $sort;
?>
" onsubmit="javascript:if(!confirm('<?php 
echo get_lang('ConfirmYourChoice');
?>
')) return false;">
<?php 
$tableHeader = array();
$tableHeader[] = array(' ');
$tableHeader[] = array(get_lang('CourseTitle'));
$tableHeader[] = array(get_lang('NbUsers'));
$tableHeader[] = array(get_lang('Actions'));
$tableCourses = array();
foreach ($Courses as $key => $enreg) {
    $course = array();
    $course[] = '<input type="checkbox" name="idChecked[]" value="' . $enreg['code'] . '">';
    $course[] = api_htmlentities($enreg['title'], ENT_QUOTES, $charset);
    $course[] = '<a href="session_course_user_list.php?id_session=' . $id_session . '&course_code=' . $enreg['code'] . '">' . $enreg['nbr_users'] . ' ' . get_lang('Users') . '</a>';
    $course[] = '<a href="' . api_get_path(WEB_COURSE_PATH) . $enreg['code'] . '/?id_session=' . $id_session . '">' . Display::return_icon('course_home.gif', get_lang('Course')) . '</a>
                <a href="session_course_edit.php?id_session=' . $id_session . '&page=session_course_list.php&course_code=' . $enreg['code'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>
				<a href="' . api_get_self() . '?id_session=' . $id_session . '&sort=' . $sort . '&action=delete&idChecked[]=' . $enreg['code'] . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a>';
    $tableCourses[] = $course;
}
echo '<form method="post" action="' . api_get_self() . '">';
Display::display_sortable_table($tableHeader, $tableCourses, array(), array());
echo '<select name="action">
	<option value="delete">' . get_lang('UnsubscribeCoursesFromSession') . '</option>
	</select>
	<button class="save" type="submit">' . get_lang('Ok') . '</button>
	</form>';
Display::display_footer();
Exemplo n.º 6
0
        $data[] = $row;
    }
    Display::display_sortable_table($table_header, $data, array(), array(), array('id' => $_GET['id']));
} else {
    echo get_lang('NoUsersInClass');
}
/**
 * Show all courses in which this class is subscribed.
 */
$courses = ClassManager::get_courses($class_id);
if (count($courses) > 0) {
    $header[] = array(get_lang('Code'), true);
    $header[] = array(get_lang('Title'), true);
    $header[] = array('', false);
    $data = array();
    foreach ($courses as $index => $course) {
        $row = array();
        $row[] = $course['visual_code'];
        $row[] = $course['title'];
        $row[] = '<a href="course_information.php?code=' . $course['code'] . '">' . Display::return_icon('info_small.gif', get_lang('Delete')) . '</a>' . '<a href="' . api_get_path(WEB_COURSE_PATH) . $course['directory'] . '">' . Display::return_icon('course_home.gif', get_lang('CourseHome')) . '</a>' . '<a href="course_edit.php?course_code=' . $course['code'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
        $data[] = $row;
    }
    echo '<p><b>' . get_lang('Courses') . '</b></p>';
    echo '<blockquote>';
    Display::display_sortable_table($header, $data, array(), array(), array('id' => $_GET['id']));
    echo '</blockquote>';
} else {
    echo '<p>' . get_lang('NoCoursesForThisClass') . '</p>';
}
// Displaying the footer.
Display::display_footer();
Exemplo n.º 7
0
function display_virtual_course_list()
{
    $course_list = CourseManager::get_virtual_course_list();
    if (!is_array($course_list)) {
        //there are no virtual courses
        echo "<i>" . get_lang('ThereAreNoVirtualCourses') . "</i>";
        return;
    }
    $column_header[] = array(get_lang('Title'), true);
    $column_header[] = array(get_lang('Code'), true);
    $column_header[] = array(get_lang('VisualCode'), true);
    $column_header[] = array(get_lang('LinkedCourseTitle'), true);
    $column_header[] = array(get_lang('LinkedCourseCode'), true);
    $table_data = array();
    for ($i = 0; $i < count($course_list); $i++) {
        $course_list[$i] = Database::generate_abstract_course_field_names($course_list[$i]);
        $target_course_code = $course_list[$i]["target_course_code"];
        $real_course_info = Database::get_course_info($target_course_code);
        $row = array();
        $row[] = $course_list[$i]["title"];
        $row[] = $course_list[$i]["system_code"];
        $row[] = $course_list[$i]["visual_code"];
        $row[] = $real_course_info["title"];
        $row[] = $real_course_info["system_code"];
        $table_data[] = $row;
    }
    Display::display_sortable_table($column_header, $table_data, array(), array(), array('action' => $_GET['action']));
}
        $data[] = $row;
    }
    echo '<p><b>'.get_lang('Classes').'</b></p>';
    echo '<blockquote>';
    Display :: display_sortable_table($header, $data, array (), array (), array ('user_id' => intval($_GET['user_id'])));
    echo '</blockquote>';
} else {
    echo '<p>'.get_lang('NoClassesForThisUser').'</p>';
}*/
/**
 * Show the URL in which this user is subscribed
 */
if (api_is_multiple_url_enabled()) {
    $url_list = UrlManager::get_access_url_from_user($user['user_id']);
    if (count($url_list) > 0) {
        $header = array();
        $header[] = array('URL', true);
        $data = array();
        foreach ($url_list as $url) {
            $row = array();
            $row[] = Display::url($url['url'], $url['url']);
            $data[] = $row;
        }
        echo '<p><b>' . get_lang('URLList') . '</b></p>';
        Display::display_sortable_table($header, $data, array(), array(), array('user_id' => intval($_GET['user_id'])));
    } else {
        echo '<p>' . get_lang('NoUrlForThisUser') . '</p>';
    }
}
/* FOOTER */
Display::display_footer();