Example #1
0
 /**
  * Show this resource
  */
 function show()
 {
     parent::show();
     $extra = api_convert_and_format_date($this->obj->thread_date);
     if ($this->obj->thread_poster_id) {
         $user_info = api_get_user_info($this->obj->thread_poster_id);
         $extra = $user_info['complete_name'] . ', ' . $extra;
     }
     echo $this->obj->thread_title . ' (' . $extra . ')';
 }
 /**
  * Returns a Form validator Obj
  * @todo the form should be auto generated
  * @param   string  url
  * @param   string  action add, edit
  * @return  obj     form validator obj
  */
 public function return_form($url, $action)
 {
     $oFCKeditor = new FCKeditor('description');
     $oFCKeditor->ToolbarSet = 'careers';
     $oFCKeditor->Width = '100%';
     $oFCKeditor->Height = '200';
     $oFCKeditor->Value = '';
     $oFCKeditor->CreateHtml();
     $form = new FormValidator('career', 'post', $url);
     // Setting the form elements
     $header = get_lang('Add');
     if ($action == 'edit') {
         $header = get_lang('Modify');
     }
     $form->addElement('header', $header);
     $id = isset($_GET['id']) ? intval($_GET['id']) : '';
     $form->addElement('hidden', 'id', $id);
     $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
     $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers', 'Width' => '100%', 'Height' => '250'));
     $status_list = $this->get_status_list();
     $form->addElement('select', 'status', get_lang('Status'), $status_list);
     if ($action == 'edit') {
         $form->addElement('text', 'created_at', get_lang('CreatedAt'));
         $form->freeze('created_at');
     }
     if ($action == 'edit') {
         $form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
     } else {
         $form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
     }
     // Setting the defaults
     $defaults = $this->get($id);
     if (!empty($defaults['created_at'])) {
         $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
     }
     if (!empty($defaults['updated_at'])) {
         $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
     }
     $form->setDefaults($defaults);
     // Setting the rules
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
 function return_exercise_block($personal_course_list)
 {
     $exercise_list = array();
     if (!empty($personal_course_list)) {
         foreach ($personal_course_list as $course_item) {
             $course_code = $course_item['c'];
             $session_id = $course_item['id_session'];
             $exercises = ExerciseLib::get_exercises_to_be_taken($course_code, $session_id);
             foreach ($exercises as $exercise_item) {
                 $exercise_item['course_code'] = $course_code;
                 $exercise_item['session_id'] = $session_id;
                 $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC');
                 $exercise_list[] = $exercise_item;
             }
         }
         if (!empty($exercise_list)) {
             $exercise_list = ArrayClass::msort($exercise_list, 'tms');
             $my_exercise = $exercise_list[0];
             $url = Display::url($my_exercise['title'], api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?exerciseId=' . $my_exercise['id'] . '&cidReq=' . $my_exercise['course_code'] . '&id_session=' . $my_exercise['session_id']);
             $this->tpl->assign('exercise_url', $url);
             $this->tpl->assign('exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT));
         }
     }
 }
Example #4
0
 if ($category[0]->is_certificate_available($user_id)) {
     $user = api_get_user_info($user_id);
     $scoredisplay = ScoreDisplay::instance();
     $scorecourse = $category[0]->calc_score($user_id);
     $scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable');
     $cattotal = Category::load(0);
     $scoretotal = $cattotal[0]->calc_score($user_id);
     $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable');
     //prepare all necessary variables:
     $organization_name = api_get_setting('Institution');
     $portal_name = api_get_setting('siteName');
     $stud_fn = $user['firstname'];
     $stud_ln = $user['lastname'];
     $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn . ' ' . $stud_ln, $category[0]->get_name(), $scorecourse_display);
     $certif_text = str_replace("\\n", "\n", $certif_text);
     $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT);
     $pdf = new Cezpdf('a4', 'landscape');
     $pdf->selectFont(api_get_path(LIBRARY_PATH) . 'ezpdf/fonts/Courier.afm');
     $pdf->ezSetMargins(30, 30, 50, 50);
     //line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom)
     $pdf->line(50, 50, 790, 50);
     $pdf->line(50, 550, 790, 550);
     $pdf->ezSetY(450);
     //@todo replace image
     //$pdf->ezImage(api_get_path(SYS_CODE_PATH).'img/dokeos_logo_certif.png',1,400,'','center','');
     $pdf->ezSetY(480);
     $pdf->ezText($certif_text, 28, array('justification' => 'center'));
     //$pdf->ezSetY(750);
     $pdf->ezSetY(50);
     $pdf->ezText($date, 18, array('justification' => 'center'));
     $pdf->ezSetY(580);
Example #5
0
?>
</th>
		<th width="160px"><?php 
echo get_lang('Date');
?>
</th>
	</tr>
<?php 
$sql = "SELECT *, quiz_question.question, firstname, lastname\n        FROM {$TBL_TRACK_ATTEMPT_RECORDING} t, {$TBL_USER}, {$TBL_EXERCICES_QUESTION} quiz_question\n\t\tWHERE   quiz_question.id = question_id AND\n                user_id = author AND\n                exe_id = '" . (int) $_GET['exe_id'] . "'\n        ORDER BY position";
$query = Database::query($sql);
while ($row = Database::fetch_array($query)) {
    echo '<tr';
    if ($i % 2 == 0) {
        echo 'class="row_odd"';
    } else {
        echo 'class="row_even"';
    }
    echo '>';
    echo '<td>' . $row['question'] . '</td>';
    echo '<td>' . $row['marks'] . '</td>';
    if (!empty($row['teacher_comment'])) {
        echo '<td>' . $row['teacher_comment'] . '</td>';
    } else {
        echo '<td>' . get_lang('WithoutComment') . '</td>';
    }
    echo '<td>' . (empty($row['firstname']) && empty($row['lastname']) ? '<i>' . get_lang('OriginalValue') . '</i>' : api_get_person_name($row['firstname'], $row['lastname'])) . '</td>';
    echo '<td>' . api_convert_and_format_date($row['insert_date'], DATE_TIME_FORMAT_LONG) . '</td>';
    echo '</tr>';
}
echo '</table>';
Display::display_footer();
$interbreadcrumb[] = array('url' => $_SESSION['gradebook_dest'] . '?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('Details'));
$interbreadcrumb[] = array('url' => 'gradebook_showlog_eval.php?visiblelog=' . Security::remove_XSS($_GET['visiblelog']) . '&amp;selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('GradebookQualifyLog'));
$this_section = SECTION_COURSES;
Display::display_header('');
echo Display::page_header(get_lang('GradebookQualifyLog'));
$t_linkeval_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
$t_user = Database::get_main_table(TABLE_MAIN_USER);
$visible_log = Security::remove_XSS($_GET['visiblelog']);
$evaledit = Evaluation::load($visible_log);
$sql = "SELECT le.name,le.description,le.weight,le.visible,le.type,le.created_at,us.username FROM " . $t_linkeval_log . " le INNER JOIN " . $t_user . " us\n      ON le.user_id_log=us.user_id where id_linkeval_log=" . $evaledit[0]->get_id() . " and type='evaluation';";
$result = Database::query($sql);
$list_info = array();
while ($row = Database::fetch_row($result)) {
    $list_info[] = $row;
}
foreach ($list_info as $key => $info_log) {
    $list_info[$key][5] = $info_log[5] ? api_convert_and_format_date($info_log[5]) : 'N/A';
    $list_info[$key][3] = $info_log[3] == 1 ? get_lang('GradebookVisible') : get_lang('GradebookInvisible');
}
$parameters = array('visiblelog' => $visible_log, 'selectcat' => intval($_GET['selectcat']));
$table = new SortableTableFromArrayConfig($list_info, 1, 20, 'gradebookeval');
$table->set_additional_parameters($parameters);
$table->set_header(0, get_lang('GradebookNameLog'));
$table->set_header(1, get_lang('GradebookDescriptionLog'));
$table->set_header(2, get_lang('GradebookPreviousWeight'));
$table->set_header(3, get_lang('GradebookVisibilityLog'));
$table->set_header(4, get_lang('ResourceType'));
$table->set_header(5, get_lang('Date'));
$table->set_header(6, get_lang('GradebookWhoChangedItLog'));
$table->display();
Display::display_footer();
Example #7
0
 echo '<a href="viewthread.php?' . api_get_cidreq() . '&amp;forum=' . Security::remove_XSS($my_forum) . '&amp;origin=' . $origin . '&amp;thread=' . $row['thread_id'] . $origin_string . '&amp;search=' . Security::remove_XSS(urlencode($my_search)) . '" ' . class_visible_invisible($row['visibility']) . '>' . prepare4display($row['thread_title']) . '</a></td>';
 echo '<td>' . $row['thread_replies'] . '</td>';
 echo '<td>' . $row['thread_views'] . '</td>';
 // display the author name
 $tab_poster_info = api_get_user_info($row['user_id']);
 $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
 if ($origin != 'learnpath') {
     echo '<td>' . display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']), '', $poster_username) . '</td>';
 } else {
     echo '<td>' . Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title" => api_htmlentities($poster_username, ENT_QUOTES))) . '</td>';
 }
 $last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], is_allowed_to_edit());
 $last_post = null;
 if ($last_post_info) {
     $poster_info = api_get_user_info($last_post_info['poster_id']);
     $post_date = api_convert_and_format_date($last_post_info['post_date']);
     $last_post = $post_date . ' ' . get_lang('By') . ' ' . display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']);
 }
 /*
             if ($row['last_poster_user_id'] == '0') {
                 $name = $row['poster_name'];
                 $last_poster_username = "";
             } else {
                 $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']);
                 $tab_last_poster_info = api_get_user_info($row['last_poster_user_id']);
                 $last_poster_username = sprintf(get_lang('LoginX'), $tab_last_poster_info['username']);
             }
             // If the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread.
             if (($row['visible'] == '1' OR api_is_allowed_to_edit(false, true)) && $origin != 'learnpath') {
                 $last_post = $post_date.' '.get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name, '', $last_poster_username);
             } elseif ($origin != 'learnpath') {
Example #8
0
 $html .= Display::return_icon('post-forum.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
 $html .= ' ' . $number_threads . '<br>' . $newPost . '</div>';
 $html .= '<div class="col-md-6">';
 // The last post in the forum.
 if ($forum['last_poster_name'] != '') {
     $name = $forum['last_poster_name'];
     $poster_id = 0;
     $username = "";
 } else {
     $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
     $poster_id = $forum['last_poster_id'];
     $userinfo = api_get_user_info($poster_id);
     $username = sprintf(get_lang('LoginX'), $userinfo['username']);
 }
 if (!empty($forum['last_post_id'])) {
     $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ' . api_convert_and_format_date($forum['last_post_date']) . '<br /> ' . get_lang('By') . ' ' . display_user_link($poster_id, $name, '', $username);
 }
 $html .= '</div>';
 $html .= '<div class="col-md-4">';
 if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval($sessionId) != 0)) {
     $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
     $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
     $html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility']);
     $html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked']);
     $html .= return_up_down_icon('forum', $forum['forum_id'], $forumsInCategory);
 }
 $iconnotify = 'notification_mail_na.png';
 $session_forum_notification = isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : false;
 if (is_array($session_forum_notification)) {
     if (in_array($forum['forum_id'], $session_forum_notification)) {
         $iconnotify = 'notification_mail.png';
Example #9
0
 /**
  * Gets all the course meetings saved in the plugin_bbb_meeting table
  * @return array Array of current open meeting rooms
  */
 public function getCourseMeetings()
 {
     $pass = $this->getUserMeetingPassword();
     $meetingList = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? ' => array(api_get_course_int_id(), api_get_session_id()))));
     $newMeetingList = array();
     $item = array();
     foreach ($meetingList as $meetingDB) {
         $meetingBBB = $this->getMeetingInfo(array('meetingId' => $meetingDB['remote_id'], 'password' => $pass));
         if ($meetingBBB === false) {
             //checking with the remote_id didn't work, so just in case and
             // to provide backwards support, check with the id
             $params = array('meetingId' => $meetingDB['id'], 'password' => $pass);
             $meetingBBB = $this->getMeetingInfo($params);
         }
         if ($meetingDB['visibility'] == 0 and $this->isTeacher() == false) {
             continue;
         }
         $meetingBBB['end_url'] = api_get_self() . '?' . api_get_cidreq() . '&action=end&id=' . $meetingDB['id'];
         if ((string) $meetingBBB['returncode'] == 'FAILED') {
             if ($meetingDB['status'] == 1 && $this->isTeacher()) {
                 $this->endMeeting($meetingDB['id']);
             }
         } else {
             $meetingBBB['add_to_calendar_url'] = api_get_self() . '?' . api_get_cidreq() . '&action=add_to_calendar&id=' . $meetingDB['id'] . '&start=' . api_strtotime($meetingDB['created_at']);
         }
         $recordArray = array();
         $actionLinksArray = array();
         if ($meetingDB['record'] == 1) {
             // backwards compatibility (when there was no remote ID)
             $mId = $meetingDB['remote_id'];
             if (empty($mId)) {
                 $mId = $meetingDB['id'];
             }
             if (empty($mId)) {
                 // if the id is still empty (should *never* occur as 'id' is
                 // the table's primary key), skip this conference
                 continue;
             }
             $recordingParams = array('meetingId' => $mId);
             //To see the recording list in your BBB server do: bbb-record --list
             $records = $this->api->getRecordingsWithXmlResponseArray($recordingParams);
             if (!empty($records)) {
                 $count = 1;
                 if (isset($records['message']) && !empty($records['message'])) {
                     if ($records['messageKey'] == 'noRecordings') {
                         $recordArray[] = get_lang('NoRecording');
                         if ($meetingDB['visibility'] == 0) {
                             $actionLinksArray[] = Display::url(Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&action=publish&id=' . $meetingDB['id']);
                         } else {
                             $actionLinksArray[] = Display::url(Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&action=unpublish&id=' . $meetingDB['id']);
                         }
                     } else {
                         //$recordArray[] = $records['message'];
                     }
                 } else {
                     foreach ($records as $record) {
                         //if you get several recordings here and you used a
                         // previous version of Chamilo, you might want to
                         // only keep the last result for each chamilo conf
                         // (see show_links after the end of this loop)
                         if (is_array($record) && isset($record['recordId'])) {
                             $url = Display::url(get_lang('ViewRecord') . " [~" . $record['playbackFormatLength'] . "']", $record['playbackFormatUrl'], array('target' => '_blank'));
                             $actionLinks = '';
                             if ($this->isTeacher()) {
                                 $actionLinks .= Display::url(Display::return_icon('link.gif', get_lang('CopyToLinkTool')), api_get_self() . '?' . api_get_cidreq() . '&action=copy_record_to_link_tool&id=' . $meetingDB['id']);
                                 $actionLinks .= Display::url(Display::return_icon('agenda.png', get_lang('AddToCalendar')), api_get_self() . '?' . api_get_cidreq() . '&action=add_to_calendar&id=' . $meetingDB['id'] . '&start=' . api_strtotime($meetingDB['created_at']) . '&url=' . $record['playbackFormatUrl']);
                                 $actionLinks .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_self() . '?' . api_get_cidreq() . '&action=delete_record&id=' . $meetingDB['id']);
                                 if ($meetingDB['visibility'] == 0) {
                                     $actionLinks .= Display::url(Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&action=publish&id=' . $meetingDB['id']);
                                 } else {
                                     $actionLinks .= Display::url(Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&action=unpublish&id=' . $meetingDB['id']);
                                 }
                             }
                             //$url .= api_get_self().'?action=publish&id='.$record['recordID'];
                             $count++;
                             $recordArray[] = $url;
                             $actionLinksArray[] = $actionLinks;
                         } else {
                             /*if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
                             
                                                                 //Fix the bbb timestamp
                                                                 //$record['startTime'] = substr($record['startTime'], 0, strlen($record['startTime']) -3);
                                                                 //$record['endTime']   = substr($record['endTime'], 0, strlen($record['endTime']) -3);
                                                                 //.' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime'])
                                                                 foreach($record['playbacks'] as $item) {
                                                                     $url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank'));
                                                                     //$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']);
                                                                     if ($this->isTeacher()) {
                                                                         $url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meetingDB['id'].'&record_id='.$record['recordID']);
                                                                         $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meetingDB['id'].'&start='.api_strtotime($meetingDB['created_at']).'&url='.$item['url']);
                                                                         $url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordID']);
                                                                     }
                                                                     //$url .= api_get_self().'?action=publish&id='.$record['recordID'];
                                                                     $count++;
                                                                     $recordArray[] = $url;
                                                                 }
                                                             }*/
                         }
                     }
                 }
             } else {
                 $actionLinks = '';
                 if ($this->isTeacher()) {
                     if ($meetingDB['visibility'] == 0) {
                         $actionLinks .= Display::url(Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&action=publish&id=' . $meetingDB['id']);
                     } else {
                         $actionLinks .= Display::url(Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&action=unpublish&id=' . $meetingDB['id']);
                     }
                 }
                 $actionLinksArray[] = $actionLinks;
                 $item['action_links'] = implode('<br />', $actionLinksArray);
             }
             //var_dump($recordArray);
             $item['show_links'] = implode('<br />', $recordArray);
             $item['action_links'] = implode('<br />', $actionLinksArray);
         }
         $item['created_at'] = api_convert_and_format_date($meetingDB['created_at']);
         //created_at
         $meetingDB['created_at'] = $item['created_at'];
         //avoid overwrite in array_merge() below
         $item['publish_url'] = api_get_self() . '?' . api_get_cidreq() . '&action=publish&id=' . $meetingDB['id'];
         $item['unpublish_url'] = api_get_self() . '?' . api_get_cidreq() . '&action=unpublish&id=' . $meetingDB['id'];
         if ($meetingDB['status'] == 1) {
             $joinParams = array('meetingId' => $meetingDB['remote_id'], 'username' => $this->user_complete_name, 'password' => $pass, 'createTime' => '', 'userID' => '', 'webVoiceConf' => '');
             $item['go_url'] = $this->protocol . $this->api->getJoinMeetingURL($joinParams);
         }
         $item = array_merge($item, $meetingDB, $meetingBBB);
         $newMeetingList[] = $item;
     }
     return $newMeetingList;
 }
 /**
  *  Checks if the exercise is visible due a lot of conditions - visibility, time limits, student attempts
  * @return bool true if is active
  */
 public function is_visible($lp_id = 0, $lp_item_id = 0, $lp_item_view_id = 0, $filter_by_admin = true)
 {
     // 1. By default the exercise is visible
     $is_visible = true;
     $message = null;
     // 1.1 Admins and teachers can access to the exercise
     if ($filter_by_admin) {
         if (api_is_platform_admin() || api_is_course_admin()) {
             return array('value' => true, 'message' => '');
         }
     }
     // Deleted exercise.
     if ($this->active == -1) {
         return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
     }
     // Checking visibility in the item_property table.
     $visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
     if ($visibility == 0 || $visibility == 2) {
         $this->active = 0;
     }
     // 2. If the exercise is not active.
     if (empty($lp_id)) {
         // 2.1 LP is OFF
         if ($this->active == 0) {
             return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
         }
     } else {
         // 2.1 LP is loaded
         if ($this->active == 0 && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
             return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
         }
     }
     //3. We check if the time limits are on
     $limit_time_exists = !empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00' || !empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00' ? true : false;
     if ($limit_time_exists) {
         $time_now = time();
         if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
             $is_visible = $time_now - api_strtotime($this->start_time, 'UTC') > 0 ? true : false;
         }
         if ($is_visible == false) {
             $message = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($this->start_time));
         }
         if ($is_visible == true) {
             if ($this->end_time != '0000-00-00 00:00:00') {
                 $is_visible = (api_strtotime($this->end_time, 'UTC') > $time_now) > 0 ? true : false;
                 if ($is_visible == false) {
                     $message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
                 }
             }
         }
         if ($is_visible == false && $this->start_time != '0000-00-00 00:00:00' && $this->end_time != '0000-00-00 00:00:00') {
             $message = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($this->start_time), api_convert_and_format_date($this->end_time));
         }
     }
     // 4. We check if the student have attempts
     $exerciseAttempts = $this->selectAttempts();
     if ($is_visible) {
         if ($exerciseAttempts > 0) {
             $attempt_count = Event::get_attempt_count_not_finished(api_get_user_id(), $this->id, $lp_id, $lp_item_id, $lp_item_view_id);
             if ($attempt_count >= $exerciseAttempts) {
                 $message = sprintf(get_lang('ReachedMaxAttempts'), $this->name, $exerciseAttempts);
                 $is_visible = false;
             }
         }
     }
     if (!empty($message)) {
         $message = Display::return_message($message, 'warning', false);
     }
     return array('value' => $is_visible, 'message' => $message);
 }
Example #11
0
 /**
  * Display the exercise results
  * @param Exercise $objExercise
  * @param int $exe_id
  * @param bool $save_user_result save users results (true) or just show the results (false)
  */
 public static function display_question_list_by_attempt($objExercise, $exe_id, $save_user_result = false)
 {
     global $origin;
     // Getting attempt info
     $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
     // Getting question list
     $question_list = array();
     if (!empty($exercise_stat_info['data_tracking'])) {
         $question_list = explode(',', $exercise_stat_info['data_tracking']);
     } else {
         // Try getting the question list only if save result is off
         if ($save_user_result == false) {
             $question_list = $objExercise->get_validated_question_list();
         }
     }
     $counter = 1;
     $total_score = $total_weight = 0;
     $exercise_content = null;
     // Hide results
     $show_results = false;
     $show_only_score = false;
     if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS) {
         $show_results = true;
     }
     if (in_array($objExercise->results_disabled, array(RESULT_DISABLE_SHOW_SCORE_ONLY, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES))) {
         $show_only_score = true;
     }
     // Not display expected answer, but score, and feedback
     $show_all_but_expected_answer = false;
     if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) {
         $show_all_but_expected_answer = true;
         $show_results = true;
         $show_only_score = false;
     }
     if ($show_results || $show_only_score) {
         $user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
         //Shows exercise header
         echo $objExercise->show_exercise_result_header($user_info, api_convert_and_format_date($exercise_stat_info['start_date'], DATE_TIME_FORMAT_LONG), $exercise_stat_info['duration'], $exercise_stat_info['user_ip']);
     }
     // Display text when test is finished #4074 and for LP #4227
     $end_of_message = $objExercise->selectTextWhenFinished();
     if (!empty($end_of_message)) {
         Display::display_normal_message($end_of_message, false);
         echo "<div class='clear'>&nbsp;</div>";
     }
     $question_list_answers = array();
     $media_list = array();
     $category_list = array();
     // Loop over all question to show results for each of them, one by one
     if (!empty($question_list)) {
         foreach ($question_list as $questionId) {
             // creates a temporary Question object
             $objQuestionTmp = Question::read($questionId);
             // This variable came from exercise_submit_modal.php
             ob_start();
             // We're inside *one* question. Go through each possible answer for this question
             $result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null, 'exercise_result', array(), $save_user_result, true, $show_results, $objExercise->selectPropagateNeg(), array());
             if (empty($result)) {
                 continue;
             }
             // In case of global score, make sure the calculated total score is integer
             /*if (!is_int($result['score'])) {
                   $result['score'] = round($result['score']);
               }*/
             $total_score += $result['score'];
             $total_weight += $result['weight'];
             $question_list_answers[] = array('question' => $result['open_question'], 'answer' => $result['open_answer'], 'answer_type' => $result['answer_type']);
             $my_total_score = $result['score'];
             $my_total_weight = $result['weight'];
             // Category report
             $category_was_added_for_this_test = false;
             if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
                 if (!isset($category_list[$objQuestionTmp->category]['score'])) {
                     $category_list[$objQuestionTmp->category]['score'] = 0;
                 }
                 if (!isset($category_list[$objQuestionTmp->category]['total'])) {
                     $category_list[$objQuestionTmp->category]['total'] = 0;
                 }
                 $category_list[$objQuestionTmp->category]['score'] += $my_total_score;
                 $category_list[$objQuestionTmp->category]['total'] += $my_total_weight;
                 $category_was_added_for_this_test = true;
             }
             if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
                 foreach ($objQuestionTmp->category_list as $category_id) {
                     $category_list[$category_id]['score'] += $my_total_score;
                     $category_list[$category_id]['total'] += $my_total_weight;
                     $category_was_added_for_this_test = true;
                 }
             }
             // No category for this question!
             if ($category_was_added_for_this_test == false) {
                 if (!isset($category_list['none']['score'])) {
                     $category_list['none']['score'] = 0;
                 }
                 if (!isset($category_list['none']['total'])) {
                     $category_list['none']['total'] = 0;
                 }
                 $category_list['none']['score'] += $my_total_score;
                 $category_list['none']['total'] += $my_total_weight;
             }
             if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
                 $my_total_score = 0;
             }
             $comnt = null;
             if ($show_results) {
                 $comnt = Event::get_comments($exe_id, $questionId);
                 if (!empty($comnt)) {
                     echo '<b>' . get_lang('Feedback') . '</b>';
                     echo '<div id="question_feedback">' . $comnt . '</div>';
                 }
             }
             if ($show_results) {
                 $score = array('result' => get_lang('Score') . " : " . self::show_score($my_total_score, $my_total_weight, false, true), 'pass' => $my_total_score >= $my_total_weight ? true : false, 'score' => $my_total_score, 'weight' => $my_total_weight, 'comments' => $comnt);
             } else {
                 $score = array();
             }
             $contents = ob_get_clean();
             $question_content = '';
             if ($show_results) {
                 $question_content = '<div class="question_row_answer">';
                 $show_media = false;
                 /*if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
                       $show_media = true;
                       $media_list[] = $objQuestionTmp->parent_id;
                   }*/
                 //Shows question title an description
                 $question_content .= $objQuestionTmp->return_header(null, $counter, $score);
             }
             $counter++;
             $question_content .= $contents;
             if ($show_results) {
                 $question_content .= '</div>';
             }
             $exercise_content .= $question_content;
         }
         // end foreach() block that loops over all questions
     }
     $total_score_text = null;
     if ($origin != 'learnpath') {
         if ($show_results || $show_only_score) {
             $total_score_text .= '<div class="question_row_score">';
             $total_score_text .= self::get_question_ribbon($objExercise, $total_score, $total_weight, true);
             $total_score_text .= '</div>';
         }
     }
     if (!empty($category_list) && ($show_results || $show_only_score)) {
         //Adding total
         $category_list['total'] = array('score' => $total_score, 'total' => $total_weight);
         echo TestCategory::get_stats_table_by_attempt($objExercise->id, $category_list);
     }
     if ($show_all_but_expected_answer) {
         $exercise_content .= "<div class='normal-message'>" . get_lang("ExerciseWithFeedbackWithoutCorrectionComment") . "</div>";
     }
     // Remove audio auto play from questions on results page - refs BT#7939
     $exercise_content = preg_replace(['/autoplay[\\=\\".+\\"]+/', '/autostart[\\=\\".+\\"]+/'], '', $exercise_content);
     echo $total_score_text;
     echo $exercise_content;
     if (!$show_only_score) {
         echo $total_score_text;
     }
     if ($save_user_result) {
         // Tracking of results
         $learnpath_id = $exercise_stat_info['orig_lp_id'];
         $learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
         $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
         if (api_is_allowed_to_session_edit()) {
             Event::update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $exercise_stat_info['exe_duration'], $question_list, '', array());
         }
         // Send notification ..
         if (!api_is_allowed_to_edit(null, true) && !api_is_excluded_user_type()) {
             if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1) {
                 $objExercise->send_mail_notification_for_exam($question_list_answers, $origin, $exe_id);
             }
             $objExercise->send_notification_for_open_questions($question_list_answers, $origin, $exe_id);
             $objExercise->send_notification_for_oral_questions($question_list_answers, $origin, $exe_id);
         }
     }
 }
 if ($file_type == 'csv') {
     $alldata[] = array('username', 'official_code', 'lastname', 'firstname', 'score', 'date');
 }
 // export results to pdf file
 if ($file_type == 'pdf') {
     $number_decimals = api_get_setting('gradebook_number_decimals');
     $datagen = new ResultsDataGenerator($eval[0], $allresults);
     // set headers pdf
     !empty($_user['official_code']) ? $officialcode = $_user['official_code'] . ' - ' : '';
     $h1 = array(get_lang('Teacher'), $officialcode . $_user['firstName'] . ', ' . $_user['lastName']);
     $h2 = array(get_lang('Score'), $eval[0]->get_max());
     $h3 = array(get_lang('Course'), $_course['name']);
     $h4 = array(get_lang('Weight'), $eval[0]->get_weight());
     $h5 = array(get_lang('Session'), api_get_session_name(api_get_session_id()));
     $date = date('d-m-Y H:i:s', time());
     $h6 = array(get_lang('DateTime'), api_convert_and_format_date($date, "%d/%m/%Y %H:%M"));
     $header_pdf = array($h1, $h2, $h3, $h4, $h5, $h6);
     // set footer pdf
     $f1 = '<hr />' . get_lang('Drh');
     $f2 = '<hr />' . get_lang('Teacher');
     $f3 = '<hr />' . get_lang('Date');
     $footer_pdf = array($f1, $f2, $f3);
     // set title pdf
     $title_pdf = $eval[0]->get_name();
     // set headers data table
     $head_ape_name = '';
     if (api_is_western_name_order()) {
         $head_ape_name = get_lang('FirstName') . ', ' . get_lang('LastName');
     } else {
         $head_ape_name = get_lang('LastName') . ', ' . get_lang('FirstName');
     }
Example #13
0
if ($_GET['selectcat'] != null) {
    $addparams = array('userid' => $my_user_id, 'selectcat' => Security::remove_XSS($_GET['selectcat']));
} else {
    $addparams = array('userid' => $my_user_id, 'selecteval' => Security::remove_XSS($_GET['selecteval']));
}
$user_table = new UserTable($my_user_id, $allevals, $alllinks, $addparams);
if (isset($_GET['exportpdf'])) {
    $datagen = new UserDataGenerator($my_user_id, $allevals, $alllinks);
    $data_array = $datagen->get_data(UserDataGenerator::UDG_SORT_NAME, 0, null, true);
    $newarray = array();
    $displayscore = ScoreDisplay::instance();
    foreach ($data_array as $data) {
        $newarray[] = array_slice($data, 1);
    }
    $userinfo = api_get_user_info($my_user_id);
    $html .= get_lang('Results') . ' : ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']) . ' (' . api_convert_and_format_date(null, DATE_FORMAT_SHORT) . ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) . ')';
    if ($displayscore->is_custom()) {
        $header_names = array(get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'), get_lang('Result'), get_lang('Display'));
    } else {
        $header_names = array(get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'), get_lang('Result'));
    }
    $table = new HTML_Table(array('class' => 'data_table'));
    $row = 0;
    $column = 0;
    foreach ($header_names as $item) {
        $table->setHeaderContents($row, $column, $item);
        $column++;
    }
    $row = 1;
    if (!empty($newarray)) {
        foreach ($newarray as $data) {
 $html .= '<div class="row">';
 $html .= '<div class="col-md-2">';
 $html .= Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL);
 $html .= ' ' . $my_number_threads . '<br>' . $newPost . '</div>';
 // the last post in the forum
 if ($forum['last_poster_name'] != '') {
     $name = $forum['last_poster_name'];
     $poster_id = 0;
 } else {
     $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
     $poster_id = $forum['last_poster_id'];
 }
 $html .= '<div class="col-md-6">';
 if (!empty($forum['last_post_id'])) {
     $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ';
     $html .= api_convert_and_format_date($forum['last_post_date']) . ' ' . get_lang('By') . ' ' . display_user_link($poster_id, $name);
 }
 $html .= '</div>';
 $html .= '<div class="col-md-4">';
 if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && $sessionId != 0)) {
     $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
     $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
     $html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility'], array('forumcategory' => $_GET['forumcategory']));
     $html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked'], array('forumcategory' => $_GET['forumcategory']));
     $html .= return_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
 }
 $iconnotify = 'notification_mail_na.png';
 if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
     if (in_array($forum['forum_id'], $_SESSION['forum_notification']['forum'])) {
         $iconnotify = 'notification_mail.png';
     }
    show_documents($folder);
    //echo "<hr>";
}
/*
-----------------------------------------------------------
	Ad Valvas
-----------------------------------------------------------
*/
if ($content == "Ad_Valvas") {
    $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
    $sql = "SELECT * FROM " . $tbl_announcement . " a, " . $item_property_table . " i  WHERE i.tool = '" . TOOL_ANNOUNCEMENT . "' AND a.id=i.ref AND i.visibility='1' AND i.to_group_id = 0 AND i.to_user_id IS NULL ORDER BY a.display_order ASC";
    $result = Database::query($sql);
    while ($myrow = Database::fetch_array($result)) {
        echo "<table width=\"100%\"><tr><td>";
        echo "<img src='../img/valves.gif' alt='advalvas'>";
        echo api_convert_and_format_date($myrow["end_date"], DATE_FORMAT_LONG, date_default_timezone_get());
        echo "</td></tr><tr><td>";
        echo $myrow["title"] . "<br />";
        showorhide_addresourcelink($content, $myrow["id"]);
        echo "</td></tr></table>";
    }
}
/*
-----------------------------------------------------------
	Forums
-----------------------------------------------------------
*/
if ($content == "Forum") {
    $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
    $TBL_CATAGORIES = Database::get_course_table(TABLE_FORUM_CATEGORY);
    $TBL_FORUMTOPICS = Database::get_course_table(TABLE_FORUM_POST);
Example #16
0
 /**
  * Get registered users' attendance sheet inside current course
  * @param	int	   $attendance_id
  * @param	int	   $user_id for showing data for only one user (optional)
  * @return 	array  users attendance sheet data
  */
 public function get_users_attendance_sheet($attendance_id, $user_id = 0, $groupId = null)
 {
     $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
     $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
     $attendance_calendar = $this->get_attendance_calendar($attendance_id, 'all', null, $groupId);
     $calendar_ids = array();
     // get all dates from calendar by current attendance
     foreach ($attendance_calendar as $cal) {
         $calendar_ids[] = $cal['id'];
     }
     $course_id = api_get_course_int_id();
     $data = array();
     if (empty($user_id)) {
         // get all registered users inside current course
         $users = $this->get_users_rel_course();
         $user_ids = array_keys($users);
         if (count($calendar_ids) > 0 && count($user_ids) > 0) {
             foreach ($user_ids as $uid) {
                 $sql = "SELECT * FROM {$tbl_attendance_sheet}\n\t\t\t\t\t        WHERE\n\t\t\t\t\t        \tc_id = {$course_id} AND\n\t\t\t\t\t        \tuser_id = '{$uid}' AND\n\t\t\t\t\t        \tattendance_calendar_id IN(" . implode(',', $calendar_ids) . ")\n\t\t\t\t\t\t\t";
                 $res = Database::query($sql);
                 if (Database::num_rows($res) > 0) {
                     while ($row = Database::fetch_array($res)) {
                         $data[$uid][$row['attendance_calendar_id']]['presence'] = $row['presence'];
                     }
                 }
             }
         }
     } else {
         // Get attendance for current user
         $user_id = intval($user_id);
         if (count($calendar_ids) > 0) {
             $sql = "SELECT cal.date_time, att.presence\n                        FROM {$tbl_attendance_sheet} att\n\t\t\t\t\t\tINNER JOIN  {$tbl_attendance_calendar} cal\n\t\t\t\t\t\tON cal.id = att.attendance_calendar_id\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tatt.c_id = {$course_id} AND\n\t\t\t\t\t\t\tcal.c_id =  {$course_id} AND\n\t\t\t\t\t\t\tatt.user_id = '{$user_id}' AND\n\t\t\t\t\t\t\tatt.attendance_calendar_id IN (" . implode(',', $calendar_ids) . ")\n                        ORDER BY date_time";
             $res = Database::query($sql);
             if (Database::num_rows($res) > 0) {
                 while ($row = Database::fetch_array($res)) {
                     $row['date_time'] = api_convert_and_format_date($row['date_time'], null, date_default_timezone_get());
                     $data[$user_id][] = $row;
                 }
             }
         }
     }
     return $data;
 }
Example #17
0
 if ($counter == 1) {
     echo Display::page_subheader($name);
 }
 echo "<div " . $style . "><table class=\"data_table\">";
 if ($row['visible'] == '0') {
     $titleclass = 'forum_message_post_title_2_be_approved';
     $messageclass = 'forum_message_post_text_2_be_approved';
     $leftclass = 'forum_message_left_2_be_approved';
 } else {
     $titleclass = 'forum_message_post_title';
     $messageclass = 'forum_message_post_text';
     $leftclass = 'forum_message_left';
 }
 echo "<tr>";
 echo "<td rowspan=\"3\" class=\"{$leftclass}\">";
 echo '<br /><b>' . api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_LONG) . '</b><br />';
 if (api_is_allowed_to_edit(null, true)) {
     echo $url_post;
 }
 echo "</td>";
 // The post title
 echo "<td class=\"{$titleclass}\">" . prepare4display($row['post_title']) . "</td>";
 echo "</tr>";
 // The post message
 echo "<tr >";
 echo "<td class=\"{$messageclass}\">" . prepare4display($row['post_text']) . "</td>";
 echo "</tr>";
 // The check if there is an attachment
 $attachment_list = getAllAttachment($row['post_id']);
 if (!empty($attachment_list)) {
     foreach ($attachment_list as $attachment) {
    /**
     * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
     * @return string  content html
     */
    public function get_content_html()
    {
        $content = '';
        $sessions = $this->sessions;
        //$content = '<div style="margin:10px;">';
        $content .= '<h4>' . get_lang('YourSessionsList') . '</h4>';
        if (count($sessions) > 0) {
            $sessions_table = '<table class="data_table" width:"95%">';
            $sessions_table .= '<tr>
									<th >' . get_lang('Title') . '</th>
									<th >' . get_lang('Date') . '</th>
									<th width="100px">' . get_lang('NbCoursesPerSession') . '</th>
								</tr>';
            $i = 1;
            foreach ($sessions as $session) {
                $session_id = intval($session['id']);
                $title = $session['name'];
                if ($session['access_start_date'] != '0000-00-00 00:00:00' && $session['access_end_date'] != '0000-00-00 00:00:00') {
                    $date = get_lang('From') . ' ' . api_convert_and_format_date($session['access_start_date'], DATE_FORMAT_SHORT, date_default_timezone_get()) . ' ' . get_lang('To') . ' ' . api_convert_and_format_date($session['access_end_date'], DATE_FORMAT_SHORT, date_default_timezone_get());
                } else {
                    $date = ' - ';
                }
                $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));
                if ($i % 2 == 0) {
                    $class_tr = 'row_odd';
                } else {
                    $class_tr = 'row_even';
                }
                $sessions_table .= '<tr class="' . $class_tr . '">
										<td>' . $title . '</td>
										<td align="center">' . $date . '</td>
										<td align="center">' . $count_courses_in_session . '</td>
								   </tr>';
                $i++;
            }
            $sessions_table .= '</table>';
            $content .= $sessions_table;
        } else {
            $content .= get_lang('ThereIsNoInformationAboutYourSessions');
        }
        if (count($sessions) > 0) {
            $content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/session.php">' . get_lang('SeeMore') . '</a></div>';
        }
        //$content .= '</div>';
        return $content;
    }
        $show_announcement_list = true;
    } else {
        $form->display();
        $show_announcement_list = false;
    }
}
if ($show_announcement_list) {
    $announcements = SystemAnnouncementManager::get_all_announcements();
    $announcement_data = array();
    foreach ($announcements as $index => $announcement) {
        $row = array();
        $row[] = $announcement->id;
        $row[] = Display::return_icon($announcement->visible ? 'accept.png' : 'exclamation.png', $announcement->visible ? get_lang('AnnouncementAvailable') : get_lang('AnnouncementNotAvailable'));
        $row[] = $announcement->title;
        $row[] = api_convert_and_format_date($announcement->date_start);
        $row[] = api_convert_and_format_date($announcement->date_end);
        $row[] = "<a href=\"?id=" . $announcement->id . "&person=" . SystemAnnouncementManager::VISIBLE_TEACHER . "&action=" . ($announcement->visible_teacher ? 'make_invisible' : 'make_visible') . "\">" . Display::return_icon($announcement->visible_teacher ? 'eyes.png' : 'eyes-close.png', get_lang('ShowOrHide')) . "</a>";
        $row[] = "<a href=\"?id=" . $announcement->id . "&person=" . SystemAnnouncementManager::VISIBLE_STUDENT . "&action=" . ($announcement->visible_student ? 'make_invisible' : 'make_visible') . "\">" . Display::return_icon($announcement->visible_student ? 'eyes.png' : 'eyes-close.png', get_lang('ShowOrHide')) . "</a>";
        $row[] = "<a href=\"?id=" . $announcement->id . "&person=" . SystemAnnouncementManager::VISIBLE_GUEST . "&action=" . ($announcement->visible_guest ? 'make_invisible' : 'make_visible') . "\">" . Display::return_icon($announcement->visible_guest ? 'eyes.png' : 'eyes-close.png', get_lang('ShowOrHide')) . "</a>";
        $row[] = $announcement->lang;
        $row[] = "<a href=\"?action=edit&id=" . $announcement->id . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a> <a href=\"?action=delete&id=" . $announcement->id . "\"  onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>";
        $announcement_data[] = $row;
    }
    $table = new SortableTableFromArray($announcement_data);
    $table->set_header(0, '', false);
    $table->set_header(1, get_lang('Active'));
    $table->set_header(2, get_lang('Title'));
    $table->set_header(3, get_lang('StartTimeWindow'));
    $table->set_header(4, get_lang('EndTimeWindow'));
    $table->set_header(5, get_lang('Teacher'));
    $table->set_header(6, get_lang('Student'));
Example #20
0
 /**
  * Return all content to replace and all content to be replace
  * @param int $user_id
  * @param int $course_id
  * @param bool $is_preview
  * @return array
  */
 static function get_all_info_to_certificate($user_id, $course_id, $is_preview = false)
 {
     $info_list = array();
     $user_id = intval($user_id);
     $course_info = api_get_course_info($course_id);
     //info portal
     $organization_name = api_get_setting('platform.institution');
     $portal_name = api_get_setting('platform.site_name');
     // Extra user data information
     $extra_user_info_data = UserManager::get_extra_user_data($user_id, false, false, false, true);
     // get extra fields
     $extraField = new ExtraField('user');
     $extraFields = $extraField->get_all(['filter = ? AND visible = ?' => [1, 1]]);
     //Student information
     $user_info = api_get_user_info($user_id);
     $first_name = $user_info['firstname'];
     $last_name = $user_info['lastname'];
     $official_code = $user_info['official_code'];
     //Teacher information
     $info_teacher_id = UserManager::get_user_id_of_course_admin_or_session_admin($course_info);
     $teacher_info = api_get_user_info($info_teacher_id);
     $teacher_first_name = $teacher_info['firstname'];
     $teacher_last_name = $teacher_info['lastname'];
     // info gradebook certificate
     $info_grade_certificate = UserManager::get_info_gradebook_certificate($course_id, $user_id);
     $date_certificate = $info_grade_certificate['created_at'];
     $date_long_certificate = '';
     $date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY);
     if (!empty($date_certificate)) {
         $date_long_certificate = api_convert_and_format_date($date_certificate);
         $date_no_time = api_convert_and_format_date($date_certificate, DATE_FORMAT_LONG_NO_DAY);
     }
     if ($is_preview) {
         $date_long_certificate = api_convert_and_format_date(api_get_utc_datetime());
         $date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY);
     }
     $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $info_grade_certificate['id'];
     //replace content
     $info_to_replace_in_content_html = array($first_name, $last_name, $organization_name, $portal_name, $teacher_first_name, $teacher_last_name, $official_code, $date_long_certificate, $date_no_time, $course_id, $course_info['name'], $info_grade_certificate['grade'], $url, '<a href="' . $url . '" target="_blank">' . get_lang('CertificateOnlineLink') . '</a>', '((certificate_barcode))');
     $info_to_be_replaced_in_content_html = array('((user_firstname))', '((user_lastname))', '((gradebook_institution))', '((gradebook_sitename))', '((teacher_firstname))', '((teacher_lastname))', '((official_code))', '((date_certificate))', '((date_certificate_no_time))', '((course_code))', '((course_title))', '((gradebook_grade))', '((certificate_link))', '((certificate_link_html))', '((certificate_barcode))');
     if (!empty($extraFields)) {
         foreach ($extraFields as $extraField) {
             $valueExtra = isset($extra_user_info_data[$extraField['variable']]) ? $extra_user_info_data[$extraField['variable']] : '';
             $info_to_be_replaced_in_content_html[] = '((' . strtolower($extraField['variable']) . '))';
             $info_to_replace_in_content_html[] = $valueExtra;
         }
     }
     $info_list[] = $info_to_be_replaced_in_content_html;
     $info_list[] = $info_to_replace_in_content_html;
     return $info_list;
 }
