/**
  * Sets the surveylist and the plainsurveylist
  */
 public function __construct()
 {
     // Database table definitions
     $table_survey = Database::get_course_table(TABLE_SURVEY);
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     // searching
     $search_restriction = SurveyUtil::survey_search_restriction();
     if ($search_restriction) {
         $search_restriction = ' AND ' . $search_restriction;
     }
     $course_id = api_get_course_int_id();
     $sql = "SELECT\n                    survey.survey_id,\n                    survey.parent_id,\n                    survey_version,\n                    survey.code as name\n\t\t\t\tFROM {$table_survey} survey\n\t\t\t\tLEFT JOIN {$table_survey_question}  survey_question\n\t\t\t\tON survey.survey_id = survey_question.survey_id , {$table_user} user\n\t\t\t\tWHERE\n\t\t\t\t\tsurvey.c_id \t\t\t=  {$course_id} AND\n\t\t\t\t\tsurvey_question.c_id \t=  {$course_id} AND\n\t\t\t\t\tsurvey.author \t\t\t= user.user_id\n\t\t\t\tGROUP BY survey.survey_id";
     $res = Database::query($sql);
     $surveys_parents = array();
     $refs = array();
     $list = array();
     $plain_array = array();
     while ($survey = Database::fetch_array($res, 'ASSOC')) {
         $plain_array[$survey['survey_id']] = $survey;
         $surveys_parents[] = $survey['survey_version'];
         $thisref =& $refs[$survey['survey_id']];
         $thisref['parent_id'] = $survey['parent_id'];
         $thisref['name'] = $survey['name'];
         $thisref['id'] = $survey['survey_id'];
         $thisref['survey_version'] = $survey['survey_version'];
         if ($survey['parent_id'] == 0) {
             $list[$survey['survey_id']] =& $thisref;
         } else {
             $refs[$survey['parent_id']]['children'][$survey['survey_id']] =& $thisref;
         }
     }
     $this->surveylist = $list;
     $this->plainsurveylist = $plain_array;
 }
Example #2
0
                $row = Database::fetch_array($result, 'ASSOC');
                $option_value = $row['value'];
                //$option_value = 0;
                $survey_question_answer = $value;
                // We save the answer after making sure that a possible previous attempt is deleted
                SurveyUtil::remove_answer(
                    $survey_invitation['user'],
                    $survey_invitation['survey_id'],
                    $survey_question_id,
                    $course_id
                );

                SurveyUtil::store_answer(
                    $survey_invitation['user'],
                    $survey_invitation['survey_id'],
                    $survey_question_id,
                    $value,
                    $option_value,
                    $survey_data
                );
            }
        }
    } else {
        // In case it's another type than 0 or 1
        die(get_lang('ErrorSurveyTypeUnknown'));
    }
}

