survey report BT#149

1.9.x
César Perales 12 years ago
parent dc81312e97
commit 1e4756324d
  1. 27
      main/inc/ajax/course.ajax.php
  2. 6
      main/inc/ajax/model.ajax.php
  3. 4
      main/inc/lib/sessionmanager.lib.php
  4. 31
      main/mySpace/index.php

@ -153,7 +153,6 @@ switch ($action) {
$course = api_get_course_info_by_id($_GET['course_id']);
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
error_log($_GET['q']);
$exercises = get_all_exercises($course, intval($_GET['session_id']), false, $_GET['q']);
foreach ($exercises as $exercise)
@ -169,6 +168,32 @@ switch ($action) {
}
}
break;
case 'search_survey_by_course':
if (api_is_platform_admin())
{
$survey = Database :: get_course_table(TABLE_SURVEY);
$sql = "SELECT survey_id as id, title
FROM $survey
WHERE c_id = %d
AND session_id = %d
AND title LIKE '%s'";
$sql_query = sprintf($sql, intval($_GET['course_id']), intval($_GET['session_id']), '%' . $_GET['q'] .'%');
$result = Database::query($sql_query);
while ($survey = Database::fetch_assoc($result))
{
$data[] = array('id' => $survey['id'], 'text' => $survey['title'] );
}
if (!empty($data))
{
echo json_encode($data);
} else
{
echo json_encode(array());
}
}
break;
default:
echo '';
}

@ -280,7 +280,9 @@ switch ($action) {
$count = count($records);
break;
case 'get_survey_overview':
$count = 10; //temp
//@TODO replace this for a more efficient function (not retrieving the whole data)
$records = SessionManager::get_survey_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['survey_id']), $options);
$count = count($records);
break;
/*case 'get_extra_fields':
$type = $_REQUEST['type'];
@ -706,7 +708,7 @@ switch ($action) {
{
$columns[] = $question_id;
}
$result = SessionManager::get_survey_overview($sessionId, $courseId, $surveyId,
array(
'where' => $where_condition,

@ -673,8 +673,10 @@ class SessionManager
return $table;
}
/**
* Gets the progress of learning paths in the given session
* Gets the survey answers
* @param int session id
* @param int course id
* @param int survey id
* @param array options order and limit keys
* @return array table with user name, lp name, progress
*/

@ -716,6 +716,37 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
});
</script>';*/
}
if (in_array($display, array('surveyoverview')))
{
$surveyOverview = new FormValidator('survey_filter', 'get', '', '', array('class'=> 'form-search'), false);
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_survey_by_course&session_id=' . $_GET['session_id'] . '&course_id=' . $_GET['course_id'] . '&survey_id=' . $_GET['survey_id'];
$surveyList = array();
$surveyId = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : null;
$courseId = isset($_GET['course_id']) ? intval($_GET['course_id']) : null;
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['id'], 'text' => $exerciseInfo['title']);
}
$surveyOverview->addElement('select_ajax', 'survey_name', get_lang('SearchExercise'), null, array('url' => $url, 'defaults' => $surveyList));
$courseListUrl = api_get_self();
echo '<div class="">';
echo $surveyOverview ->return_form();
echo '</div>';
echo '<script>
$(function() {
$("#survey_name").on("change", function() {
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var surveyId = $("#survey_name").val();
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId+"&course_id="+courseId+"&survey_id="+surveyId;
});
});
</script>';
}
if (in_array($display, array('exerciseprogress')))
{
//exercise

Loading…
Cancel
Save