Example #21
0
 /**
  * Refreshes the chat windows (usually called every x seconds through AJAX)
  * @return void (prints JSON array of chat windows)
  */
 public function heartbeat()
 {
     $to_user_id = api_get_user_id();
     $sql = "SELECT * FROM " . $this->table . "\n                WHERE to_user = '******' AND ( recd  = 0 )\n                ORDER BY id ASC";
     $result = Database::query($sql);
     $chat_list = array();
     while ($chat = Database::fetch_array($result, 'ASSOC')) {
         $chat_list[$chat['from_user']]['items'][] = $chat;
     }
     $items = array();
     foreach ($chat_list as $from_user_id => $rows) {
         $rows = $rows['items'];
         $user_info = api_get_user_info($from_user_id, true);
         //Cleaning tsChatBoxes
         unset($_SESSION['tsChatBoxes'][$from_user_id]);
         foreach ($rows as $chat) {
             $chat['message'] = Security::remove_XSS($chat['message']);
             $item = array('s' => '0', 'f' => $from_user_id, 'm' => $chat['message'], 'username' => $user_info['complete_name'], 'id' => $chat['id']);
             $items[$from_user_id]['items'][] = $item;
             $items[$from_user_id]['user_info']['user_name'] = $user_info['complete_name'];
             $items[$from_user_id]['user_info']['online'] = $user_info['user_is_online'];
             $items[$from_user_id]['user_info']['avatar'] = $user_info['avatar_small'];
             $_SESSION['openChatBoxes'][$from_user_id] = api_strtotime($chat['sent'], 'UTC');
         }
         $_SESSION['chatHistory'][$from_user_id]['items'][] = $item;
         $_SESSION['chatHistory'][$from_user_id]['user_info']['user_name'] = $user_info['complete_name'];
         $_SESSION['chatHistory'][$from_user_id]['user_info']['online'] = $user_info['user_is_online'];
         $_SESSION['chatHistory'][$from_user_id]['user_info']['avatar'] = $user_info['avatar_small'];
     }
     if (!empty($_SESSION['openChatBoxes'])) {
         foreach ($_SESSION['openChatBoxes'] as $user_id => $time) {
             if (!isset($_SESSION['tsChatBoxes'][$user_id])) {
                 $now = time() - $time;
                 $time = api_convert_and_format_date($time, DATE_TIME_FORMAT_SHORT_TIME_FIRST);
                 $message = sprintf(get_lang('SentAtX'), $time);
                 if ($now > 180) {
                     $item = array('s' => '2', 'f' => $user_id, 'm' => $message);
                     if (isset($_SESSION['chatHistory'][$user_id])) {
                         $_SESSION['chatHistory'][$user_id]['items'][] = $item;
                     }
                     $_SESSION['tsChatBoxes'][$user_id] = 1;
                 }
             }
         }
     }
     $sql = "UPDATE " . $this->table . " SET recd = 1\n                WHERE to_user = '******' AND recd = 0";
     Database::query($sql);
     if ($items != '') {
         //$items = substr($items, 0, -1);
     }
     echo json_encode(array('items' => $items));
 }