// Displaying the survey title and subtitle (appears on every page)
echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>';
echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
Example #3
0
    if (in_array($_GET['message'], array('SurveyUpdatedSuccesfully', 'SurveyCreatedSuccesfully'))) {
        Display::display_confirmation_message(get_lang($message_information) . ', ' . PHP_EOL . api_strtolower(get_lang('YouCanNowAddQuestionToYourSurvey')));
    }
    // We have added a question
    if (in_array($_GET['message'], array('QuestionAdded', 'QuestionUpdated'))) {
        Display::display_confirmation_message(get_lang($message_information));
    }
    if (in_array($_GET['message'], array('YouNeedToCreateGroups'))) {
        Display::display_warning_message(get_lang($message_information), false);
    }
}
if (!empty($survey_data['survey_version'])) {
    echo '<b>' . get_lang('Version') . ': ' . $survey_data['survey_version'] . '</b>';
}
// We exit here is the first or last question is a pagebreak (which causes errors)
SurveyUtil::check_first_last_question($_GET['survey_id']);
// Action links
$survey_actions = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/create_new_survey.php?' . api_get_cidreq() . '&amp;action=edit&amp;survey_id=' . $survey_id . '">' . Display::return_icon('edit.png', get_lang('EditSurvey'), '', ICON_SIZE_MEDIUM) . '</a>';
$survey_actions .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidreq() . '&amp;action=delete&amp;survey_id=' . $survey_id . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('DeleteSurvey') . '?', ENT_QUOTES)) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('DeleteSurvey'), '', ICON_SIZE_MEDIUM) . '</a>';
//$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>';
$survey_actions .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/preview.php?' . api_get_cidreq() . '&amp;survey_id=' . $survey_id . '">' . Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM) . '</a>';
$survey_actions .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invite.php?' . api_get_cidreq() . '&amp;survey_id=' . $survey_id . '">' . Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_MEDIUM) . '</a>';
$survey_actions .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?' . api_get_cidreq() . '&amp;survey_id=' . $survey_id . '">' . Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '<div class="actions">' . $survey_actions . '</div>';
if ($survey_data['survey_type'] == 0) {
    echo '<div class="actionsbig">';
    echo '<a style="padding-left:0px;" href="' . api_get_path(WEB_CODE_PATH) . 'survey/question.php?' . api_get_cidreq() . '&amp;action=add&type=yesno&amp;survey_id=' . $survey_id . '">' . Display::return_icon('yesno.gif', get_lang('YesNo')) . '</a>';
    echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/question.php?' . api_get_cidreq() . '&amp;action=add&type=multiplechoice&amp;survey_id=' . $survey_id . '">' . Display::return_icon('mcua.gif', get_lang('UniqueSelect')) . '<br /></a>';
    echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/question.php?' . api_get_cidreq() . '&amp;action=add&type=multipleresponse&amp;survey_id=' . $survey_id . '">' . Display::return_icon('mcma.gif', get_lang('MultipleResponse')) . '</a>';
    echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/question.php?' . api_get_cidreq() . '&amp;action=add&type=open&amp;survey_id=' . $survey_id . '">' . Display::return_icon('open_answer.gif', get_lang('Open')) . '<br /></a>';
    echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/question.php?' . api_get_cidreq() . '&amp;action=add&type=dropdown&amp;survey_id=' . $survey_id . '">' . Display::return_icon('dropdown.gif', get_lang('Dropdown')) . '<br /></a>';
Example #4
0
 /**
  * This function gets all the survey data that is to be displayed in the sortable table
  *
  * @param int $from
  * @param int $number_of_items
  * @param int $column
  * @param string $direction
  * @param bool $isDrh
  * @return unknown
  *
  * @author Patrick Cool <*****@*****.**>, Ghent University
  * @author Julio Montoya <*****@*****.**>, Beeznest - Adding intvals
  * @version January 2007
  */
 static function get_survey_data($from, $number_of_items, $column, $direction, $isDrh = false)
 {
     $table_survey = Database::get_course_table(TABLE_SURVEY);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $_user = api_get_user_info();
     // Searching
     $search_restriction = SurveyUtil::survey_search_restriction();
     if ($search_restriction) {
         $search_restriction = ' AND ' . $search_restriction;
     }
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $column = intval($column);
     if (!in_array(strtolower($direction), array('asc', 'desc'))) {
         $direction = 'asc';
     }
     // Condition for the session
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id);
     $course_id = api_get_course_int_id();
     $sql = "SELECT\n\t\t\t\t\tsurvey.survey_id AS col0,\n\t\t\t\t\tsurvey.title AS col1,\n\t\t\t\t\tsurvey.code AS col2,\n\t\t\t\t\tcount(survey_question.question_id) AS col3,\n\t\t\t\t\t" . (api_is_western_name_order() ? "CONCAT(user.firstname, ' ', user.lastname)" : "CONCAT(user.lastname, ' ', user.firstname)") . "\tAS col4,\n\t\t\t\t\tsurvey.avail_from AS col5,\n\t\t\t\t\tsurvey.avail_till AS col6,\n\t\t\t\t\tsurvey.invited AS col7,\n\t\t\t\t\tsurvey.anonymous AS col8,\n\t\t\t\t\tsurvey.survey_id AS col9,\n\t\t\t\t\tsurvey.session_id AS session_id,\n\t\t\t\t\tsurvey.answered,\n\t\t\t\t\tsurvey.invited\n\t\t\t\t FROM {$table_survey} survey\n                    LEFT JOIN {$table_survey_question} survey_question\n                    ON (survey.survey_id = survey_question.survey_id AND survey_question.c_id = {$course_id})\n                    LEFT JOIN {$table_user} user\n                    ON (survey.author = user.user_id)\n\t\t\t\t WHERE survey.c_id = {$course_id}\n\t\t\t\t {$search_restriction}\n\t\t\t\t {$condition_session} ";
     $sql .= " GROUP BY survey.survey_id";
     $sql .= " ORDER BY col{$column} {$direction} ";
     $sql .= " LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $surveys = array();
     $array = array();
     while ($survey = Database::fetch_array($res)) {
         $array[0] = $survey[0];
         $array[1] = Display::url($survey[1], api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . $survey[0] . '&' . api_get_cidreq());
         // Validation when belonging to a session
         $session_img = api_get_session_image($survey['session_id'], $_user['status']);
         $array[2] = $survey[2] . $session_img;
         $array[3] = $survey[3];
         $array[4] = $survey[4];
         $array[5] = $survey[5];
         $array[6] = $survey[6];
         $array[7] = Display::url($survey['answered'], api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=answered&survey_id=' . $survey[0] . '&' . api_get_cidreq()) . ' / ' . Display::url($survey['invited'], api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=invited&survey_id=' . $survey[0] . '&' . api_get_cidreq());
         $array[8] = $survey[8];
         $array[9] = $survey[9];
         if ($isDrh) {
             $array[1] = $survey[1];
             $array[7] = strip_tags($array[7]);
         }
         $surveys[] = $array;
     }
     return $surveys;
 }
