static function get_survey_data_for_coach($from, $number_of_items, $column, $direction) { $survey_tree = new SurveyTree(); $last_version_surveys = $survey_tree->get_last_children_from_branch($survey_tree->surveylist); $list = array(); foreach ($last_version_surveys as &$survey) { $list[] = $survey['id']; } if (count($list) > 0) { $list_condition = " AND survey.survey_id IN (" . implode(',', $list) . ") "; } else { $list_condition = ''; } $from = intval($from); $number_of_items = intval($number_of_items); $column = intval($column); if (!in_array(strtolower($direction), array('asc', 'desc'))) { $direction = 'asc'; } $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); $course_id = api_get_course_int_id(); //IF(is_shared<>0,'V','-') AS col6, $sql = "SELECT " . "survey.survey_id\t\t\t\t\t\t\tAS col0, " . "survey.title\t AS col1, " . "survey.code\t\t\t\t\t\t\t\t\tAS col2, " . "count(survey_question.question_id)\t\t\tAS col3, " . (api_is_western_name_order() ? "CONCAT(user.firstname, ' ', user.lastname)" : "CONCAT(user.lastname, ' ', user.firstname)") . "\tAS col4, " . "survey.avail_from\t\t\t\t\t\t\tAS col5, " . "survey.avail_till\t\t\t\t\t\t\tAS col6, " . "CONCAT('<a href=\"survey_invitation.php?view=answered&survey_id=',survey.survey_id,'\">',survey.answered,'</a> / <a href=\"survey_invitation.php?view=invited&survey_id=',survey.survey_id,'\">',survey.invited, '</a>')\tAS col7, " . "survey.anonymous\t\t\t\t\t\t\tAS col8, " . "survey.survey_id\t\t\t\t\t\t\tAS col9 " . "FROM {$table_survey} survey " . "LEFT JOIN {$table_survey_question} survey_question\n ON (survey.survey_id = survey_question.survey_id AND survey.c_id = survey_question.c_id) " . ", {$table_user} user\n WHERE survey.author = user.user_id AND survey.c_id = {$course_id} {$list_condition} "; $sql .= " GROUP BY survey.survey_id"; $sql .= " ORDER BY col{$column} {$direction} "; $sql .= " LIMIT {$from},{$number_of_items}"; $res = Database::query($sql); $surveys = array(); while ($survey = Database::fetch_array($res)) { $surveys[] = $survey; } return $surveys; }
$form->addElement('text', 'survey_weight', get_lang('QualifyWeight'), 'value="0.00" style="width: 40px;" onfocus="javascript: this.select();"'); $form->applyFilter('survey_weight', 'html_filter'); // Loading Gradebook select GradebookUtils::load_gradebook_select_in_tool($form); if ($_GET['action'] == 'edit') { $element = $form->getElement('category_id'); $element->freeze(); } $form->addElement('html', '</div>'); } // Personality/Conditional Test Options $surveytypes[0] = get_lang('Normal'); $surveytypes[1] = get_lang('Conditional'); if ($_GET['action'] == 'add') { $form->addElement('hidden', 'survey_type', 0); $survey_tree = new SurveyTree(); $list_surveys = $survey_tree->createList($survey_tree->surveylist); $list_surveys[0] = ''; $form->addElement('select', 'parent_id', get_lang('ParentSurvey'), $list_surveys); $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">');