Example #22
0
 /**
  * Gets information about messages sent
  * @param  integer
  * @param  integer
  * @param  string
  * @return array
  */
 public static function get_message_data_sent($from, $number_of_items, $column, $direction)
 {
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     if (!isset($direction)) {
         $column = 3;
         $direction = 'DESC';
     } else {
         $column = intval($column);
         if (!in_array($direction, array('ASC', 'DESC'))) {
             $direction = 'ASC';
         }
     }
     $table_message = Database::get_main_table(TABLE_MESSAGE);
     $request = api_is_xml_http_request();
     $sql = "SELECT\n                    id as col0, user_sender_id as col1, title as col2, send_date as col3, user_receiver_id as col4, msg_status as col5\n                FROM {$table_message}\n                WHERE\n                    user_sender_id=" . api_get_user_id() . " AND\n                    msg_status=" . MESSAGE_STATUS_OUTBOX . "\n                ORDER BY col{$column} {$direction}\n                LIMIT {$from}, {$number_of_items}";
     $sql_result = Database::query($sql);
     $i = 0;
     $message_list = array();
     while ($result = Database::fetch_row($sql_result)) {
         if ($request === true) {
             $message[0] = '<input type="checkbox" value=' . $result[0] . ' name="out[]">';
         } else {
             $message[0] = $result[0];
         }
         $class = 'class = "read"';
         $result[2] = Security::remove_XSS($result[2]);
         if ($request === true) {
             $userInfo = api_get_user_info($result[4]);
             $message[1] = '<a onclick="show_sent_message(' . $result[0] . ')" href="javascript:void(0)">' . $userInfo['complete_name'] . '</a>';
             $message[2] = '<a onclick="show_sent_message(' . $result[0] . ')" href="javascript:void(0)">' . str_replace("\\", "", $result[2]) . '</a>';
             $message[3] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG);
             //date stays the same
             $message[4] = '&nbsp;&nbsp;<a onclick="delete_one_message_outbox(' . $result[0] . ')" href="javascript:void(0)"  >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>';
         } else {
             $link = '';
             if (isset($_GET['f']) && $_GET['f'] == 'social') {
                 $link = '&f=social';
             }
             $userInfo = api_get_user_info($result[4]);
             $message[1] = '<a ' . $class . ' onclick="show_sent_message (' . $result[0] . ')" href="../messages/view_message.php?id_send=' . $result[0] . $link . '">' . $result[2] . '</a><br />' . $userInfo['complete_name'];
             //$message[2] = '<a '.$class.' onclick="show_sent_message ('.$result[0].')" href="../messages/view_message.php?id_send='.$result[0].$link.'">'.$result[2].'</a>';
             $message[2] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG);
             //date stays the same
             $message[3] = '<a href="outbox.php?action=deleteone&id=' . $result[0] . '&' . $link . '"  onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmDeleteMessage'))) . "'" . ')) return false;" >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>';
         }
         foreach ($message as $key => $value) {
             $message[$key] = $value;
         }
         $message_list[] = $message;
         $i++;
     }
     return $message_list;
 }
         break;
     case "week":
         $sql = "SELECT access_date\n                        FROM {$TABLETRACK_ACCESS}\n                        WHERE access_user_id = {$uInfo}\n                        AND c_id = {$courseId}\n                        AND WEEK(access_date) = WEEK( FROM_UNIXTIME('{$reqdate}') )\n                        AND YEAR(access_date) = YEAR(FROM_UNIXTIME('{$reqdate}'))\n                        GROUP BY DAYOFMONTH(access_date)\n                        ORDER BY access_date ASC";
         $weeklowreqdate = $reqdate - 86400 * date("w", $reqdate);
         $weekhighreqdate = $reqdate + 86400 * (6 - date("w", $reqdate));
         $displayedDate = get_lang('From') . " " . date("d ", $weeklowreqdate) . $MonthsLong[date("n", $weeklowreqdate) - 1] . date(" Y", $weeklowreqdate) . " " . get_lang('To') . " " . date("d ", $weekhighreqdate) . $MonthsLong[date("n", $weekhighreqdate) - 1] . date(" Y", $weekhighreqdate);
         break;
 }
 echo "<tr><td>";
 $results = StatsUtils::getManyResults1Col($sql);
 /*             * * display of the displayed period  ** */
 echo "<table width='100%' cellpadding='2' cellspacing='1' border='0' align=center>";
 echo "<td bgcolor='#E6E6E6'>" . $displayedDate . "</td>";
 if (is_array($results)) {
     for ($j = 0; $j < sizeof($results); $j++) {
         $beautifulDateTime = api_convert_and_format_date($results[$j], null, date_default_timezone_get());
         echo "<tr>";
         echo "<td style='padding-left : 40px;' valign='top'>" . $beautifulDateTime . "</td>";
         echo "</tr>";
         // $limit is used to select only results between $results[$j] (current login) and next one
         if ($j == sizeof($results) - 1) {
             $limit = date("Y-m-d H:i:s", $nextReqDate);
         } else {
             $limit = $results[$j + 1];
         }
         // select all access to tool between displayed date and next displayed date or now() if
         // displayed date is the last login date
         $sql = "SELECT access_tool, count(access_tool)\n                        FROM {$TABLETRACK_ACCESS}\n                        WHERE access_user_id = {$uInfo}\n                            AND access_tool IS NOT NULL\n                            AND access_date > '" . $results[$j] . "'\n                            AND access_date < '" . $limit . "'\n                            AND c_id = {$courseId}\n                        GROUP BY access_tool\n                        ORDER BY access_tool ASC";
         $results2 = StatsUtils::getManyResults2Col($sql);
         if (is_array($results2)) {
             echo "<tr><td colspan='2'>\n";
Example #24
0
                        }
                        if (!empty($session_id)) {
                            //If I'm a coach
                            $coaches = CourseManager::get_coach_list_from_course_code($course_info['real_id'], $session_id);
                            if (isset($coaches) && isset($coaches[$user_id])) {
                                $user_info = api_get_user_info($user_id);
                                $description .= '<tr><td>' . get_lang('Coach') . ': </td><td class="highlight">' . $user_info['complete_name'] . '</td>';
                            } else {
                                //If not show everything
                                $teachers = CourseManager::get_coach_list_from_course_code_to_string($course_info['real_id'], $session_id);
                                if (!empty($teachers)) {
                                    $description .= '<tr><td>' . get_lang('Coachs') . ': </td><td class="highlight">' . $coaches . '</td>';
                                }
                            }
                        }
                        $description .= '<tr><td>' . get_lang('Date') . ': </td><td class="highlight">' . api_convert_and_format_date(time(), DATE_TIME_FORMAT_LONG) . '</td>';
                        $description .= '</table>';
                        $header_attributes = array(array('style' => 'width:10px'), array('style' => 'width:30px'), array('style' => 'width:50px'), array('style' => 'width:500px'));
                        $params = array('add_signatures' => false, 'filename' => get_lang('UserList'), 'pdf_title' => get_lang('StudentList'), 'pdf_description' => $description, 'header_attributes' => $header_attributes);
                        Export::export_table_pdf($a_users, $params);
                        exit;
                }
        }
    }
}
// end if allowed to edit
if (api_is_allowed_to_edit(null, true)) {
    // Unregister user from course
    if (isset($_REQUEST['unregister']) && $_REQUEST['unregister']) {
        if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $_GET['user_id'] != $_user['user_id']) {
            $user_id = Database::escape_string($_GET['user_id']);
echo $filterForm;
if (count($certificate_list) == 0) {
    echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else {
    echo '<br /><br /><table class="data_table">';
    foreach ($certificate_list as $index => $value) {
        echo '<tr>
                <td width="100%" class="actions">' . get_lang('Student') . ' : ' . api_get_person_name($value['firstname'], $value['lastname']) . ' (' . $value['username'] . ')</td>';
        echo '</tr>';
        echo '<tr><td>
            <table class="data_table">';
        $list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id);
        foreach ($list_certificate as $value_certificate) {
            echo '<tr>';
            echo '<td width="50%">' . get_lang('Score') . ' : ' . $value_certificate['score_certificate'] . '</td>';
            echo '<td width="30%">' . get_lang('Date') . ' : ' . api_convert_and_format_date($value_certificate['created_at']) . '</td>';
            echo '<td width="20%">';
            $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $value_certificate['id'];
            $certificates = Display::url(get_lang('Certificate'), $url, array('target' => '_blank', 'class' => 'btn btn-default'));
            echo $certificates;
            echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token=' . $token . '&cidReq=' . $course_code . '&action=delete&cat_id=' . $cat_id . '&certificate_id=' . $value_certificate['id'] . '">
                    ' . Display::return_icon('delete.png', get_lang('Delete')) . '
                  </a>';
            echo '</td></tr>';
        }
        echo '</table>';
        echo '</td></tr>';
    }
    echo '</table>';
}
Display::display_footer();
Example #26
0
 /**
  * This functions gets all replys to a post, threaded.
  *
  * @param Integer $current
  * @param Integer $current_level
  * @param Integer $blog_id
  * @param Integer $post_id
  */
 public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
 {
     // Init
     $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
     $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
     global $charset, $dateFormatLong;
     $course_id = api_get_course_int_id();
     // Select top level comments
     $next_level = $current_level + 1;
     $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color\n\t\t\t\t\tFROM {$tbl_blogs_comments} comments\n\t\t\t\t\t\tINNER JOIN {$tbl_users} user ON comments.author_id = user.user_id\n\t\t\t\t\t\tLEFT JOIN {$tbl_blogs_tasks} task ON comments.task_id = task.task_id AND task.c_id = {$course_id}\n\t\t\t\t\tWHERE \tcomments.c_id = {$course_id} AND\n\t\t\t\t\t\t\tparent_comment_id = {$current} AND\n\t\t\t\t\t\t\tcomments.blog_id = '" . (int) $blog_id . "' AND\n\t\t\t\t\t\t\tcomments.post_id = '" . (int) $post_id . "'";
     $result = Database::query($sql);
     while ($comment = Database::fetch_array($result)) {
         // Select the children recursivly
         $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username FROM {$tbl_blogs_comments} comments\n\t\t\t\t\tINNER JOIN {$tbl_users} user ON comments.author_id = user.user_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tcomments.c_id = {$course_id} AND\n\t\t\t\t\t\tcomment_id = {$current}\n\t\t\t\t\t\tAND blog_id = '" . (int) $blog_id . "'\n\t\t\t\t\t\tAND post_id = '" . (int) $post_id . "'";
         $tmp = Database::query($tmp);
         $tmp = Database::fetch_array($tmp);
         $parent_cat = $tmp['parent_comment_id'];
         $border_color = '';
         // Prepare data
         $comment_text = make_clickable(stripslashes($comment['comment']));
         $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
         $blog_comment_actions = "";
         if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) {
             $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_comment&comment_id=' . $comment['comment_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
         }
         if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) {
             $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']);
         }
         if (!is_null($comment['task_id'])) {
             $border_color = ' border-left: 3px solid #' . $comment['color'];
         }
         $comment_text = stripslashes($comment_text);
         // Output...
         $margin = $current_level * 30;
         echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
         echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: ' . addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >' . stripslashes($comment['title']) . '</a></span>';
         echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
         echo '<span class="blogpost_text">' . $comment_text . '</span>';
         $file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']);
         if (!empty($file_name_array)) {
             echo '<br /><br />';
             echo Display::return_icon('attachment.gif', get_lang('Attachment'));
             echo '<a href="download.php?file=';
             echo $file_name_array['path'];
             echo ' "> ' . $file_name_array['filename'] . ' </a>';
             echo '<span class="attachment_comment">';
             echo $file_name_array['comment'];
             echo '</span><br />';
         }
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
         echo '<span class="blogpost_comment_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title' => $username)) . ' - ' . get_lang('Rating') . ': ' . Blog::display_rating('comment', $blog_id, $comment['comment_id']) . $rating_select . '</span>';
         echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
         echo '</div>';
         // Go further down the tree.
         Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
     }
 }
