From ed61cafbc06f4ca5bfa390ffc8b4bb2e8aca5162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Perales?= Date: Thu, 9 Jan 2014 17:30:02 -0500 Subject: [PATCH] Survey Report: hide user info when survey is anonimous --- main/inc/ajax/course.ajax.php | 3 ++- main/inc/lib/sessionmanager.lib.php | 16 ++++++++++------ main/mySpace/index.php | 5 +++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/main/inc/ajax/course.ajax.php b/main/inc/ajax/course.ajax.php index f04bc73516..d92b461a5e 100644 --- a/main/inc/ajax/course.ajax.php +++ b/main/inc/ajax/course.ajax.php @@ -184,7 +184,7 @@ switch ($action) { { $survey = Database :: get_course_table(TABLE_SURVEY); - $sql = "SELECT survey_id as id, title + $sql = "SELECT survey_id as id, title, anonymous FROM $survey WHERE c_id = %d AND session_id = %d @@ -194,6 +194,7 @@ switch ($action) { $result = Database::query($sql_query); while ($survey = Database::fetch_assoc($result)) { + $survey['title'] .= ($survey['anonymous'] == 1) ? ' (' . get_lang('Anonymous') . ')': ''; $data[] = array('id' => $survey['id'], 'text' => strip_tags(html_entity_decode($survey['title']))); } if (!empty($data)) diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index ab794df1be..4f694593b1 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -661,21 +661,25 @@ class SessionManager //Get survey questions $questions = survey_manager::get_questions($surveyId, $courseId); + + //Survey is anonymous? + $result = Database::query(sprintf("SELECT anonymous FROM $c_survey WHERE survey_id = %d", $surveyId)); + $row = Database::fetch_array($result); + $anonymous = ($row['anonymous'] == 1) ? true : false; + $table = array(); foreach ($users as $user) { $data = array( - 'lastname' => $user[1], - 'firstname' => $user[2], - 'username' => $user[3], + 'lastname' => ($anonymous ? '***' : $user[1]), + 'firstname' => ($anonymous ? '***' : $user[2]), + 'username' => ($anonymous ? '***' : $user[3]), ); //Get questions by user $sql = "SELECT sa.question_id, sa.option_id, sqo.option_text, sq.type FROM $c_survey_answer sa - INNER JOIN $c_survey_question sq ON sq.question_id = sa.question_id " - //." INNER JOIN $c_survey s ON sq.survey_id = s.survey_id " - ." + INNER JOIN $c_survey_question sq ON sq.question_id = sa.question_id LEFT JOIN $c_survey_question_option sqo ON sqo.c_id = sa.c_id AND sqo.question_id = sq.question_id AND sqo.question_option_id = sa.option_id diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 3f5933047f..234e70f926 100644 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -687,8 +687,9 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst if (!empty($surveyId)) { $course = api_get_course_info_by_id($courseId); $surveyList = array(); - $exerciseInfo = survey_manager::get_survey($surveyId, 0, $course['code']); - $surveyList[] = array('id' => $exerciseInfo['survey_id'], 'text' => strip_tags(html_entity_decode($exerciseInfo['title']))); + $surveyInfo = survey_manager::get_survey($surveyId, 0, $course['code']); + $surveyInfo['title'] .= ($surveyInfo['anonymous'] == 1) ? ' (' . get_lang('Anonymous') . ')': ''; + $surveyList[] = array('id' => $surveyInfo['survey_id'], 'text' => strip_tags(html_entity_decode($surveyInfo['title']))); } $sessionFilter->addElement('select_ajax', 'survey_name', get_lang('SearchSurvey'), null, array('url' => $url, 'defaults' => $surveyList, 'width' => '400px'));