Example #5
0
<?php

/* For licensing terms, see /license.txt */
//require_once '../inc/global.inc.php';
$survey_id = isset($_REQUEST['i']) ? intval($_REQUEST['i']) : null;
if (empty($survey_id)) {
    api_not_allowed(true);
}
if (!survey_manager::survey_generation_hash_available()) {
    api_not_allowed(true);
}
$course_info = api_get_course_info_by_id($_REQUEST['c']);
$hash_is_valid = survey_manager::validate_survey_hash($survey_id, $_REQUEST['c'], $_REQUEST['s'], $_REQUEST['g'], $_REQUEST['h']);
if ($hash_is_valid && $course_info) {
    $survey_data = survey_manager::get_survey($survey_id, null, $course_info['code']);
    $invitation_code = api_get_unique_id();
    $params = array('c_id' => $_REQUEST['c'], 'session_id' => $_REQUEST['s'], 'user' => $invitation_code, 'survey_code' => $survey_data['code'], 'invitation_code' => $invitation_code, 'invitation_date' => api_get_utc_datetime());
    $invitation_id = SurveyUtil::save_invitation($params);
    if ($invitation_id) {
        $link = api_get_path(WEB_CODE_PATH) . 'survey/fillsurvey.php?invitationcode=' . $invitation_code . '&course=' . $course_info['code'];
        header('Location: ' . $link);
        exit;
    }
} else {
    api_not_allowed(true);
}
Example #6
0
            $tool_name = get_lang('DetailedReportByUser');
            break;
        case 'comparativereport':
            $tool_name = get_lang('ComparativeReport');
            break;
        case 'completereport':
            $tool_name = get_lang('CompleteReport');
            break;
    }
}

// Displaying the header
Display::display_header($tool_name, 'Survey');

// Action handling
SurveyUtil::handle_reporting_actions($survey_data, $people_filled);