Example #27
0
/**
 * This function retrieves all the personal agenda items and add them to the agenda items found by the other functions.
 */
function get_personal_agenda_items($user_id, $agendaitems, $day = "", $month = "", $year = "", $week = "", $type)
{
    $tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
    $user_id = intval($user_id);
    // 1. creating the SQL statement for getting the personal agenda items in MONTH view
    if ($type == "month_view" or $type == "") {
        // we are in month view
        $sql = "SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' and MONTH(date)='" . $month . "' AND YEAR(date) = '" . $year . "'  ORDER BY date ASC";
    }
    // 2. creating the SQL statement for getting the personal agenda items in WEEK view
    // we are in week view
    if ($type == "week_view") {
        $start_end_day_of_week = calculate_start_end_of_week($week, $year);
        $start_day = $start_end_day_of_week['start']['day'];
        $start_month = $start_end_day_of_week['start']['month'];
        $start_year = $start_end_day_of_week['start']['year'];
        $end_day = $start_end_day_of_week['end']['day'];
        $end_month = $start_end_day_of_week['end']['month'];
        $end_year = $start_end_day_of_week['end']['year'];
        // in sql statements you have to use year-month-day for date calculations
        $start_filter = $start_year . "-" . $start_month . "-" . $start_day . " 00:00:00";
        $start_filter = api_get_utc_datetime($start_filter);
        $end_filter = $end_year . "-" . $end_month . "-" . $end_day . " 23:59:59";
        $end_filter = api_get_utc_datetime($end_filter);
        $sql = " SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' AND date>='" . $start_filter . "' AND date<='" . $end_filter . "'";
    }
    // 3. creating the SQL statement for getting the personal agenda items in DAY view
    if ($type == "day_view") {
        // we are in day view
        // we could use mysql date() function but this is only available from 4.1 and higher
        $start_filter = $year . "-" . $month . "-" . $day . " 00:00:00";
        $start_filter = api_get_utc_datetime($start_filter);
        $end_filter = $year . "-" . $month . "-" . $day . " 23:59:59";
        $end_filter = api_get_utc_datetime($end_filter);
        $sql = " SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' AND date>='" . $start_filter . "' AND date<='" . $end_filter . "'";
    }
    $result = Database::query($sql);
    while ($item = Database::fetch_array($result, 'ASSOC')) {
        $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
        $item['date'] = api_get_local_time($item['date']);
        $item['start_date_tms'] = api_strtotime($item['date']);
        $item['content'] = $item['text'];
        // we break the date field in the database into a date and a time part
        $agenda_db_date = explode(" ", $item['date']);
        $date = $agenda_db_date[0];
        $time = $agenda_db_date[1];
        // we divide the date part into a day, a month and a year
        $agendadate = explode("-", $item['date']);
        $year = intval($agendadate[0]);
        $month = intval($agendadate[1]);
        $day = intval($agendadate[2]);
        // we divide the time part into hour, minutes, seconds
        $agendatime = explode(":", $time);
        $hour = $agendatime[0];
        $minute = $agendatime[1];
        $second = $agendatime[2];
        if ($type == 'month_view') {
            $item['calendar_type'] = 'personal';
            $item['start_date'] = $item['date'];
            $agendaitems[$day][] = $item;
            continue;
        }
        // if the student has specified a course we a add a link to that course
        if ($item['course'] != "") {
            $url = api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?cidReq=" . urlencode($item['course']) . "&amp;day={$day}&amp;month={$month}&amp;year={$year}#{$day}";
            // RH  //Patrick Cool: to highlight the relevant agenda item
            $course_link = "<a href=\"{$url}\" title=\"" . $item['course'] . "\">" . $item['course'] . "</a>";
        } else {
            $course_link = "";
        }
        // Creating the array that will be returned. If we have week or month view we have an array with the date as the key
        // if we have a day_view we use a half hour as index => key 33 = 16h30
        if ($type !== "day_view") {
            // This is the array construction for the WEEK or MONTH view
            //Display events in agenda
            $agendaitems[$day] .= "<div><i>{$time_minute}</i> {$course_link} <a href=\"myagenda.php?action=view&amp;view=personal&amp;day={$day}&amp;month={$month}&amp;year={$year}&amp;id=" . $item['id'] . "#" . $item['id'] . "\" class=\"personal_agenda\">" . $item['title'] . "</a></div><br />";
        } else {
            // this is the array construction for the DAY view
            $halfhour = 2 * $agendatime['0'];
            if ($agendatime['1'] >= '30') {
                $halfhour = $halfhour + 1;
            }
            //Display events by list
            $agendaitems[$halfhour] .= "<div><i>{$time_minute}</i> {$course_link} <a href=\"myagenda.php?action=view&amp;view=personal&amp;day={$day}&amp;month={$month}&amp;year={$year}&amp;id=" . $item['id'] . "#" . $item['id'] . "\" class=\"personal_agenda\">" . $item['title'] . "</a></div>";
        }
    }
    return $agendaitems;
}
Example #28
0
 /**
  * Displays the student publications for a specific user in a specific course.
  * @todo remove globals
  */
 public function display_student_publications_tracking_info($view, $user_id, $course_id)
 {
     global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
     $_course = api_get_course_info();
     $user_id = intval($user_id);
     $course_id = intval($course_id);
     if (substr($view, 2, 1) == '1') {
         $sql = "SELECT u.upload_date, w.title, w.author, w.url\n                    FROM {$TABLETRACK_UPLOADS} u , {$TABLECOURSE_WORK} w\n                    WHERE\n                        u.upload_work_id = w.id AND\n                        u.upload_user_id = '{$user_id}' AND\n                        u.c_id = '{$course_id}'\n                    ORDER BY u.upload_date DESC";
         $results = StatsUtils::getManyResultsXCol($sql, 4);
         $title[1] = get_lang('WorksDetails');
         $line = '';
         $title_line = get_lang('WorkTitle') . ";" . get_lang('WorkAuthors') . ";" . get_lang('Date') . "\n";
         if (is_array($results)) {
             for ($j = 0; $j < count($results); $j++) {
                 $pathToFile = api_get_path(WEB_COURSE_PATH) . $_course['path'] . "/" . $results[$j][3];
                 $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
                 $line .= $results[$j][1] . ";" . $results[$j][2] . ";" . $beautifulDate . "\n";
             }
         } else {
             $line = get_lang('NoResult');
         }
     }
     return array($title_line, $line);
 }
 /**
  * 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');
     }
 }
    /**
     * @param $visible
     * @param $id
     * @param int $start
     * @param string $user_id
     * @return string
     */
    public static function display_all_announcements($visible, $id = -1, $start = 0, $user_id = '')
    {
        $user_selected_language = api_get_interface_language();
        $start = intval($start);
        $userGroup = new UserGroup();
        $tbl_announcement_group = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
        $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0);
        $groups = array();
        foreach ($temp_user_groups as $user_group) {
            $groups = array_merge($groups, array($user_group['id']));
            $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id']));
        }
        // Checks if tables exists to not break platform not updated
        $groups_string = '(' . implode($groups, ',') . ')';
        $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
        $now = api_get_utc_datetime();
        $sql = "SELECT * FROM " . $db_table . "\n\t\t\t\tWHERE\n\t\t\t\t    (lang = '{$user_selected_language}' OR lang IS NULL) AND\n\t\t\t\t    ( '{$now}' >= date_start AND '{$now}' <= date_end) ";
        switch ($visible) {
            case self::VISIBLE_GUEST:
                $sql .= " AND visible_guest = 1 ";
                break;
            case self::VISIBLE_STUDENT:
                $sql .= " AND visible_student = 1 ";
                break;
            case self::VISIBLE_TEACHER:
                $sql .= " AND visible_teacher = 1 ";
                break;
        }
        if (count($groups) > 0) {
            $sql .= " OR id IN (\n                    SELECT announcement_id FROM {$tbl_announcement_group}\n                    WHERE group_id in {$groups_string}\n                    ) ";
        }
        if (api_is_multiple_url_enabled()) {
            $current_access_url_id = api_get_current_access_url_id();
            $sql .= " AND access_url_id IN ('1', '{$current_access_url_id}')";
        }
        if (!isset($_GET['start']) || $_GET['start'] == 0) {
            $sql .= " ORDER BY date_start DESC LIMIT " . $start . ",20";
        } else {
            $sql .= " ORDER BY date_start DESC LIMIT " . ($start + 1) . ",20";
        }
        $announcements = Database::query($sql);
        $content = '';
        if (Database::num_rows($announcements) > 0) {
            $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']);
            $query_string = ereg_replace('&$', '', $query_string);
            $url = api_get_self();
            $content .= '<div class="system_announcements">';
            $content .= '<h3>' . get_lang('SystemAnnouncements') . '</h3>';
            $content .= '<table align="center">';
            $content .= '<tr>';
            $content .= '<td>';
            $content .= SystemAnnouncementManager::display_arrow($user_id);
            $content .= '</td>';
            $content .= '</tr>';
            $content .= '</table>';
            $content .= '<table align="center" border="0" width="900px">';
            while ($announcement = Database::fetch_object($announcements)) {
                $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG);
                $content .= '<tr><td>';
                $content .= '<a name="' . $announcement->id . '"></a>
						<div class="system_announcement">
						<h2>' . $announcement->title . '</h2><div class="system_announcement_date">' . $display_date . '</div>
						<br />
					  	<div class="system_announcement_content">' . $announcement->content . '
						</div>
					  </div><br />';
                $content .= '</tr></td>';
            }
            $content .= '</table>';
            $content .= '<table align="center">';
            $content .= '<tr>';
            $content .= '<td>';
            $content .= SystemAnnouncementManager::display_arrow($user_id);
            $content .= '</td>';
            $content .= '</tr>';
            $content .= '</table>';
            $content .= '</div>';
        }
        return $content;
    }