Ejemplo n.º 1
0
function printPolls()
{
    global $tool_content, $course_id, $course_code, $langCreatePoll, $langPollsActive, $langTitle, $langPollCreator, $langPollCreation, $langCancel, $langPollStart, $langPollEnd, $langPollNone, $is_editor, $langAnswers, $themeimg, $langEdit, $langDelete, $langActions, $langSurveyNotStarted, $langDeactivate, $langPollsInactive, $langPollHasEnded, $langActivate, $langParticipate, $langVisible, $user_id, $langHasParticipated, $langSee, $langHasNotParticipated, $uid, $langConfirmDelete, $langPurgeExercises, $langPurgeExercises, $langConfirmPurgeExercises, $langCreateDuplicate, $head_content, $langCreateDuplicateIn, $langCurrentCourse;
    $head_content .= "\n    <script>\n        \$(document).on('click', '.warnLink', function() {\n            var pid = \$(this).data('pid');\n            \$('#clone_form').attr('action', '{$_SERVER['SCRIPT_NAME']}?pid=' + pid);\n        });          \n    </script>\n    ";
    $poll_check = 0;
    $result = Database::get()->queryArray("SELECT * FROM poll WHERE course_id = ?d", $course_id);
    $num_rows = count($result);
    if ($num_rows > 0) {
        ++$poll_check;
    }
    if (!$poll_check) {
        $tool_content .= "\n    <div class='alert alert-warning'>" . $langPollNone . "</div><br>";
    } else {
        // Print active polls
        $tool_content .= "\n                    <div class='table-repsonsive'>\n\t\t      <table class='table-default'>\n\t\t      <tr>\n\t\t\t<th><div align='left'>&nbsp;{$langTitle}</div></th>\n\t\t\t<th class='text-center'>{$langPollStart}</th>\n\t\t\t<th class='text-center'>{$langPollEnd}</th>";
        if ($is_editor) {
            $tool_content .= "<th class='text-center' width='16'>{$langAnswers}</th>" . "<th class='text-center'>" . icon('fa-cogs') . "</th>";
        } else {
            $tool_content .= "<th class='text-center'>{$langParticipate}</th>";
        }
        $tool_content .= "</tr>";
        $index_aa = 1;
        $k = 0;
        foreach ($result as $thepoll) {
            $total_participants = Database::get()->querySingle("SELECT COUNT(DISTINCT user_id) AS total FROM poll_answer_record WHERE pid = ?d", $thepoll->pid)->total;
            $visibility = $thepoll->active;
            if ($visibility or $is_editor) {
                if ($visibility) {
                    $visibility_css = "";
                    $visibility_gif = "fa-eye";
                    $visibility_func = "deactivate";
                    $arrow_png = "arrow";
                    $k++;
                } else {
                    $visibility_css = " class=\"not_visible\"";
                    $visibility_gif = "fa-eye-slash";
                    $visibility_func = "activate";
                    $arrow_png = "arrow";
                    $k++;
                }
                $tool_content .= "<tr {$visibility_css}>";
                $temp_CurrentDate = date("Y-m-d H:i");
                $temp_StartDate = $thepoll->start_date;
                $temp_EndDate = $thepoll->end_date;
                $temp_StartDate = mktime(substr($temp_StartDate, 11, 2), substr($temp_StartDate, 14, 2), 0, substr($temp_StartDate, 5, 2), substr($temp_StartDate, 8, 2), substr($temp_StartDate, 0, 4));
                $temp_EndDate = mktime(substr($temp_EndDate, 11, 2), substr($temp_EndDate, 14, 2), 0, substr($temp_EndDate, 5, 2), substr($temp_EndDate, 8, 2), substr($temp_EndDate, 0, 4));
                $temp_CurrentDate = mktime(substr($temp_CurrentDate, 11, 2), substr($temp_CurrentDate, 14, 2), 0, substr($temp_CurrentDate, 5, 2), substr($temp_CurrentDate, 8, 2), substr($temp_CurrentDate, 0, 4));
                $creator_id = $thepoll->creator_id;
                $theCreator = uid_to_name($creator_id);
                $pid = $thepoll->pid;
                $countAnswers = Database::get()->querySingle("SELECT COUNT(DISTINCT(user_id)) as counter FROM poll_answer_record WHERE pid = ?d", $pid)->counter;
                // check if user has participated
                $has_participated = Database::get()->querySingle("SELECT COUNT(*) as counter FROM poll_answer_record\n                                        WHERE user_id = ?d AND pid = ?d", $uid, $pid)->counter;
                // check if poll has ended OR not strarted yet
                $poll_ended = 0;
                $poll_not_started = 0;
                if ($temp_CurrentDate < $temp_StartDate) {
                    $poll_not_started = 1;
                } else {
                    if ($temp_CurrentDate >= $temp_EndDate) {
                        $poll_ended = 1;
                    }
                }
                if ($is_editor) {
                    $tool_content .= "\n                        <td><a href='pollparticipate.php?course={$course_code}&amp;UseCase=1&pid={$pid}'>" . q($thepoll->name) . "</a>";
                } else {
                    $tool_content .= "\n                        <td>";
                    if ($has_participated == 0 and $poll_ended == 0) {
                        $tool_content .= "<a href='pollparticipate.php?course={$course_code}&amp;UseCase=1&pid={$pid}'>" . q($thepoll->name) . "</a>";
                    } else {
                        $tool_content .= q($thepoll->name);
                    }
                }
                $tool_content .= "                       \n                        <td class='text-center'>" . nice_format(date("Y-m-d H:i", strtotime($thepoll->start_date)), true) . "</td>\n                        <td class='text-center'>" . nice_format(date("Y-m-d H:i", strtotime($thepoll->end_date)), true) . "</td>";
                if ($is_editor) {
                    $tool_content .= "\n                        <td class='text-center'>{$countAnswers}</td>\n                        <td class='text-center option-btn-cell'>" . action_button(array(array('title' => $langSee, 'icon' => 'fa-search', 'url' => "pollparticipate.php?course={$course_code}&amp;UseCase=1&pid={$pid}"), array('title' => $langEdit, 'icon' => 'fa-edit', 'url' => "admin.php?course={$course_code}&amp;pid={$pid}"), array('title' => $langPurgeExercises, 'icon' => 'fa-eraser', 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;delete_results=yes&amp;pid={$pid}", 'confirm' => $langConfirmPurgeExercises, 'show' => $total_participants > 0), array('title' => $langDelete, 'icon' => 'fa-times', 'class' => 'delete', 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;delete=yes&amp;pid={$pid}", 'confirm' => $langConfirmDelete), array('title' => $langVisible, 'icon' => $visibility_gif, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;visibility={$visibility_func}&amp;pid={$pid}"), array('title' => $langParticipate, 'icon' => 'fa-pie-chart', 'url' => "pollresults.php?course={$course_code}&pid={$pid}", 'show' => $total_participants > 0), array('title' => $langCreateDuplicate, 'icon' => 'fa-copy', 'icon-class' => 'warnLink', 'icon-extra' => "data-toggle='modal' data-target='#modalWarning' data-remote='false' data-pid='{$pid}'", 'url' => "#"))) . "</td></tr>";
                } else {
                    $tool_content .= "\n                        <td class='text-center'>";
                    if ($has_participated == 0 && $poll_ended == 0 && $poll_not_started == 0) {
                        $tool_content .= "{$langHasNotParticipated}";
                    } else {
                        if ($poll_ended == 1) {
                            $tool_content .= $langPollHasEnded;
                        } elseif ($poll_not_started == 1) {
                            $tool_content .= $langSurveyNotStarted;
                        } else {
                            $tool_content .= $langHasParticipated;
                        }
                    }
                    $tool_content .= "</td></tr>";
                }
            }
            $index_aa++;
        }
        $tool_content .= "</table></div>";
    }
    $my_courses = Database::get()->queryArray("SELECT a.course_id Course_id, b.title Title FROM course_user a, course b WHERE a.course_id = b.id AND a.course_id != ?d AND a.user_id = ?d AND a.status = 1", $course_id, $uid);
    $tool_content .= "\n    <!-- Modal -->\n    <div class='modal fade' id='modalWarning' tabindex='-1' role='dialog' aria-labelledby='modalWarningLabel' aria-hidden='true'>\n      <div class='modal-dialog'>\n        <div class='modal-content'>\n          <div class='modal-header'>\n          {$langCreateDuplicateIn}\n            <button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span></button>\n          </div>\n          <form action='{$_SERVER['SCRIPT_NAME']}' method='POST' id='clone_form'>\n          <div class='modal-body'>\n            <select class='form-control' id='course_id' name='clone_to_course_id'>\n                <option value='{$course_id}' selected>--- {$langCurrentCourse} ---</option>";
    foreach ($my_courses as $row) {
        $tool_content .= "<option value='{$row->Course_id}'>{$row->Title}</option>";
    }
    $tool_content .= "            \n            </select>\n          </div>\n          <div class='modal-footer'>\n            <input type='submit' class='btn btn-primary' value='{$langCreateDuplicate}'>\n            <a href='#' data-dismiss='modal' class='btn btn-default'>{$langCancel}</a>\n          </div>\n          </form>\n        </div>\n      </div>\n    </div>    \n    ";
}
Ejemplo n.º 2
0
 * ======================================================================== */

/**
 * @file messageList.php
 * @brief Functionality of chat module
 */
$require_current_course = TRUE;
$require_login = TRUE;
require_once '../../include/baseTheme.php';
require_once 'include/lib/textLib.inc.php';

    $coursePath = $webDir . '/courses/';
    $fileChatName = $coursePath . $course_code . '/chat.txt';
    $tmpArchiveFile = $coursePath . $course_code . '/tmpChatArchive.txt';

    $nick = uid_to_name($uid);

// How many lines to show on screen
    define('MESSAGE_LINE_NB', 20);
// How many lines to keep in temporary archive
// (the rest are in the current chat file)
    define('MAX_LINE_IN_FILE', 20);

    if ($GLOBALS['language'] == 'el') {
        $timeNow = date("d-m-Y / H:i", time());
    } else {
        $timeNow = date("Y-m-d / H:i", time());
    }

    if (!file_exists($fileChatName)) {
        $fp = fopen($fileChatName, 'w') or die('<center>$langChatError</center>');
Ejemplo n.º 3
0
            $total_reply_pages = ceil($replies / $posts_per_page);
            $pagination .= "<strong class='pagination'><span>&nbsp;".icon('fa-arrow-circle-right')." ";
            add_topic_link(0, $total_reply_pages);
            if ($total_reply_pages > PAGINATION_CONTEXT + 1) {
                $pagination .= "&nbsp;...&nbsp;";
            }
            for ($p = max(1, $total_reply_pages - PAGINATION_CONTEXT); $p < $total_reply_pages; $p++) {
                add_topic_link($p, $total_reply_pages);
            }
            $pagination .= "&nbsp;</span></strong>";
        }
        $tool_content .= "<td>$image <a href='$topiclink'><b>" . q($topic_title) . "</b></a>$pagination</td>";
        $tool_content .= "<td class='text-center'>$replies</td>";
        $tool_content .= "<td class='text-center'>" . q(uid_to_name($myrow->poster_id)) . "</td>";
        $tool_content .= "<td class='text-center'>$myrow->num_views</td>";
        $tool_content .= "<td class='text-center'>" . q(uid_to_name($myrow->poster_id)) . "<br />$last_post_datetime</td>";
        $sql = Database::get()->querySingle("SELECT notify_sent FROM forum_notify
			WHERE user_id = ?d AND topic_id = ?d AND course_id = ?d", $uid, $myrow->id, $course_id);
        if ($sql) {
            $topic_action_notify = $sql->notify_sent;
        }
        if (!isset($topic_action_notify)) {
            $topic_link_notify = FALSE;
            $topic_icon = '_off';
        } else {
            $topic_link_notify = toggle_link($topic_action_notify);
            $topic_icon = toggle_icon($topic_action_notify);
        }
        $tool_content .= "<td class='text-center option-btn-cell'>";

        $dyntools = (!$is_editor) ? array() : array(
Ejemplo n.º 4
0
/**
 * Link for displaying user profile
 * @param type $uid
 * @param type $size
 * @param type $class
 * @return type
 */
function profile_image($uid, $size, $class = null)
{
    global $urlServer, $themeimg;
    // makes $class argument optional
    $class_attr = $class == null ? '' : "class='" . q($class) . "'";
    $name = $uid > 0 ? q(trim(uid_to_name($uid))) : '';
    if ($uid > 0 and file_exists("courses/userimg/{$uid}_{$size}.jpg")) {
        return "<img src='{$urlServer}courses/userimg/{$uid}_{$size}.jpg' {$class_attr} title='{$name}' alt='{$name}'>";
    } else {
        return "<img src='{$themeimg}/default_{$size}.jpg' {$class_attr} title='{$name}' alt='{$name}'>";
    }
}
Ejemplo n.º 5
0
            }
        } else { // free text questions
            $answers = Database::get()->queryArray("SELECT answer_text, user_id
                                FROM poll_answer_record
                                WHERE qid = ?d
                                ORDER BY user_id", $q->pqid);
            foreach ($answers as $a) {
                $qlist[$a->user_id][$q->pqid] = $a->answer_text;
            }
        }
    }
    echo $crlf;
    $k = 0;
    foreach ($qlist as $user_id => $answers) {
        $k++;
        $student_name = $anonymized? "$langStudent $k": uid_to_name($user_id);
        if ($anonymized) {
            $user_id = $k;
        }
        echo csv_escape($student_name), ';', $user_id, ';',
             implode(';', array_map('csv_escape', $answers)), $crlf;
    }
} else {
    echo csv_escape($langQuestions), $crlf, $crlf;
    $questions = Database::get()->queryArray("SELECT * FROM poll_question WHERE pid=?d ORDER BY q_position",$p->pid);
    foreach ($questions as $q) {
        if ($q->qtype == QTYPE_LABEL) {
            echo csv_escape(strip_tags($q->question_text)), $crlf, $crlf;
        } else {
            echo csv_escape($q->question_text), $crlf;
            if ($q->qtype == QTYPE_SINGLE or $q->qtype == QTYPE_MULTIPLE) {
Ejemplo n.º 6
0
function printPolls() {
    global $tool_content, $course_id, $course_code,
    $langTitle, $langCancel,
    $langPollStart, $langPollEnd, $langPollNone, $is_editor, $langAnswers,
    $langEditChange, $langDelete, $langSurveyNotStarted,
    $langDeactivate, $langPollHasEnded, $langActivate,
    $langParticipate,  $langHasParticipated, $langSee,
    $langHasNotParticipated, $uid, $langConfirmDelete, $langPurgeExercises,
    $langPurgeExercises, $langConfirmPurgeExercises, $langCreateDuplicate, 
    $head_content, $langCreateDuplicateIn, $langCurrentCourse, $langUsage, $langNoAccessPrivilages;
    
    $my_courses = Database::get()->queryArray("SELECT a.course_id Course_id, b.title Title FROM course_user a, course b WHERE a.course_id = b.id AND a.course_id != ?d AND a.user_id = ?d AND a.status = 1", $course_id, $uid);
    $courses_options = "";
    foreach ($my_courses as $row) {
        $courses_options .= "'<option value=\"$row->Course_id\">".q($row->Title)."</option>'+";
    }    
    $head_content .= "
    <script>
        $(document).on('click', '.warnLink', function() {
            var pid = $(this).data('pid');
            bootbox.dialog({
                title: '$langCreateDuplicateIn',
                message: '<form action=\"$_SERVER[SCRIPT_NAME]\" method=\"POST\" id=\"clone_form\">'+
                            '<select class=\"form-control\" id=\"course_id\" name=\"clone_to_course_id\">'+
                                '<option value=\"$course_id\">--- $langCurrentCourse ---</option>'+
                                $courses_options    
                            '</select>'+
                          '</form>',
                    buttons: {
                        success: {
                            label: '$langCreateDuplicate',
                            className: 'btn-success',
                            callback: function (d) {    
                                $('#clone_form').attr('action', '$_SERVER[SCRIPT_NAME]?pid=' + pid);
                                $('#clone_form').submit();  
                            }
                        },
                        cancel: {
                            label: '$langCancel',
                            className: 'btn-default'
                        }                        
                    }
                            
                    
            });
        });          
    </script>
    ";
    
    $poll_check = 0;
    $query = "SELECT * FROM poll WHERE course_id = ?d";
    $query_params[] = $course_id;
    //Bring only those assigned to the student
    if (!$is_editor) {
        $gids = user_group_info($uid, $course_id);
        if (!empty($gids)) {
            $gids_sql_ready = implode(',',array_keys($gids));
        } else {
            $gids_sql_ready = "''";
        }        
        $query .= " AND
                    (assign_to_specific = '0' OR assign_to_specific != '0' AND pid IN
                       (SELECT poll_id FROM poll_to_specific WHERE user_id = ?d UNION SELECT poll_id FROM poll_to_specific WHERE group_id IN ($gids_sql_ready))
                    )";
        $query_params[] = $uid;
    }
    
    $result = Database::get()->queryArray($query, $query_params);
        
    $num_rows = count($result);
    if ($num_rows > 0)
        ++$poll_check;
    if (!$poll_check) {
        $tool_content .= "\n    <div class='alert alert-warning'>" . $langPollNone . "</div><br>";
    } else {
        // Print active polls
        $tool_content .= "
                    <div class='table-repsonsive'>
		      <table class='table-default'>
		      <tr class='list-header'>
			<th><div align='left'>&nbsp;$langTitle</div></th>
			<th class='text-center'>$langPollStart</th>
			<th class='text-center'>$langPollEnd</th>";

        if ($is_editor) {
            $tool_content .= "<th class='text-center' width='16'>$langAnswers</th>";
        } else {
            $tool_content .= "<th class='text-center'>$langParticipate</th>";
        }
        $tool_content .= "<th class='text-center'>".icon('fa-cogs')."</th>";
        $tool_content .= "</tr>";
        $index_aa = 1;
        $k = 0;
        foreach ($result as $thepoll) {
            $total_participants = Database::get()->querySingle("SELECT COUNT(DISTINCT user_id) AS total FROM poll_answer_record WHERE pid = ?d", $thepoll->pid)->total;
            $visibility = $thepoll->active;

            if (($visibility) or ($is_editor)) {
                if ($visibility) {
                    $visibility_css = "";
                    $visibility_gif = "fa-eye";
                    $visibility_func = "deactivate";
                    $arrow_png = "arrow";
                    $k++;
                } else {
                    $visibility_css = " class=\"not_visible\"";
                    $visibility_gif = "fa-eye-slash";
                    $visibility_func = "activate";
                    $arrow_png = "arrow";
                    $k++;
                }
                $tool_content .= "<tr $visibility_css>";

                $temp_CurrentDate = date("Y-m-d H:i");
                $temp_StartDate = $thepoll->start_date;
                $temp_EndDate = $thepoll->end_date;
                $temp_StartDate = mktime(substr($temp_StartDate, 11, 2), substr($temp_StartDate, 14, 2), 0, substr($temp_StartDate, 5, 2), substr($temp_StartDate, 8, 2), substr($temp_StartDate, 0, 4));
                $temp_EndDate = mktime(substr($temp_EndDate, 11, 2), substr($temp_EndDate, 14, 2), 0, substr($temp_EndDate, 5, 2), substr($temp_EndDate, 8, 2), substr($temp_EndDate, 0, 4));
                $temp_CurrentDate = mktime(substr($temp_CurrentDate, 11, 2), substr($temp_CurrentDate, 14, 2), 0, substr($temp_CurrentDate, 5, 2), substr($temp_CurrentDate, 8, 2), substr($temp_CurrentDate, 0, 4));
                $creator_id = $thepoll->creator_id;
                $theCreator = uid_to_name($creator_id);
                $pid = $thepoll->pid;
                $countAnswers = Database::get()->querySingle("SELECT COUNT(DISTINCT(user_id)) as counter FROM poll_answer_record WHERE pid = ?d", $pid)->counter;
                // check if user has participated
                $has_participated = Database::get()->querySingle("SELECT COUNT(*) as counter FROM poll_answer_record
                                        WHERE user_id = ?d AND pid = ?d", $uid, $pid)->counter;
                // check if poll has ended OR not strarted yet
                $poll_ended = 0;
                $poll_not_started = 0;
                if($temp_CurrentDate < $temp_StartDate) {
                    $poll_not_started = 1;
                } else if ($temp_CurrentDate >= $temp_EndDate) {
                    $poll_ended = 1;
                }
                
                if ($is_editor) {
                    $tool_content .= "
                        <td><a href='pollparticipate.php?course=$course_code&amp;UseCase=1&pid=$pid'>".q($thepoll->name)."</a>";
                } else {
                    $tool_content .= "
                        <td>";
                    if (($has_participated == 0) and $poll_ended == 0) {
                        $tool_content .= "<a href='pollparticipate.php?course=$course_code&amp;UseCase=1&pid=$pid'>".q($thepoll->name)."</a>";
                    } else {
                        $tool_content .= q($thepoll->name);
                    }
                }
                $tool_content .= "                       
                        <td class='text-center'>" . nice_format(date("Y-m-d H:i", strtotime($thepoll->start_date)), true) . "</td>
                        <td class='text-center'>" . nice_format(date("Y-m-d H:i", strtotime($thepoll->end_date)), true) . "</td>";
                if ($is_editor) {
                    $tool_content .= "
                        <td class='text-center'>$countAnswers</td>
                        <td class='text-center option-btn-cell'>" .action_button(array(
                            array(
                                'title' => $langEditChange,
                                'icon' => 'fa-edit',
                                'url' => "admin.php?course=$course_code&amp;pid=$pid"                              
                            ),
                            array(
                                'title' => $visibility?  $langDeactivate : $langActivate,
                                'icon' => $visibility ?  'fa-toggle-off' : 'fa-toggle-on',
                                'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;visibility=$visibility_func&amp;pid={$pid}"
                            ),
                            array(
                                'title' => $langUsage,
                                'icon' => 'fa-line-chart',
                                'url' => "pollresults.php?course=$course_code&pid=$pid",
                                'show' => $total_participants > 0
                            ),
                            array(
                                'title' => $langSee,
                                'icon' => 'fa-search',
                                'url' => "pollparticipate.php?course=$course_code&amp;UseCase=1&pid=$pid"
                            ),
                            array(
                                'title' => $langCreateDuplicate,
                                'icon' => 'fa-copy',
                                'icon-class' => 'warnLink',
                                'icon-extra' => "data-pid='$pid'",
                                'url' => "#"
                            ),
                            array(
                                'title' => $langPurgeExercises,
                                'icon' => 'fa-eraser',
                                'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;delete_results=yes&amp;pid=$pid",
                                'confirm' => $langConfirmPurgeExercises,
                                'show' => $total_participants > 0
                            ),                                        
                            array(
                                'title' => $langDelete,
                                'icon' => 'fa-times',
                                'class' => 'delete',
                                'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;delete=yes&amp;pid=$pid",
                                'confirm' => $langConfirmDelete                               
                            )                                   
                        ))."</td></tr>";
                } else {
                    $tool_content .= "
                        <td class='text-center'>";
                    if ($has_participated == 0 && $poll_ended == 0 && $poll_not_started == 0) {
                        $tool_content .= "$langHasNotParticipated";
                    } else {
                        if ($poll_ended == 1) {
                            $tool_content .= $langPollHasEnded;
                        } elseif($poll_not_started == 1) {
                            $tool_content .= $langSurveyNotStarted;                           
                        } else {
                            $tool_content .= $langHasParticipated;
                        }
                    }
                    $tool_content .= "</td>";
                    $line_chart_link = ($has_participated && $thepoll->show_results)? "<a href='pollresults.php?course=$course_code&pid=$pid'><span class='fa fa-line-chart'></span></a>" : "<span class='fa fa-line-chart' data-toggle='tooltip' title='$langNoAccessPrivilages'></span>" ;
                    $tool_content .= "<td class='text-center option-btn-cell'><div style='padding-top:7px;padding-bottom:7px;'>$line_chart_link</div></td></tr>";
//                    $tool_content .= "
//                        <td class='text-center option-btn-cell'>" .action_button(array(
//                            array(
//                                'title' => $langUsage,
//                                'icon' => 'fa-line-chart',
//                                'url' => "pollresults.php?course=$course_code&pid=$pid",
//                                'show' => $has_participated
//                            )         
//                        ))."</td></tr>";
                }
            }
            $index_aa ++;
        }
        $tool_content .= "</table></div>";
    }
}
Ejemplo n.º 7
0
/**
 * @brief Print a box with the details of a bbb session
 * @global type $course_id
 * @global type $tool_content
 * @global type $is_editor
 * @global type $langNewBBBSessionStart
 * @global type $langNewBBBSessionType
 * @global type $langConfirmDelete
 * @global type $langNewBBBSessionPublic
 * @global type $langNewBBBSessionPrivate
 * @global type $langBBBSessionJoin
 * @global type $langNewBBBSessionDesc
 * @global type $course_code
 * @global type $langNote
 * @global type $langBBBNoteEnableJoin
 * @global type $langTitle
 * @global type $langActivate
 * @global type $langDeactivate
 * @global type $langModify
 * @global type $langDelete
 */
function bbb_session_details() {
    global $course_id, $tool_content, $is_editor, $course_code, $head_content,
        $langNewBBBSessionStart, $langNewBBBSessionType, $langParticipants,
        $langConfirmDelete, $langNewBBBSessionPublic, $langNewBBBSessionPrivate,
        $langBBBSessionJoin, $langNewBBBSessionDesc, $langNote,
        $langBBBNoteEnableJoin, $langTitle,$langActivate, $langDeactivate,
        $langEditChange, $langDelete, $langNoBBBSesssions, $langDaysLeft, $m,
        $langBBBNotServerAvailableStudent, $langBBBNotServerAvailableTeacher,
        $langBBBImportRecordings;

    load_js('trunk8');

    $myGroups = Database::get()->queryArray("SELECT group_id FROM group_members WHERE user_id=?d", $_SESSION['uid']);

    $activeClause = $is_editor? '': "AND active = '1'";
    $result = Database::get()->queryArray("SELECT * FROM bbb_session
        WHERE course_id = ?s $activeClause ORDER BY start_date DESC", $course_id);
    if (get_total_bbb_servers() == '0') {
        if ($is_editor) {
            $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableTeacher</p>";
        } else {
            $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableStudent</p>";
        }
    } elseif ($result) {
        if (!$is_editor) {
            $tool_content .= "<div class='alert alert-info'><label>$langNote</label>:<br>$langBBBNoteEnableJoin</div>";
        }
        $headingsSent = false;
        $headings = "<div class='row'>
                       <div class='col-md-12'>
                         <div class='table-responsive'>
                           <table class='table-default'>
                             <tr class='list-header'>
                               <th style='width:25%'>$langTitle</th>
                               <th class='text-center'>$langNewBBBSessionDesc</th>
                               <th class='text-center'>$langNewBBBSessionStart</th>
                               <th class='text-center'>$langParticipants</th>
                               <th class='text-center'>".icon('fa-gears')."</th>
                             </tr>";

        define('DAY_MINUTES', 24 * 40);
        foreach ($result as $row) {
            $participants = '';
            // Get participants
            $r_group = explode(",",$row->participants);
            foreach ($r_group as $participant_uid) {
                if ($participants) {
                    $participants .= ', ';
                }
                $participant_uid = str_replace("'", '', $participant_uid);
                if (preg_match('/^_/', $participant_uid)) {
                    $participants .= gid_to_name(str_replace("_", '', $participant_uid));
                } else {
                    $participants .= uid_to_name($participant_uid, 'fullname');
                }
            }
            $participants = "<span class='trunk8'>$participants</span>";
            $id = $row->id;
            $title = $row->title;
            $start_date = $row->start_date;
            $timeLeft = date_diff_in_minutes($start_date, date('Y-m-d H:i:s'));
            $timeLabel = $start_date;
            if ($timeLeft > 0) {
                $timeLabel .= "<br><span class='label label-warning'><small>$langDaysLeft " .
                    format_time_duration($timeLeft * 60) .
                    "</small></span>";
            } elseif (-$timeLeft > DAY_MINUTES) {
                $timeLabel .= "<br><span class='label label-danger'><small>$m[expired]</small></span>";
            }

            // $row->public == '1' ? $type = $langNewBBBSessionPublic: $type = $langNewBBBSessionPrivate;
            $meeting_id = $row->meeting_id;
            $att_pw = $row->att_pw;
            $mod_pw = $row->mod_pw;
            $record = $row->record;
            $desc = isset($row->description)? $row->description: '';

            $canJoin = $row->active == '1' &&
                $timeLeft < $row->unlock_interval &&
                -$timeLeft < DAY_MINUTES &&
                get_total_bbb_servers() <> '0';
            if ($canJoin) {
                if($is_editor)
                {
                    $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;meeting_id=" . urlencode($meeting_id) . "&amp;title=".urlencode($title)."&amp;att_pw=".urlencode($att_pw)."&amp;mod_pw=".urlencode($mod_pw)."&amp;record=$record' target='_blank'>" . q($title) . "</a>";
                }else
                {
                    //$joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;meeting_id=" . urlencode($meeting_id) . "&amp;att_pw=".urlencode($att_pw)."' target='_blank'>" . q($title) . "</a>";
                    $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;meeting_id=" . urlencode($meeting_id) . "&amp;title=".urlencode($title)."&amp;att_pw=".urlencode($att_pw)."&amp;record=$record' target='_blank'>" . q($title) . "</a>";
                }
            } else {
                $joinLink = q($title);
            }

            if ($is_editor) {
                if (!$headingsSent) {
                    $tool_content .= $headings;
                    $headingsSent = true;
                }
                $tool_content .= '<tr' . ($row->active? '': " class='not_visible'") . ">
                    <td class='text-left'>$joinLink</td>
                    <td>$desc</td>
                    <td class='text-center'>$timeLabel</td>
                    <td style='width: 30%'>$participants</td>
                    <td class='option-btn-cell'>".
                        action_button(array(
                            array(  'title' => $langEditChange,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($id) . "&amp;choice=edit",
                                    'icon' => 'fa-edit'),
                            array(  'title' => $langBBBImportRecordings,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($row->id) . "&amp;choice=import_video",
                                    'icon' => "fa-edit"),
                            array(  'title' => $row->active? $langDeactivate : $langActivate,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($row->id) . "&amp;choice=do_".
                                             ($row->active? 'disable' : 'enable'),
                                    'icon' => $row->active ? 'fa-eye': 'fa-eye-slash'),
                            array(  'title' => $langDelete,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($row->id) . "&amp;choice=do_delete",
                                    'icon' => 'fa-times',
                                    'class' => 'delete',
                                    'confirm' => $langConfirmDelete)
                            )) .
                    "</td></tr>";
            } else {
                // Allow access to session only if user is in participant group or session is scheduled for everyone
                $access = false;
                if(!empty($r_group) && count($r_group)>0 && $r_group[0]<>'')
                {
                    foreach ($myGroups as $mg) {
                        if (in_array("'_" . $mg->group_id . "'", $r_group)) {
                            $access = true;
                        }
                }
                }else{
                    $access = true;
                }
                // Always allow access to editor switched to student view
                $access = $access || in_array("'".$_SESSION['uid']."'", $r_group) ||
                    (isset($_SESSION['student_view']) and $_SESSION['student_view'] == $course_code);

                if ($access) {
                    if (!$headingsSent) {
                        $tool_content .= $headings;
                        $headingsSent = true;
                    }
                    $tool_content .= "<tr>
                        <td class='text-center'>$joinLink</td>
                        <td>$desc</td>
                        <td class='text-center'>$timeLabel</td>
                        <td style='width: 30%'>$participants</td>
                        <td class='text-center'>";
                    // Join url will be active only X minutes before scheduled time and if session is visible for users
                    if ($canJoin) {
                        $tool_content .= icon('fa-sign-in', $langBBBSessionJoin,"$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;title=".urlencode($title)."&amp;meeting_id=" . urlencode($meeting_id) . "&amp;att_pw=".urlencode($att_pw)."&amp;record=$record' target='_blank");
                    } else {
                        $tool_content .= "-</td>";
                    }
                    $tool_content .= "</tr>";
                }
            }
        }
        if ($headingsSent) {
            $tool_content .= "</table></div></div></div>";
        }

        if (get_total_bbb_servers() == '0') {
            if ($is_editor) {
                $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableTeacher</p>";
            } else {
                $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableStudent</p>";
            }
        }
        if (!$is_editor and !$headingsSent) {
            $tool_content .= "<div class='alert alert-warning'>$langNoBBBSesssions</div>";
        }
    } else {
        $tool_content .= "<div class='alert alert-warning'>$langNoBBBSesssions</div>";
    }
}
Ejemplo n.º 8
0
 while ($line !== false) {
     $line = canonicalize_whitespace($line);
     if (!empty($line)) {
         $info = explode('|', $line);
         $title = $info[0];
         $prof_uid = null;
         $prof_not_found = false;
         if (isset($info[1])) {
             $prof_info = trim($info[1]);
             $prof_uid = find_prof(trim($info[1]));
             if ($prof_info and !$prof_uid) {
                 $prof_not_found = true;
             }
         }
         if ($prof_uid) {
             $prof_name = uid_to_name($prof_uid);
         } else {
             $prof_name = '';
         }
         list($code, $cid) = create_course('', $_POST['lang'], $title, $departments, $vis, $prof_name, $_POST['password']);
         if ($cid) {
             if ($prof_uid) {
                 Database::get()->query("INSERT INTO course_user\n                                SET course_id = {$cid},\n                                    user_id = {$prof_uid},\n                                    status = 1,\n                                    tutor = 1,\n                                    reg_date = NOW()");
             }
             Database::get()->query("INSERT INTO group_properties SET\n                            course_id = {$cid},\n                            self_registration = 1,\n                            multiple_registration = 0,\n                            forum = 1,\n                            private_forum = 0,\n                            documents = 1,\n                            wiki = 0,\n                            agenda = 0");
             create_modules($cid);
         }
         if ($code) {
             course_index($code);
         }
         $class = $prof_not_found ? 'alert alert-warning' : 'alert alert-success';
Ejemplo n.º 9
0
$head_content .= "<script type='text/javascript'>
        $(function() {
            $('#user_date_start, #user_date_end').datetimepicker({
                format: 'dd-mm-yyyy hh:ii',
                pickerPosition: 'bottom-left',
                language: '".$language."',
                autoclose: true
            });
        });
    </script>";


$u = isset($_GET['u']) ? intval($_GET['u']) : '';

$pageName = "$langUserLog: " . uid_to_name($u);
$navigation[] = array('url' => 'index.php', 'name' => $langAdmin);
$navigation[] = array('url' => 'listusers.php', 'name' => $langListUsers);

if (isset($_POST['user_date_start'])) {    
    $uds = DateTime::createFromFormat('d-m-Y H:i', $_POST['user_date_start']);
    $u_date_start = $uds->format('Y-m-d H:i');    
    $user_date_start = $uds->format('d-m-Y H:i');
} else {
    $date_start = new DateTime();
    $date_start->sub(new DateInterval('P15D'));    
    $u_date_start = $date_start->format('Y-m-d H:i');
    $user_date_start = $date_start->format('d-m-Y H:i');       
}
if (isset($_POST['user_date_end'])) {
    $ude = DateTime::createFromFormat('d-m-Y H:i', $_POST['user_date_end']);    
Ejemplo n.º 10
0
    header("Content-type: text/csv; charset=UTF-16");
    header("Pragma: no-cache");
    header("Expires: 0");

    $bom = "\357\273\277";

    $crlf = "\r\n";
    $output = "$bom$langSurname\t$langName\t$langAm\t$langStart\t$langExerciseDuration\t$langYourTotalScore2$crlf";
    $output .= "$crlf";

    $result = Database::get()->queryArray("SELECT DISTINCT uid FROM `exercise_user_record` WHERE eid = ?d", $exerciseId);

    foreach ($result as $row) {
        $sid = $row->uid;
        $surname = uid_to_name($sid,'surname');
        $name = uid_to_name($sid,'givenname');
        $am = uid_to_am($sid);

        $result2 = Database::get()->queryArray("SELECT DATE_FORMAT(record_start_date, '%Y-%m-%d / %H:%i') AS record_start_date,
			record_end_date, TIME_TO_SEC(TIMEDIFF(record_end_date, record_start_date)) AS time_duration,
			total_score, total_weighting
			FROM `exercise_user_record` WHERE uid = ?d AND eid = ?d", $sid, $exerciseId);
        
        foreach ($result2 as $row2) {
            $output .= csv_escape($surname) . "\t";
            $output .= csv_escape($name) . "\t";
            $output .= csv_escape($am) . "\t";
            $recordStartDate = $row2->record_start_date;
            $output .= csv_escape($recordStartDate) . "\t";
            if ($row2->time_duration == '00:00:00' or empty($row2->time_duration)) { // for compatibility
                $output .= csv_escape($langNotRecorded) . "\t";
Ejemplo n.º 11
0
 } else {
     $out .= "<form method='post' class='form-horizontal' role='form' action='dropbox_submit.php?course=$course_code' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
 }
 //hidden variables needed in case of a reply
 foreach ($msg->recipients as $rec) {
     if ($rec != $uid) {
         $out .= "<input type='hidden' name='recipients[]' value='$rec' />";
     }
 }
 $out .= "
     <fieldset>
     <legend>$langReply</legend>
         <div class='form-group'>
             <label for='senderName' class='col-sm-2 control-label'>$langSender:</label>
             <div class='col-sm-10'>
                 <input name='senderName' type='text' class='form-control' id='senderName' value='" . q(uid_to_name($uid)) . "' disabled>
             </div>
         </div>
         <div class='form-group'>
             <label for='message_title' class='col-sm-2 control-label'>$langSubject:</label>
             <div class='col-sm-10'>
                 <input name='message_title' type='text' class='form-control' id='message_title' value='" .
                     q($langMsgRe . ' ' . $msg->subject) . "'>
             </div>
         </div>
         <div class='form-group'>
             <label for='body' class='col-sm-2 control-label'>$langMessage:</label>
             <div class='col-sm-10'>
                 ".rich_text_editor('body', 4, 20, '')."                            
             </div>
         </div>";
Ejemplo n.º 12
0
     if ($course_id == 0) {
         $out .= "<form method='post' action='dropbox_submit.php' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
         if ($msg->course_id != 0) {
             //thread belonging to a course viewed from the central ui
             $out .= "<input type='hidden' name='course' value='" . course_id_to_code($msg->course_id) . "' />";
         }
     } else {
         $out .= "<form method='post' action='dropbox_submit.php?course={$course_code}' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
     }
     //hidden variables needed in case of a reply
     foreach ($msg->recipients as $rec) {
         if ($rec != $uid) {
             $out .= "<input type='hidden' name='recipients[]' value='{$rec}' />";
         }
     }
     $out .= "<fieldset>\r\n                       <table width='100%' class='table table-bordered'>\r\n                         <caption><b>{$langReply}</b></caption>\r\n                         <tr>\r\n                           <th>{$langSender}:</th>\r\n                           <td>" . q(uid_to_name($uid)) . "</td>\r\n    \t                 </tr>\r\n                         <tr>\r\n                           <th>{$langSubject}:</th>\r\n                           <td><input type='text' name='message_title' value='" . $langMsgRe . $msg->subject . "' /></td>\r\n    \t                 </tr>";
     $out .= "<tr>\r\n                      <th>" . $langMessage . ":</th>\r\n                      <td>" . rich_text_editor('body', 4, 20, '') . "\r\n                        <small><br/>{$langMaxMessageSize}</small></td>\r\n                     </tr>";
     if ($course_id != 0) {
         $out .= "<tr>\r\n                       <th width='120'>{$langFileName}:</th>\r\n                       <td><input type='file' name='file' size='35' />\r\n                       </td>\r\n                     </tr>";
     }
     $out .= "<tr>\r\n    \t               <th>&nbsp;</th>\r\n                       <td class='left'><input class='btn btn-primary' type='submit' name='submit' value='" . q($langSend) . "' />&nbsp;\r\n                          {$langMailToUsers}<input type='checkbox' name='mailing' value='1' checked /></td>\r\n                     </tr>\r\n                   </table>\r\n                 </fieldset>\r\n               </form>\r\n               <p class='right smaller'>{$langMaxFileSize} " . ini_get('upload_max_filesize') . "</p>";
     $out .= "<script type='text/javascript' src='{$urlAppend}js/select2-3.5.1/select2.min.js'></script>\n\r\n                 <script type='text/javascript'>\r\n                        \$(document).ready(function () {\r\n                            \$('#select-recipients').select2();       \r\n                            \$('#selectAll').click(function(e) {\r\n                                e.preventDefault();\r\n                                var stringVal = [];\r\n                                \$('#select-recipients').find('option').each(function(){\r\n                                    stringVal.push(\$(this).val());\r\n                                });\r\n                                \$('#select-recipients').val(stringVal).trigger('change');\r\n                            });\r\n                            \$('#removeAll').click(function(e) {\r\n                                e.preventDefault();\r\n                                var stringVal = [];\r\n                                \$('#select-recipients').val(stringVal).trigger('change');\r\n                            });         \r\n                        });\r\n\r\n                        </script>";
 }
 /******End of Reply Form ********/
 $out .= "</div>";
 $out .= '<script>
           $(function() {
             $("#in_msg_body").find("a").addClass("outtabs");
         
             $(".delete").click(function() {
               if (confirm("' . $langConfirmDelete . '")) {
Ejemplo n.º 13
0
            }
            $answers_table .= "</table>";
            $chart->normalize();
            $tool_content .= $chart->plot();
            $tool_content .= $answers_table;
        } elseif ($theQuestion->qtype == QTYPE_FILL) {
            $answers = Database::get()->queryArray("SELECT answer_text, user_id FROM poll_answer_record\n                                WHERE qid = ?d", $theQuestion->pqid);
            $tool_content .= "<table class='table-default'>\n                    <tbody>\n                    <tr>\n                            <th>{$langUser}</th>\n                            <th>{$langAnswer}</th>\n                    </tr>";
            if ($thePoll->anonymized == 1) {
                $k = 1;
                foreach ($answers as $theAnswer) {
                    $tool_content .= "\n                    <tr>\n                            <td>{$langStudent} {$k}</td>\n                            <td>" . q($theAnswer->answer_text) . "</td>\n                    </tr>";
                    $k++;
                }
            } else {
                $k = 1;
                foreach ($answers as $theAnswer) {
                    $tool_content .= "\n                    <tr " . ($k > 3 ? 'class="hidden_row" style="display:none;"' : '') . ">\n                            <td>" . q(uid_to_name($theAnswer->user_id)) . "</td>\n                            <td>" . q($theAnswer->answer_text) . "</td>\n                    </tr>";
                    $k++;
                }
                if ($k > 4) {
                    $tool_content .= "\n                    <tr>\n                            <td colspan='2'><a href='#' class='trigger_names' data-type='fill' id='show'>{$showall}</a></td>\n                    </tr>";
                }
            }
            $tool_content .= '</tbody></table><br>';
        }
        $tool_content .= "</div></div>";
    }
}
// display page
draw($tool_content, 2, null, $head_content);
Ejemplo n.º 14
0
 }
 if ($course_id == 0 && $type == 'pm') {
     if (!$personal_msgs_allowed) {
         $tool_content .= "<div class='alert alert-warning'>{$langGeneralError}</div>";
         draw($tool_content, 1, null, $head_content);
         exit;
     }
     $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' id='newmsg' method='post' action='dropbox_submit.php' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
 } elseif ($course_id == 0 && $type == 'cm') {
     $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' method='post' action='dropbox_submit.php' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
 } else {
     $type = 'cm';
     //only course messages are allowed in the context of a course
     $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' method='post' action='dropbox_submit.php?course={$course_code}' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
 }
 $tool_content .= "\n\t<fieldset>\n            <div class='form-group'>\n                <label for='title' class='col-sm-2 control-label'>{$langSender}:</label>\n                <div class='col-sm-10'>\n                  <input type='text' class='form-control' value='" . q(uid_to_name($uid)) . "' disabled>\n                </div>\n            </div>";
 if ($type == 'cm' && $course_id == 0) {
     //course message from central interface
     //find user's courses
     $sql = "SELECT course.code code, course.title title\n                FROM course, course_user\n                WHERE course.id = course_user.course_id\n                AND course_user.user_id = ?d\n                ORDER BY title";
     $res = Database::get()->queryArray($sql, $uid);
     $head_content .= "<script type='text/javascript'>\n                            \$(document).on('change','#courseselect',function(){\n                              \$.ajax({\n                                type: 'POST',\n                                dataType: 'json',\n                                url: 'load_recipients.php',\n                                data: {'course' : \$('#courseselect').val() }\n                              }).done(function(data) {\n                                \$('#select-recipients').empty();\n                                if(!(\$.isEmptyObject(data))) {\n                                  \$('#select-recipients').empty();\n                                  \$.each(data, function(key,value){\n                                    if (key.charAt(0) == '_') {\n                                      \$('#select-recipients').prepend('<option value=\\'' + key + '\\'>' + value + '</option>');\n                                    } else {\n                                      \$('#select-recipients').append('<option value=\\'' + key + '\\'>' + value + '</option>');\n                                    }\n                                  });\n                                }\n                                \$('#select-recipients').select2('destroy');\n                                \$('#select-recipients').select2();\n                              });\n                            });\n                          </script>";
     $tool_content .= "\n            <div class='form-group'>\n                <label for='title' class='col-sm-2 control-label'>{$langCourse}:</label>\n                <div class='col-sm-10'>\n                    <select id='courseselect' class='form-control' name='course'>\n                        <option value='-1'>&nbsp;</option>";
     foreach ($res as $course) {
         $tool_content .= "<option value='" . $course->code . "'>" . q($course->title) . "</option>";
     }
     $tool_content .= "    </select>\n                           </div>\n                         </div>";
 }
 $tool_content .= "\n        <div class='form-group'>\n            <label for='title' class='col-sm-2 control-label'>{$langTitle}:</label>\n            <div class='col-sm-10'>\n                <input type='text' class='form-control' name='message_title'>\n            </div>\n        </div>\n        <div class='form-group'>\n            <label for='title' class='col-sm-2 control-label'>{$langMessage}:</label>\n            <div class='col-sm-10'>\n                " . rich_text_editor('body', 4, 20, '') . "\n                <span class='help-block'>{$langMaxMessageSize}</span>\n            </div>\n        </div>";
 if ($course_id != 0 || $type == 'cm' && $course_id == 0) {
     $tool_content .= "\n        <div class='form-group'>\n            <label for='title' class='col-sm-2 control-label'>{$langFileName}:</label>\n            <div class='col-sm-10'>\n                <input type='file' name='file'>\n            </div>\n        </div>";
Ejemplo n.º 15
0
 $crlf;

// display a list of user and their respective progress
$sql = "SELECT U.`surname`, U.`givenname`, U.`id`
		FROM `user` AS U, `course_user` AS CU
		WHERE U.`id`= CU.`user_id`
		AND CU.`course_id` = $course_id
		ORDER BY U.`surname` ASC, U.`givenname` ASC";
$usersList = get_limited_list($sql, 500000);
foreach ($usersList as $user) {
    echo "$crlf";
    $learningPathList = Database::get()->queryArray("SELECT learnPath_id FROM lp_learnPath WHERE course_id = ?d", $course_id);
    $iterator = 1;
    $globalprog = 0;

    foreach ($learningPathList as $learningPath) {
        // % progress
        $prog = get_learnPath_progress($learningPath->learnPath_id, $user->id);
        if ($prog >= 0) {
            $globalprog += $prog;
        }
        $iterator++;
    }
    $total = round($globalprog / ($iterator - 1));
    echo csv_escape(uid_to_name($user->id)) .
    ";" . csv_escape(uid_to_am($user->id)) .
    ";" . csv_escape(user_groups($course_id, $user->id, 'csv')) .
    ";" . $total . "%";
}
echo $crlf;
Ejemplo n.º 16
0
function download_pdf_file($assign, $sub, $auto_judge_scenarios, $auto_judge_scenarios_output)
{
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor(PDF_AUTHOR);
    $pdf->SetTitle('Auto Judge Report');
    $pdf->SetSubject('Auto Judge Report');
    // set default header data
    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
    // set header and footer fonts
    $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    // set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    // set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    // set some language-dependent strings (optional)
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    // add a page
    $pdf->AddPage();
    $report_table = '
    <style>
    table.first{
        width: 100%;
        border-collapse: collapse;
    }

    td {
        font-size: 0.9em;
        border: 1px solid #95CAFF;
        padding: 3px 7px 2px 7px;
    }

     th {
        font-size: 0.9em;
        text-align: center;
        padding-top: 5px;
        padding-bottom: 4px;
        background-color: #3399FF;
        color: #ffffff;
    }

    </style>
    <table class="first">
        <tr>
            <th>Είσοδος</th>
            <th>Έξοδος</th>
            <th>Τελεστής</th>
            <th>Αναμεν. Έξοδος</th>
            <th>Βαρύτητα</th>
            <th >Αποτέλεσμα</th>
        </tr>
     ' . get_table_content($auto_judge_scenarios, $auto_judge_scenarios_output, $assign->max_grade) . '
    </table>';
    $report_details = '
        <style>
    table.first{
        width: 100%;
        border-collapse: collapse;
         vertical-align: center;
    }

    td {
        font-size: 1em;
          border: 1px solid #000000;
        padding: 3px 7px 2px 7px;
         text-align: center;
    }

     th {
        font-size: 1.0em;
        text-align: left;
        padding-top: 5px;
        padding-bottom: 4px;
        background-color: #3399FF;
        color: #ffffff;
        width: 120px;
           border: 1px solid #000000;
    }
    </style>

        <table class="first">
            <tr>
            <th> Μάθημα</th> <td>' . htmlspecialchars(get_course_title(), ENT_QUOTES) . ' </td>
            </tr>
             <tr>
            <th> Εργασία</th> <td> ' . htmlspecialchars($assign->title, ENT_QUOTES) . '</td>
            </tr>
             <tr>
            <th> Εκπαιδευόμενος</th><td> ' . htmlspecialchars(q(uid_to_name($sub->uid)), ENT_QUOTES) . '</td>
            </tr>
             <tr>
            <th> Βαθμός</th> <td>' . htmlspecialchars($sub->grade, ENT_QUOTES) . '/' . htmlspecialchars($assign->max_grade, ENT_QUOTES) . ' </td>
            </tr>
             <tr>
            <th> Κατάταξη</th> <td>' . htmlspecialchars(get_submission_rank($assign->id, $sub->grade, $sub->submission_date), ENT_QUOTES) . '</td>
            </tr>
    </table>';
    $pdf->writeHTML($report_details, true, false, true, false, '');
    $pdf->Ln();
    $pdf->writeHTML($report_table, true, false, true, false, '');
    $pdf->Output('auto_judge_report_' . q(uid_to_name($sub->uid)) . '.pdf', 'D');
}
Ejemplo n.º 17
0
            draw($tool_content, 1, null, $head_content);
            exit;
        }
        $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' id='newmsg' method='post' action='dropbox_submit.php' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
    } elseif ($course_id == 0 && $type == 'cm') {
        $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' method='post' action='dropbox_submit.php' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
    } else {
        $type = 'cm'; //only course messages are allowed in the context of a course
        $tool_content .= "<div class='form-wrapper'><form class='form-horizontal' role='form' method='post' action='dropbox_submit.php?course=$course_code' enctype='multipart/form-data' onsubmit='return checkForm(this)'>";
    }
    $tool_content .= "
	<fieldset>
            <div class='form-group'>
                <label for='title' class='col-sm-2 control-label'>$langSender:</label>
                <div class='col-sm-10'>
                  <input type='text' class='form-control' value='" . q(uid_to_name($uid)) . "' disabled>
                </div>
            </div>";
    if ($type == 'cm' && $course_id == 0) {//course message from central interface
        //find user's courses with dropbox module activated       
        $sql = "SELECT course.code code, course.title title
                FROM course, course_user, course_module
                WHERE course.id = course_user.course_id
                AND course.id = course_module.course_id
                AND course_module.module_id = ?d
                AND course_module.visible = ?d
                AND course_user.user_id = ?d
                ORDER BY title";
        $res = Database::get()->queryArray($sql, MODULE_ID_DROPBOX, 1, $uid);
        
        $head_content .= "<script type='text/javascript'>
Ejemplo n.º 18
0
}
$table_cont = '';
$unknown_users = array();
$result = Database::get()->queryArray("SELECT user_id, ip, date_time FROM logins 
                 WHERE course_id = ?d AND $date_where $user_where
                 ORDER BY date_time DESC", $course_id, $date_terms, $terms);

foreach ($result as $row) {
    $known = false;
    if (isset($users[$row->user_id])) {
        $user = $users[$row->user_id];
        $known = true;
    } elseif (isset($unknown_users[$row->user_id])) {
        $user = $unknown_users[$row->user_id];
    } else {
        $user = uid_to_name($row->user_id);
        if ($user === false) {
            $user = $langAnonymous;
        }
        $unknown_users[$row->user_id] = $user;
    }
    
    $table_cont .= "<td>";
    if ($known) {
        $table_cont .= q($user);
    } else {
        $table_cont .= "<span class='red'>" . q($user) . "</span>";
    }
    $table_cont .= "</td>
                <td align='text-center'>" . $row->ip . "</td>
                <td align='text-center'>" . nice_format($row->date_time, true) . "</td>
Ejemplo n.º 19
0
function create_zip_index($path, $id, $online = FALSE) {
    global $charset, $m, $course_id;

    $fp = fopen($path, "w");
    if (!$fp) {
        die("Unable to create assignment index file - aborting");
    }
    fputs($fp, '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=' . $charset . '">
                <style type="text/css">
                .sep td, th { border: 1px solid; }
                td { border: none; }
                table { border-collapse: collapse; border: 2px solid; }
                .sep { border-top: 2px solid black; }
                </style>
	</head>
	<body>
		<table class="table-default">
			<tr>
				<th>' . $m['username'] . '</th>
				<th>' . $m['am'] . '</th>
				<th>' . $m['filename'] . '</th>
				<th>' . $m['sub_date'] . '</th>
				<th>' . $m['grade'] . '</th>
			</tr>');

    $assign = Database::get()->querySingle("SELECT * FROM assignment WHERE id = ?d", $id);
    if ($assign->grading_scale_id) {
        $serialized_scale_data = Database::get()->querySingle('SELECT scales FROM grading_scale WHERE id = ?d AND course_id = ?d', $assign->grading_scale_id, $course_id)->scales;
        $scales = unserialize($serialized_scale_data);
        $scale_values = array_value_recursive('scale_item_value', $scales);
    }
    $result = Database::get()->queryArray("SELECT a.uid, a.file_path, a.submission_date, a.grade, a.comments, a.grade_comments, a.group_id, b.deadline FROM assignment_submit a, assignment b WHERE a.assignment_id = ?d AND a.assignment_id = b.id ORDER BY a.id", $id);
    foreach ($result as $row) {
        $filename = basename($row->file_path);
        $filelink = empty($filename) ? '&nbsp;' :
                ("<a href='$filename'>" . htmlspecialchars($filename) . '</a>');
        $late_sub_text = ((int) $row->deadline && $row->submission_date > $row->deadline) ?  "<div style='color:red;'>$m[late_submission]</div>" : '';
        if ($assign->grading_scale_id) {
            $key = closest($row->grade, $scale_values, true)['key'];
            $row->grade = $scales[$key]['scale_item_name'];
        }
        fputs($fp, '
			<tr class="sep">
				<td>' . q(uid_to_name($row->uid)) . '</td>
				<td>' . q(uid_to_am($row->uid)) . '</td>
				<td align="center">' . $filelink . '</td>
				<td align="center">' . $row->submission_date .$late_sub_text. '</td>
				<td align="center">' . $row->grade . '</td>
			</tr>');
        if (trim($row->comments != '')) {
            fputs($fp, "
			<tr><td colspan='6'><b>$m[comments]: " .
                    "</b>$row->comments</td></tr>");
        }
        if (trim($row->grade_comments != '')) {
            fputs($fp, "
			<tr><td colspan='6'><b>$m[gradecomments]: " .
                    "</b>$row->grade_comments</td></tr>");
        }
        if (!empty($row->group_id)) {
            fputs($fp, "<tr><td colspan='6'>$m[groupsubmit] " .
                    "$m[ofgroup] $row->group_id</td></tr>\n");
        }
    }
    fputs($fp, ' </table></body></html>');
    fclose($fp);
}
Ejemplo n.º 20
0
            $tool_content .= "<p><b>{$langConfirm}</b></p>";
            $tool_content .= "<ul class='listBullet'>";
            $tool_content .= "<li>{$langYes}: ";
            $tool_content .= "<a href='{$_SERVER['SCRIPT_NAME']}?doit=yes'>{$langDelete}</a>";
            $tool_content .= "</li>";
            $tool_content .= "<li>{$langNo}: <a href='profile/profile.php'>{$langBack}</a>";
            $tool_content .= "</li></ul>";
        } else {
            $tool_content .= action_bar(array(array('title' => $langBack, 'url' => "profile/profile.php", 'icon' => 'fa-reply', 'level' => 'primary-label')));
            $tool_content .= "<div class='alert alert-danger'>{$langNotice}:</br> ";
            $tool_content .= "{$langExplain}</div>";
        }
    }
    //endif is admin
} else {
    if (isset($uid)) {
        $un = uid_to_name($uid, 'username');
        $n = uid_to_name($uid);
        deleteUser($id, false);
        // action logging
        Log::record(0, 0, LOG_DELETE_USER, array('uid' => $uid, 'username' => $un, 'name' => $n));
        unset($_SESSION['uid']);
        $tool_content .= action_bar(array(array('title' => $langLogout, 'url' => "../index.php?logout=yes", 'icon' => 'fa-sign-out', 'level' => 'primary-label')));
        $tool_content .= "<div class='alert alert-success'>{$langDelSuccess}</br>{$langThanks}</div>";
    }
}
if (isset($_SESSION['uid'])) {
    draw($tool_content, 1);
} else {
    draw($tool_content, 0);
}
Ejemplo n.º 21
0
        array('title' => $langBack,
              'url' => "edituser.php?u=$u",
              'icon' => 'fa-reply',
              'level' => 'primary-label'),
        array('title' => $langBackAdmin,
              'url' => "index.php",
              'icon' => 'fa-reply',
              'level' => 'primary-label')));
}

if (isDepartmentAdmin()) {
    validateUserNodes(intval($u), true);
}

$u_account = $u ? q(uid_to_name($u, 'username')) : '';
$u_realname = $u ? q(uid_to_name($u)) : '';
$userdata = user_get_data($u);
$u_status = $userdata->status;

if (!$doit) {
    if ($u_account && $c) {
        $tool_content .= "<div class='alert alert-warning'>$langConfirmDeleteQuestion1 <em>$u_realname ($u_account)</em>
    	$langConfirmDeleteQuestion2 <em>" . q(course_id_to_title($c)) . "</em>
        </div>
        <div class='col-sm-offset-5 btn btn-primary'><a href='$_SERVER[SCRIPT_NAME]?u=$u&amp;c=$c&amp;doit=yes'>$langDelete</a></div>";
    } else {
        $tool_content .= "<div class='alert alert-danger'>$langErrorUnreguser</div>";
    }
   
} else {
    if ($c and $u) {
Ejemplo n.º 22
0
        array('title' => $langBackAdmin,
              'url' => "index.php",
              'icon' => 'fa-reply',
              'level' => 'primary-label')));

// get the incoming values and initialize them
if (isset($_GET['u'])) {
    $user = getDirectReference($_GET['u']);
    $iuid = $_GET['u'];
} else {
    forbidden();
}

if ($user) {
    $u_account = q(uid_to_name($user, 'username'));
    $u_realname = q(uid_to_name($user));
    $u_desc = "<em>$u_realname ($u_account)</em>";
}

if (!isset($_POST['doit'])) {
    if ($user) {
        if (get_admin_rights($user) > 0) {
            $tool_content .= "<div class='alert alert-warning'>" .
                sprintf($langCantDeleteAdmin, $u_desc) . ' ' .
                $langIfDeleteAdmin .
                "</div>";
        } else {
            $tool_content .= "<div class='alert alert-warning'>$langConfirmDeleteQuestion1 $u_desc<br>
                $langConfirmDeleteQuestion3
              </div>
              <form method='post' action='$_SERVER[SCRIPT_NAME]?u=$iuid'>
Ejemplo n.º 23
0
function create_zip_index($path, $id, $online = FALSE)
{
    global $charset, $m;
    $fp = fopen($path, "w");
    if (!$fp) {
        die("Unable to create assignment index file - aborting");
    }
    fputs($fp, '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=' . $charset . '">
                <style type="text/css">
                .sep td, th { border: 1px solid; }
                td { border: none; }
                table { border-collapse: collapse; border: 2px solid; }
                .sep { border-top: 2px solid black; }
                </style>
	</head>
	<body>
		<table width="95%" class="tbl">
			<tr>
				<th>' . $m['username'] . '</th>
				<th>' . $m['am'] . '</th>
				<th>' . $m['filename'] . '</th>
				<th>' . $m['sub_date'] . '</th>
				<th>' . $m['grade'] . '</th>
			</tr>');
    $result = Database::get()->queryArray("SELECT a.uid, a.file_path, a.submission_date, a.grade, a.comments, a.grade_comments, a.group_id, b.deadline FROM assignment_submit a, assignment b WHERE a.assignment_id = ?d AND a.assignment_id = b.id ORDER BY a.id", $id);
    foreach ($result as $row) {
        $filename = basename($row->file_path);
        $filelink = empty($filename) ? '&nbsp;' : "<a href='{$filename}'>" . htmlspecialchars($filename) . '</a>';
        $late_sub_text = (int) $row->deadline && $row->submission_date > $row->deadline ? '<div style="color:red;">$m[late_submission]</div>' : '';
        fputs($fp, '
			<tr class="sep">
				<td>' . q(uid_to_name($row->uid)) . '</td>
				<td>' . q(uid_to_am($row->uid)) . '</td>
				<td align="center">' . $filelink . '</td>
				<td align="center">' . $row->submission_date . $late_sub_text . '</td>
				<td align="center">' . $row->grade . '</td>
			</tr>');
        if (trim($row->comments != '')) {
            fputs($fp, "\n\t\t\t<tr><td colspan='6'><b>{$m['comments']}: " . "</b>{$row->comments}</td></tr>");
        }
        if (trim($row->grade_comments != '')) {
            fputs($fp, "\n\t\t\t<tr><td colspan='6'><b>{$m['gradecomments']}: " . "</b>{$row->grade_comments}</td></tr>");
        }
        if (!empty($row->group_id)) {
            fputs($fp, "<tr><td colspan='6'>{$m['groupsubmit']} " . "{$m['ofgroup']} {$row->group_id}</td></tr>\n");
        }
    }
    fputs($fp, ' </table></body></html>');
    fclose($fp);
}
Ejemplo n.º 24
0
function notify_users($forum_id, $forum_name, $topic_id, $subject, $message, $topic_date) {
    global $logo, $langNewForumNotify, $course_code, $course_code, $course_id, $langForumFrom,
        $uid, $langBodyForumNotify, $langInForums, $urlServer, $langdate, $langSender,
        $langCourse, $langCategory, $langForum, $langSubject, $langNote,
        $langLinkUnsubscribe, $langHere, $charset, $langMailBody;

    $subject_notify = "$logo - $langNewForumNotify";
    $category_id = forum_category($forum_id);
    $cat_name = category_name($category_id);
    $c = course_code_to_title($course_code);
    $name = uid_to_name($uid);
    $title = course_id_to_title($course_id);

    $header_html_topic_notify = "<!-- Header Section -->
    <div id='mail-header'>
        <br>
        <div>
            <div id='header-title'>$langBodyForumNotify <a href='{$urlServer}courses/$course_code'>".q($title)."</a>.</div>
            <ul id='forum-category'>
                <li><span><b>$langCategory:</b></span> <span>" . q($cat_name) . "</span></li>
                <li><span><b>$langForum:</b></span> <span><a href='{$urlServer}modules/forum/viewforum.php?course=$course_code&amp;forum=$forum_id'>" . q($forum_name) . "</a></span></li>
                <li><span><b>$langForumFrom :</b></span> <span>$name</span></li>
                <li><span><b>$langdate:</b></span> <span> $topic_date </span></li>
            </ul>
        </div>
    </div>";
    
    $body_html_topic_notify = "<!-- Body Section -->
    <div id='mail-body'>
        <br>
        <div><b>$langSubject:</b> <span class='left-space'><a href='{$urlServer}modules/forum/viewforum.php?course=$course_code&amp;forum=$forum_id&amp;topic=$topic_id'>" . q($subject) . "</a></span></div><br>
        <div><b>$langMailBody:</b></div>
        <div id='mail-body-inner'>
            $message
        </div>
    </div>";

    $footer_html_topic_notify = "<!-- Footer Section -->
    <div id='mail-footer'>
        <br>
        <div>
            <small>" . sprintf($langLinkUnsubscribe, q($title)) ." <a href='${urlServer}main/profile/emailunsubscribe.php?cid=$course_id'>$langHere</a></small>
        </div>
    </div>";

    $html_topic_notify = $header_html_topic_notify.$body_html_topic_notify.$footer_html_topic_notify;

    $plain_message = html2text($message);
    $plain_topic_notify = "$langBodyForumNotify $langInForums\n" .
       "$langSender: $name\n" .
       "$langCourse: $title\n    {$urlServer}courses/$course_code/\n" .
       "$langCategory: $cat_name\n" .
       "$langForum: $forum_name\n    {$urlServer}modules/forum/viewforum.php?course=$course_code&forum=$forum_id\n" . 
       "$langSubject: $subject\n    {$urlServer}modules/forum/viewforum.php?course=$course_code&forum=$forum_id&topic=$topic_id\n" . 
       "--------------------------------------------\n$plain_message\n" .
       "--------------------------------------------\n" .
       "$langNote: " . canonicalize_whitespace(str_replace('<br />', "\n", sprintf($langLinkUnsubscribe, q($title)))) .
       " $langHere:\n${urlServer}main/profile/emailunsubscribe.php?cid=$course_id\n";

    $users = Database::get()->queryArray("SELECT DISTINCT user_id FROM forum_notify
			WHERE (forum_id = ?d OR cat_id = ?d)
			AND notify_sent = 1 AND course_id = ?d AND user_id != ?d", $forum_id, $category_id, $course_id, $uid);
    $email = array();
    foreach ($users as $user) {
        if (get_user_email_notification($user->user_id, $course_id)) {
            $email[] = uid_to_email($user->user_id);
        }
    }
    send_mail_multipart('', '', '', $email, $subject_notify, $plain_topic_notify, $html_topic_notify, $charset);
}
Ejemplo n.º 25
0
if ($type == 'duration') {    
    $result = user_duration_query($course_id, $u_date_start, $u_date_end, $group_id);
} else {
    $result = Database::get()->queryArray("SELECT user_id AS id FROM group_members WHERE group_id = ?d", $group_id);
}
if (count($result) > 0) {
    foreach ($result as $row) {
        $user_id = $row->id;        
        if ($type == 'duration') {
            $value = format_time_duration(0 + $row->duration);
            $sortkey = $row->duration;
            $name = $row->surname . ' ' . $row->givenname;
            $am = $row->am;
        } elseif ($type == 'lp') {
            $name = uid_to_name($user_id);
            $am = uid_to_am($user_id);
            $iterator = 0;
            $progress = 0;
            foreach ($learningPathList as $learningPath) {
                $progress += get_learnPath_progress($learningPath->learnPath_id, $user_id);
                $iterator++;
            }
            if ($iterator > 0) {
                $total = round($progress / $iterator);
                $sortkey = $total;
                $value = disp_progress_bar($total, 1) . '&nbsp;<small>' . $total . '%</small>';
            } else {
                $value = '&mdash;';
            }
        }
Ejemplo n.º 26
0
 if ($forum_data->cat_id == $cat_id) {
     if ($forum_data->post_time) {
         $last_post = $forum_data->post_time;
         $last_post_datetime = $forum_data->post_time;
         list($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
         list($year, $month, $day) = explode('-', $last_post_date);
         list($hour, $min) = explode(':', $last_post_time);
         $last_post_time = mktime($hour, $min, 0, $month, $day, $year);
         $human_last_post_time = date('d/m/Y -  H:i', $last_post_time);
     }
     if (empty($last_post)) {
         $last_post = $langNoPosts;
     }
     $forum_name = q($forum_data->name);
     if ($forum_data->poster_id) {
         $last_user_post = uid_to_name($forum_data->poster_id);
     } else {
         $last_user_post = '';
     }
     $last_post_topic_id = $forum_data->topic_id;
     $total_posts = $forum_data->num_posts;
     $total_topics = $forum_data->num_topics;
     $desc = q($forum_data->desc);
     $forum_id = $forum_data->id;
     $is_member = false;
     $group_id = init_forum_group_info($forum_id);
     $member = $is_member ? "&nbsp;&nbsp;($langMyGroup)" : '';
     // Show link to forum if:
     //  - user is admin of course
     //  - forum doesn't belong to group
     //  - forum belongs to group and group forums are enabled and
Ejemplo n.º 27
0
 Database::get()->query("DELETE FROM forum_user_stats WHERE user_id = ?d AND course_id = ?d", $uid, $course_id);
 Database::get()->query("INSERT INTO forum_user_stats (user_id, num_posts, course_id) VALUES (?d,?d,?d)", $uid, $forum_user_stats->c, $course_id);
 Database::get()->query("UPDATE forum_topic\n                    SET last_post_id = ?d\n                WHERE id = ?d\n                AND forum_id = ?d", $post_id, $topic_id, $forum_id);
 Database::get()->query("UPDATE forum\n                    SET num_topics = num_topics+1,\n                    num_posts = num_posts+1,\n                    last_post_id = ?d\n\t\tWHERE id = ?d", $post_id, $forum_id);
 $topic = $topic_id;
 $total_forum = get_total_topics($forum_id);
 $total_topic = get_total_posts($topic) - 1;
 // subtract 1 because we want the number of replies, not the number of posts.
 // --------------------------------
 // notify users
 // --------------------------------
 $subject_notify = "{$logo} - {$langNewForumNotify}";
 $category_id = forum_category($forum_id);
 $cat_name = category_name($category_id);
 $c = course_code_to_title($course_code);
 $name = uid_to_name($uid);
 $title = course_id_to_title($course_id);
 $forum_message = "-------- {$langBodyMessage} ({$langSender}: {$name})\n{$message}--------";
 $plain_forum_message = q(html2text($forum_message));
 $body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' \n                               {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' <br /><br />" . q($forum_message) . "<br />\n                               <br />{$gunet}<br /><a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>";
 $plain_body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' \n\n{$plain_forum_message} \n\n{$gunet}\n<a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>";
 $linkhere = "&nbsp;<a href='{$urlServer}main/profile/emailunsubscribe.php?cid={$course_id}'>{$langHere}</a>.";
 $unsubscribe = "<br /><br />{$langNote}: " . sprintf($langLinkUnsubscribe, $title);
 $plain_body_topic_notify .= $unsubscribe . $linkhere;
 $body_topic_notify .= $unsubscribe . $linkhere;
 $sql = Database::get()->queryArray("SELECT DISTINCT user_id FROM forum_notify\n\t\t\tWHERE (forum_id = ?d OR cat_id = ?d)\n\t\t\tAND notify_sent = 1 AND course_id = ?d AND user_id != ?d", $forum_id, $category_id, $course_id, $uid);
 foreach ($sql as $r) {
     if (get_user_email_notification($r->user_id, $course_id)) {
         $emailaddr = uid_to_email($r->user_id);
         send_mail_multipart('', '', '', $emailaddr, $subject_notify, $plain_body_topic_notify, $body_topic_notify, $charset);
     }
Ejemplo n.º 28
0
load_js('bootstrap-datetimepicker');

$head_content .= "<script type='text/javascript'>
        $(function() {
            $('#user_date_expires_at').datetimepicker({
                format: 'dd-mm-yyyy hh:ii',
                pickerPosition: 'bottom-left',
                language: '".$language."',
                autoclose: true
            });
        });
    </script>";

$navigation[] = array('url' => 'index.php', 'name' => $langAdmin);
$navigation[] = array('url' => 'listusers.php', 'name' => $langListUsersActions);
$toolName = "$langEditUser: "******"SELECT surname, givenname, username, password, email,
                              phone, registered_at, expires_at, status, am,
                              verified_mail, whitelist
                         FROM user WHERE id = ?s", $u);
    if (isset($_POST['submit_editauth'])) {
        $auth = intval($_POST['auth']);
        $oldauth = array_search($info->password, $auth_ids);
        $tool_content .= "<div class='alert alert-success'>$langQuotaSuccess.";
Ejemplo n.º 29
0
            $answer_total = 0;
            foreach ($answers as $a) {
                $answer_counts[] = $a->count;
                $answer_total += $a->count;
                if ($a->aid < 0) {
                    $answer_text[] = $langPollUnknown;
                } else {
                    $answer_text[] = $a->answer;
                }
            }
            echo csv_escape($langAnswers), ';', csv_escape($langResults), ' (%)', $crlf;
            foreach ($answer_counts as $i => $count) {
                $percentage = round(100 * ($count / $answer_total));
                $label = $answer_text[$i];
                echo csv_escape($label), ';', csv_escape($count), ';', csv_escape($percentage), $crlf;
            }
            echo $crlf;
        } else {
            // free text questions
            echo csv_escape($q->question_text), $crlf;
            $answers = Database::get()->queryArray("SELECT answer_text, user_id FROM poll_answer_record\n                                                           WHERE qid = ?d", $q->pqid);
            $k = 0;
            foreach ($answers as $a) {
                $k++;
                $student_name = $anonymized ? "{$langStudent} {$k}" : uid_to_name($a->user_id);
                echo csv_escape($student_name), ';', csv_escape($a->answer_text), $crlf;
            }
            echo $crlf;
        }
    }
}
Ejemplo n.º 30
0
$tree = new Hierarchy();
$user = new User();
if (isset($_REQUEST['u'])) {
    $u = intval($_REQUEST['u']);
    $_SESSION['u_tmp'] = $u;
}
if (!isset($_REQUEST['u'])) {
    $u = $_SESSION['u_tmp'];
}
$verified_mail = isset($_REQUEST['verified_mail']) ? intval($_REQUEST['verified_mail']) : 2;
load_js('jstree');
load_js('bootstrap-datetimepicker');
$head_content .= "<script type='text/javascript'>\n        \$(function() {\n            \$('#user_date_expires_at').datetimepicker({\n                format: 'dd-mm-yyyy hh:ii', \n                pickerPosition: 'bottom-left', \n                language: '" . $language . "',\n                autoclose: true    \n            });\n        });\n    </script>";
$navigation[] = array('url' => 'index.php', 'name' => $langAdmin);
$navigation[] = array('url' => 'listusers.php', 'name' => $langListUsersActions);
$toolName = "{$langEditUser}: " . uid_to_name($u);
$u_submitted = isset($_POST['u_submitted']) ? $_POST['u_submitted'] : '';
if ($u) {
    if (isDepartmentAdmin()) {
        validateUserNodes(intval($u), true);
    }
    $info = Database::get()->querySingle("SELECT surname, givenname, username, password, email,\n                              phone, registered_at, expires_at, status, am,\n                              verified_mail, whitelist\n                         FROM user WHERE id = ?s", $u);
    if (isset($_POST['submit_editauth'])) {
        $auth = intval($_POST['auth']);
        $oldauth = array_search($info->password, $auth_ids);
        $tool_content .= "<div class='alert alert-success'>{$langQuotaSuccess}.";
        if ($auth == 1 and $oldauth != 1) {
            $tool_content .= " <a href='password.php?userid={$u}'>{$langEditAuthSetPass}</a>";
            $newpass = '******';
        } else {
            $newpass = $auth_ids[$auth];