// Actions bar
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'">'.
    Display::return_icon('back.png', get_lang('BackToSurvey'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';

// Content
if (!isset($_GET['action']) ||
    isset($_GET['action']) &&
    $_GET['action'] == 'overview'
) {
    $myweb_survey_id = $survey_id;
    echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=questionreport&amp;survey_id='.$myweb_survey_id.'&'.api_get_cidreq().'">'.
        Display::return_icon('survey_reporting_question.gif',get_lang('DetailedReportByQuestion')).' '.get_lang('DetailedReportByQuestion').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByQuestionDetail').' </div>';
    $defaults['parent_id'] = 0;
}
if (isset($survey_data['survey_type']) && $survey_data['survey_type'] == 1 || $_GET['action'] == 'add') {
    $form->addElement('checkbox', 'one_question_per_page', null, get_lang('OneQuestionPerPage'));
    $form->addElement('checkbox', 'shuffle', null, get_lang('ActivateShuffle'));
}
$input_name_list = null;
if (isset($_GET['action']) && $_GET['action'] == 'edit' && !empty($survey_id)) {
    if ($survey_data['anonymous'] == 0) {
        $form->addElement('checkbox', 'show_form_profile', null, get_lang('ShowFormProfile'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
        if ($survey_data['show_form_profile'] == 1) {
            $form->addElement('html', '<div id="options_field" style="display:block">');
        } else {
            $form->addElement('html', '<div id="options_field" style="display:none">');
        }
        $field_list = SurveyUtil::make_field_list();
        if (is_array($field_list)) {
            // TODO hide and show the list in a fancy DIV
            foreach ($field_list as $key => &$field) {
                if ($field['visibility'] == 1) {
                    $form->addElement('checkbox', 'profile_' . $key, ' ', '&nbsp;&nbsp;' . $field['name']);
                    $input_name_list .= 'profile_' . $key . ',';
                }
            }
            // Necessary to know the fields
            $form->addElement('hidden', 'input_name_list', $input_name_list);
            // Set defaults form fields
            if ($survey_data['form_fields']) {
                $form_fields = explode('@', $survey_data['form_fields']);
                foreach ($form_fields as &$field) {
                    $field_value = explode(':', $field);
Example #8
0
 /**
  * Returns the "what's new" icon notifications
  *
  * The general logic of this function is to track the last time the user
  * entered the course and compare to what has changed inside this course
  * since then, based on the item_property table inside this course. Note that,
  * if the user never entered the course before, he will not see notification
  * icons. This function takes session ID into account (if any) and only shows
  * the corresponding notifications.
  * @param array     Course information array, containing at least elements 'db' and 'k'
  * @return string   The HTML link to be shown next to the course
  */
 public static function show_notification($course_info)
 {
     $t_track_e_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
     $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
     $tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $course_code = Database::escape_string($course_info['code']);
     $user_id = api_get_user_id();
     $course_id = $course_info['real_id'];
     $course_info['id_session'] = intval($course_info['id_session']);
     // Get the user's last access dates to all tools of this course
     $sql = "SELECT *\n                FROM {$t_track_e_access} USE INDEX (access_cours_code, access_user_id)\n                WHERE\n                    access_cours_code = '" . $course_code . "' AND\n                    access_user_id = '{$user_id}' AND\n                    access_session_id ='" . $course_info['id_session'] . "'";
     $resLastTrackInCourse = Database::query($sql);
     $oldestTrackDate = $oldestTrackDateOrig = '3000-01-01 00:00:00';
     while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
         $lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date'];
         if ($oldestTrackDate > $lastTrackInCourse['access_date']) {
             $oldestTrackDate = $lastTrackInCourse['access_date'];
         }
     }
     if ($oldestTrackDate == $oldestTrackDateOrig) {
         //if there was no connexion to the course ever, then take the
         // course creation date as a reference
         $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
         $sql = "SELECT course.creation_date " . "FROM {$course_table} course " . "WHERE course.code = '" . $course_code . "'";
         $res = Database::query($sql);
         if ($res && Database::num_rows($res) > 0) {
             $row = Database::fetch_array($res);
         }
         $oldestTrackDate = $row['creation_date'];
     }
     // Get the last edits of all tools of this course.
     $sql = "SELECT\n                    tet.*,\n                    tet.lastedit_date last_date,\n                    tet.tool tool,\n                    tet.ref ref,\n                    tet.lastedit_type type,\n                    tet.to_group_id group_id,\n                    ctt.image image,\n                    ctt.link link\n                FROM {$tool_edit_table} tet, {$course_tool_table} ctt\n                WHERE\n                    tet.c_id = {$course_id} AND\n                    ctt.c_id = {$course_id} AND\n                    tet.lastedit_date > '{$oldestTrackDate}' " . " AND (ctt.name = tet.tool OR (ctt.name = 'student_publication' AND tet.tool = 'work')) " . " AND ctt.visibility = '1' " . " AND tet.lastedit_user_id != {$user_id} AND tet.id_session = '" . $course_info['id_session'] . "'\n                 ORDER BY tet.lastedit_date";
     $res = Database::query($sql);
     // Get the group_id's with user membership.
     $group_ids = GroupManager::get_group_ids($course_info['real_id'], $user_id);
     $group_ids[] = 0;
     //add group 'everyone'
     $notifications = array();
     // Filter all last edits of all tools of the course
     while ($res && ($item_property = Database::fetch_array($res))) {
         // First thing to check is if the user never entered the tool
         // or if his last visit was earlier than the last modification.
         if ((!isset($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $group_ids) && ($item_property['tool'] != TOOL_DROPBOX && $item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)) && ($item_property['visibility'] == '1' || $course_info['status'] == '1' && $item_property['visibility'] == '0' || !isset($item_property['visibility']))) {
             if ($course_info['real_id'] == 1) {
                 //  var_dump($item_property);
             }
             // Also drop announcements and events that are not for the user or his group.
             if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && ($item_property['to_user_id'] != $user_id && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))) {
                 continue;
             }
             // If it's a survey, make sure the user's invited. Otherwise drop it.
             if ($item_property['tool'] == TOOL_SURVEY) {
                 $survey_info = survey_manager::get_survey($item_property['ref'], 0, $course_code);
                 if (!empty($survey_info)) {
                     $invited_users = SurveyUtil::get_invited_users($survey_info['code'], $course_code);
                     if (!in_array($user_id, $invited_users['course_users'])) {
                         continue;
                     }
                 }
             }
             // If it's a learning path, ensure it is currently visible to the user
             if ($item_property['tool'] == TOOL_LEARNPATH) {
                 require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpath.class.php';
                 if (!learnpath::is_lp_visible_for_student($item_property['ref'], $user_id, $course_code)) {
                     continue;
                 }
             }
             if ($item_property['tool'] == 'work' && $item_property['type'] == 'DirectoryCreated') {
                 $item_property['lastedit_type'] = 'WorkAdded';
             }
             $notifications[$item_property['tool']] = $item_property;
         }
     }
     // Show all tool icons where there is something new.
     $retvalue = '&nbsp;';
     while (list($key, $notification) = each($notifications)) {
         $lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date']));
         $type = $notification['lastedit_type'];
         if (empty($course_info['id_session'])) {
             $my_course['id_session'] = 0;
         } else {
             $my_course['id_session'] = $course_info['id_session'];
         }
         $label = get_lang('TitleNotification') . ": " . get_lang($type) . " ({$lastDate})";
         $retvalue .= '<a href="' . api_get_path(WEB_CODE_PATH) . $notification['link'] . '?cidReq=' . $course_code . '&amp;ref=' . $notification['ref'] . '&amp;gidReq=' . $notification['to_group_id'] . '&amp;id_session=' . $my_course['id_session'] . '">' . Display::return_icon($notification['image'], $label) . '</a>&nbsp;';
     }
     return $retvalue;
 }
Example #9
0
function anonymous_filter($anonymous)
{
    return SurveyUtil::anonymous_filter($anonymous);
}
Example #10
0
    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . $survey_id, 'name' => $urlname);
}
$courseCode = isset($_GET['cidReq']) ? $_GET['cidReq'] : null;
$surveyAnonymous = SurveyManager::get_survey($survey_id, 0, $courseCode);
$surveyAnonymous = $surveyAnonymous['anonymous'];
if ($surveyAnonymous == 0 && api_is_anonymous()) {
    api_not_allowed(true);
} elseif ($surveyAnonymous == 0 && $userInvited == 0) {
    if (!api_is_allowed_to_edit()) {
        api_not_allowed(true);
    }
}
// Header
Display::display_header(get_lang('SurveyPreview'));
// We exit here is the first or last question is a pagebreak (which causes errors)
SurveyUtil::check_first_last_question($survey_id, false);
// Only a course admin is allowed to preview a survey: you are NOT a course admin => error message
/*
if (!api_is_allowed_to_edit(false, true)) {
	Display :: display_error_message(get_lang('NotAllowed'), false);
}*/
$counter_question = 0;
// Only a course admin is allowed to preview a survey: you are a course admin
if (api_is_course_admin() || api_is_course_admin() && $_GET['isStudentView'] == 'true' || api_is_allowed_to_session_edit(false, true)) {
    // Survey information
    echo '<div id="survey_title">' . $survey_data['survey_title'] . '</div>';
    echo '<div id="survey_subtitle">' . $survey_data['survey_subtitle'] . '</div>';
    // Displaying the survey introduction
    if (!isset($_GET['show'])) {
        if (!empty($survey_data['survey_introduction'])) {
            echo '<div id="survey_content" class="survey_content">' . $survey_data['survey_introduction'] . '</div>';
Example #11
0
    SurveyUtil::update_count_invited($survey_data['code']);
    $total_count = $count_course_users + $counter_additional_users;
    $table_survey = Database::get_course_table(TABLE_SURVEY);
    // Counting the number of people that are invited
    $sql = "SELECT * FROM {$table_survey} WHERE c_id = {$course_id} AND code = '" . Database::escape_string($survey_data['code']) . "'";
    $result = Database::query($sql);
    $row = Database::fetch_array($result);
    $total_invited = $row['invited'];
    if ($total_invited > 0) {
        $message = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=answered&amp;survey_id=' . $survey_data['survey_id'] . '">' . $survey_data['answered'] . '</a> ';
        $message .= get_lang('HaveAnswered') . ' ';
        $message .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=invited&amp;survey_id=' . $survey_data['survey_id'] . '">' . $total_invited . '</a> ';
        $message .= get_lang('WereInvited');
        Display::display_normal_message($message, false);
        Display::display_confirmation_message($total_count . ' ' . get_lang('InvitationsSend'));
    }
} else {
    // Getting the invited users
    $defaults = SurveyUtil::get_invited_users($survey_data['code']);
    // Getting the survey mail text
    if (!empty($survey_data['reminder_mail'])) {
        $defaults['mail_text'] = $survey_data['reminder_mail'];
    } else {
        $defaults['mail_text'] = $survey_data['invite_mail'];
    }
    $defaults['mail_title'] = $survey_data['mail_subject'];
    $defaults['send_mail'] = 1;
    $form->setDefaults($defaults);
    $form->display();
}
Display::display_footer();
Example #12
0
 /**
  * Returns the "what's new" icon notifications
  *
  * The general logic of this function is to track the last time the user
  * entered the course and compare to what has changed inside this course
  * since then, based on the item_property table inside this course. Note that,
  * if the user never entered the course before, he will not see notification
  * icons. This function takes session ID into account (if any) and only shows
  * the corresponding notifications.
  * @param array     Course information array, containing at least elements 'db' and 'k'
  * @return string   The HTML link to be shown next to the course
  */
 public static function show_notification($course_info)
 {
     if (empty($course_info)) {
         return '';
     }
     $t_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
     $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
     $tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $course_code = Database::escape_string($course_info['code']);
     $user_id = api_get_user_id();
     $course_id = intval($course_info['real_id']);
     $sessionId = intval($course_info['id_session']);
     // Get the user's last access dates to all tools of this course
     $sql = "SELECT *\n                FROM {$t_track_e_access}\n                WHERE\n                    c_id = {$course_id} AND\n                    access_user_id = '{$user_id}' AND\n                    access_session_id ='" . $sessionId . "'";
     $resLastTrackInCourse = Database::query($sql);
     $oldestTrackDate = $oldestTrackDateOrig = '3000-01-01 00:00:00';
     while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
         $lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date'];
         if ($oldestTrackDate > $lastTrackInCourse['access_date']) {
             $oldestTrackDate = $lastTrackInCourse['access_date'];
         }
     }
     if ($oldestTrackDate == $oldestTrackDateOrig) {
         //if there was no connexion to the course ever, then take the
         // course creation date as a reference
         $oldestTrackDate = $course_info['creation_date'];
     }
     $sessionCondition = api_get_session_condition($sessionId, true, false, 'tet.session_id');
     // Get the last edits of all tools of this course.
     $sql = "SELECT\n                    tet.*,\n                    tet.lastedit_date last_date,\n                    tet.tool tool,\n                    tet.ref ref,\n                    tet.lastedit_type type,\n                    tet.to_group_id group_id,\n                    ctt.image image,\n                    ctt.link link\n                FROM {$tool_edit_table} tet\n                INNER JOIN {$course_tool_table} ctt\n                ON tet.c_id = ctt.c_id\n                WHERE\n                    tet.c_id = {$course_id} AND\n                    tet.lastedit_date > '{$oldestTrackDate}' " . " AND (ctt.name = tet.tool OR (ctt.name = 'student_publication' AND tet.tool = 'work'))\n                    AND ctt.visibility = '1'\n                    AND tet.lastedit_user_id != {$user_id} {$sessionCondition}\n                 ORDER BY tet.lastedit_date";
     $res = Database::query($sql);
     // Get the group_id's with user membership.
     $group_ids = GroupManager::get_group_ids($course_info['real_id'], $user_id);
     $group_ids[] = 0;
     //add group 'everyone'
     $notifications = array();
     // Filter all last edits of all tools of the course
     while ($res && ($item_property = Database::fetch_array($res, 'ASSOC'))) {
         // First thing to check is if the user never entered the tool
         // or if his last visit was earlier than the last modification.
         if ((!isset($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $group_ids) && ($item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)) && ($item_property['visibility'] == '1' || $course_info['status'] == '1' && $item_property['visibility'] == '0' || !isset($item_property['visibility']))) {
             // Also drop announcements and events that are not for the user or his group.
             if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && ($item_property['to_user_id'] != $user_id && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))) {
                 continue;
             }
             // If it's a survey, make sure the user's invited. Otherwise drop it.
             if ($item_property['tool'] == TOOL_SURVEY) {
                 $survey_info = SurveyManager::get_survey($item_property['ref'], 0, $course_code);
                 if (!empty($survey_info)) {
                     $invited_users = SurveyUtil::get_invited_users($survey_info['code'], $course_code);
                     if (!in_array($user_id, $invited_users['course_users'])) {
                         continue;
                     }
                 }
             }
             // If it's a learning path, ensure it is currently visible to the user
             if ($item_property['tool'] == TOOL_LEARNPATH) {
                 if (!learnpath::is_lp_visible_for_student($item_property['ref'], $user_id, $course_code)) {
                     continue;
                 }
             }
             if ($item_property['tool'] == TOOL_DROPBOX) {
                 $item_property['link'] = 'dropbox/dropbox_download.php?id=' . $item_property['ref'];
             }
             if ($item_property['tool'] == 'work' && $item_property['type'] == 'DirectoryCreated') {
                 $item_property['lastedit_type'] = 'WorkAdded';
             }
             $notifications[$item_property['tool']] = $item_property;
         }
     }
     // Show all tool icons where there is something new.
     $return = '&nbsp;';
     foreach ($notifications as $notification) {
         $lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date']));
         $type = $notification['lastedit_type'];
         $label = get_lang('TitleNotification') . ": " . get_lang($type) . " ({$lastDate})";
         if (strpos($notification['link'], '?') === false) {
             $notification['link'] = $notification['link'] . '?notification=1';
         } else {
             $notification['link'] = $notification['link'] . '&notification=1';
         }
         $return .= Display::url(Display::return_icon($notification['image'], $label), api_get_path(WEB_CODE_PATH) . $notification['link'] . '&cidReq=' . $course_code . '&ref=' . $notification['ref'] . '&gidReq=' . $notification['to_group_id'] . '&id_session=' . $sessionId) . '&nbsp;';
     }
     return $return;
 }
Example #13
0
function get_survey_data_drh($from, $number_of_items, $column, $direction)
{
    return SurveyUtil::get_survey_data($from, $number_of_items, $column, $direction, true);
}
Example #14
0
            $tool_name = get_lang('DetailedReportByQuestion');
            break;
        case 'userreport':
            $tool_name = get_lang('DetailedReportByUser');
            break;
        case 'comparativereport':
            $tool_name = get_lang('ComparativeReport');
            break;
        case 'completereport':
            $tool_name = get_lang('CompleteReport');
            break;
    }
}
// Displaying the header
Display::display_header($tool_name, 'Survey');
// Action handling
SurveyUtil::handle_reporting_actions();
// Actions bar
echo '<div class="actions">';
echo '<a href="survey.php?survey_id=' . $survey_id . '">' . Display::return_icon('back.png', get_lang('BackToSurvey'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
// Content
if (!$_GET['action'] || $_GET['action'] == 'overview') {
    $myweb_survey_id = $survey_id;
    echo '<div class="sectiontitle"><a href="reporting.php?action=questionreport&amp;survey_id=' . $myweb_survey_id . '">' . Display::return_icon('survey_reporting_question.gif', get_lang('DetailedReportByQuestion')) . ' ' . get_lang('DetailedReportByQuestion') . '</a></div><div class="sectioncomment">' . get_lang('DetailedReportByQuestionDetail') . ' </div>';
    echo '<div class="sectiontitle"><a href="reporting.php?action=userreport&amp;survey_id=' . $myweb_survey_id . '">' . Display::return_icon('survey_reporting_user.gif', get_lang('DetailedReportByUser')) . ' ' . get_lang('DetailedReportByUser') . '</a></div><div class="sectioncomment">' . get_lang('DetailedReportByUserDetail') . '.</div>';
    echo '<div class="sectiontitle"><a href="reporting.php?action=comparativereport&amp;survey_id=' . $myweb_survey_id . '">' . Display::return_icon('survey_reporting_comparative.gif', get_lang('ComparativeReport')) . ' ' . get_lang('ComparativeReport') . '</a></div><div class="sectioncomment">' . get_lang('ComparativeReportDetail') . '.</div>';
    echo '<div class="sectiontitle"><a href="reporting.php?action=completereport&amp;survey_id=' . $myweb_survey_id . '">' . Display::return_icon('survey_reporting_complete.gif', get_lang('CompleteReport')) . ' ' . get_lang('CompleteReport') . '</a></div><div class="sectioncomment">' . get_lang('CompleteReportDetail') . '</div>';
}
// Footer
Display::display_footer();
Example #15
0
        $paged_questions_sec = array();
    } else {
        echo '<div id="survey_content" class="survey_content">' . get_lang('UpdateInformation') . '</div>';
        // We unset the sessions
        unset($_SESSION['paged_questions']);
        unset($_SESSION['page_questions_sec']);
        $paged_questions_sec = array();
        $form->display();
    }
}
// Displaying the survey thanks message
if (isset($_POST['finish_survey'])) {
    Display::display_confirmation_message(get_lang('SurveyFinished'));
    echo $survey_data['survey_thanks'];
    SurveyManager::update_survey_answered($survey_data, $survey_invitation['user'], $survey_invitation['survey_code']);
    SurveyUtil::flagSurveyAsAnswered($survey_invitation['survey_code'], $survey_invitation['c_id']);
    unset($_SESSION['paged_questions']);
    unset($_SESSION['page_questions_sec']);
    Display::display_footer();
    exit;
}
// Sets the random questions
$shuffle = '';
if ($survey_data['shuffle'] == 1) {
    $shuffle = ' BY RAND() ';
}
if (isset($_GET['show']) || isset($_POST['personality'])) {
    // Getting all the questions for this page and add them to a
    // multidimensional array where the first index is the page.
    // As long as there is no pagebreak fount we keep adding questions to the page
    $questions_displayed = array();