Removing PHP warnings

skala
Julio Montoya 13 years ago
parent a16235c327
commit 38435cf3ba
  1. 19
      main/survey/create_new_survey.php
  2. 11
      main/survey/preview.php
  3. 691
      main/survey/survey.lib.php
  4. 56
      main/survey/survey.php
  5. 7
      main/survey/survey_invite.php

@ -122,7 +122,7 @@ $survey_code = $form->addElement('text', 'survey_code', get_lang('SurveyCode'),
if ($_GET['action'] == 'edit') {
//$survey_code->freeze();
$form->applyFilter('survey_code', 'api_strtoupper');
//$form->applyFilter('survey_code', 'api_strtoupper');
}
$form->addElement('html_editor', 'survey_title', get_lang('SurveyTitle'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '200'));
@ -180,7 +180,7 @@ if ((isset($_GET['action']) && $_GET['action'] == 'edit') && !empty($survey_id))
} else {
$form->addElement('html', '<div id="options_field" style="display:none">');
}
$input_name_list = null;
$field_list = SurveyUtil::make_field_list();
if (is_array($field_list)) {
// TODO hide and show the list in a fancy DIV
@ -239,15 +239,6 @@ if ($form->validate()) {
// Storing the survey
$return = survey_manager::store_survey($values);
/* // Deleting the shared survey if the survey is getting unshared (this only happens when editing)
if (is_numeric($survey_data['survey_share']) && $values['survey_share']['survey_share'] == 0 && $values['survey_id'] != '') {
survey_manager::delete_survey($survey_data['survey_share'], true);
}
// Storing the already existing questions and options of a survey that gets shared (this only happens when editing)
if ($survey_data['survey_share'] == 0 && $values['survey_share']['survey_share'] !== 0 && $values['survey_id'] != '') {
survey_manager::get_complete_survey_structure($return['id']);
}
*/
if ($return['type'] == 'error') {
// Display the error
Display::display_error_message(get_lang($return['message']), false);
@ -258,7 +249,7 @@ if ($form->validate()) {
// Display the form
$form->display();
} else {
$gradebook_option = $values['survey_qualify_gradebook'] > 0;
$gradebook_option = isset($values['survey_qualify_gradebook']) && $values['survey_qualify_gradebook'] > 0;
if ($gradebook_option) {
$survey_id = intval($return['id']);
if ($survey_id > 0) {
@ -267,8 +258,6 @@ if ($form->validate()) {
$description_gradebook = ''; // Not needed here.
$survey_weight = floatval($_POST['survey_weight']);
$max_score = 1;
$date = time(); // TODO: Maybe time zones implementation is needed here.
$visible = 1; // 1 = visible
$link_info = is_resource_in_course_gradebook($course_id, $gradebook_link_type, $survey_id, $session_id);
$gradebook_link_id = $link_info['id'];
@ -292,9 +281,7 @@ if ($form->validate()) {
} else {
// Displaying the header
Display::display_header($tool_name);
$form->display();
}
// Footer
Display :: display_footer();

@ -65,14 +65,9 @@ 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;
$questions = array();
// 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
@ -162,7 +157,7 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView'] ==
}
echo '<form id="question" name="question" method="post" action="'.api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show.'">';
if (is_array($questions) && count($questions) > 0) {
if (isset($questions) && is_array($questions) && count($questions) > 0) {
foreach ($questions as $key => & $question) {
$ch_type = 'ch_'.$question['type'];
$display = new $ch_type;

File diff suppressed because it is too large Load Diff

@ -8,7 +8,6 @@
*
* @todo use quickforms for the forms
*/
// Language file that needs to be included
$language_file = 'survey';
@ -23,7 +22,7 @@ api_protect_course_script(true);
// Including additional libraries
require_once 'survey.lib.php';
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
/** @todo this has to be moved to a more appropriate place (after the display_header of the code) */
// Coach can't view this page
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
if (!api_is_allowed_to_edit(false, true) || (api_is_course_coach() && $extend_rights_for_coachs == 'false')) {
@ -46,12 +45,12 @@ $course_id = api_get_course_int_id();
$action = isset($_GET['action']) ? $_GET['action'] : null;
// Breadcrumbs
$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
// Getting the survey information
if (isset($_GET['survey_id'])) {
$course_code = api_get_course_id();
if ($course_code!=-1) {
if ($course_code != -1) {
$survey_data = survey_manager::get_survey($survey_id);
} else {
Display :: display_header(get_lang('ToolSurvey'));
@ -78,7 +77,7 @@ if ($is_survey_type_1 && $action == 'addgroup' || $action == 'deletegroup') {
Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\'
WHERE c_id = '.$course_id.' AND id = \''.Database::escape_string($_POST['group_id']).'\'');
$sendmsg = 'GroupUpdatedSuccessfully';
} elseif(!empty($_POST['name'])) {
} elseif (!empty($_POST['name'])) {
Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') ');
$sendmsg = 'GroupCreatedSuccessfully';
} else {
@ -86,7 +85,7 @@ if ($is_survey_type_1 && $action == 'addgroup' || $action == 'deletegroup') {
}
}
if ($action == 'deletegroup'){
if ($action == 'deletegroup') {
Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.Database::escape_string($_GET['gid']).' and survey_id = '.Database::escape_string($survey_id));
$sendmsg = 'GroupDeletedSuccessfully';
}
@ -106,7 +105,7 @@ $message_information = Security::remove_XSS($_GET['message']);
if (isset($action)) {
if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) {
survey_manager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey);
survey_manager::move_survey_question($my_action_survey, $my_question_id_survey, $my_survey_id_survey);
Display::display_confirmation_message(get_lang('SurveyQuestionMoved'));
}
if ($action == 'delete' AND is_numeric($_GET['question_id'])) {
@ -115,7 +114,7 @@ if (isset($action)) {
}
if (isset($_GET['message'])) {
// We have created the survey or updated the survey
if (in_array($_GET['message'], array('SurveyUpdatedSuccesfully','SurveyCreatedSuccesfully'))) {
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
@ -128,18 +127,19 @@ if (isset($_GET['message'])) {
}
}
if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>';
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="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="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="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="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="create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>';
$survey_actions .= '<a href="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="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="reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_MEDIUM).'</a>';
$survey_actions .= '<a href="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="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="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) {
@ -216,24 +216,24 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
echo ' <td>'.$tool_name.'</td>';
echo ' <td>'.$row['number_of_options'].'</td>';
echo ' <td>';
echo ' <a href="question.php?'.api_get_cidreq().'&amp;action=edit&amp;type='.$row['type'].'&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
echo ' <a href="question.php?'.api_get_cidreq().'&amp;action=edit&amp;type='.$row['type'].'&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?', ENT_QUOTES, $charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
if ($question_counter > 1) {
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=moveup&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>';
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=moveup&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
Display::display_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
if ($question_counter < $question_counter_max) {
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=movedown&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>';
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=movedown&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
Display::display_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
echo ' </td>';
$question_counter++;
if ($is_survey_type_1) {
echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>';
echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>';
echo '<td>'.(($row['survey_group_pri'] == 0) ? get_lang('Secondary') : get_lang('Primary')).'</td>';
echo '<td>'.(($row['survey_group_pri'] == 0) ? $groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']] : $groups[$row['survey_group_pri']]).'</td>';
}
echo '</tr>';
}
@ -247,7 +247,7 @@ if ($is_survey_type_1) {
echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false);
}
if (in_array($_GET['sendmsg'], array('GroupNeedName'))){
if (in_array($_GET['sendmsg'], array('GroupNeedName'))) {
echo Display::display_warning_message(get_lang($_GET['sendmsg']), false);
}
@ -257,7 +257,7 @@ if ($is_survey_type_1) {
if ($action == 'editgroup') {
$sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.Database::escape_string($_GET['gid']).' AND survey_id = '.Database::escape_string($survey_id).' limit 1';
$rs = Database::query($sql);
$editedrow = Database::fetch_array($rs,'ASSOC');
$editedrow = Database::fetch_array($rs, 'ASSOC');
echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>';
echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">';
echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">';
@ -279,12 +279,12 @@ if ($is_survey_type_1) {
$sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.Database::escape_string($survey_id).' ORDER BY name';
$rs = Database::query($sql);
while($row = Database::fetch_array($rs,ASSOC)){
while ($row = Database::fetch_array($rs, ASSOC)) {
$grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
'<a href="survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '.
'<a href="survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a> '.
'<a href="survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'), $row['name']).'?', ENT_QUOTES)).'\')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
'</td></tr>';
}
echo $grouplist.'</table>';

@ -21,7 +21,6 @@ require '../inc/global.inc.php';
// Including additional libraries
require_once 'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
$this_section = SECTION_COURSES;
@ -144,12 +143,8 @@ $form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAll
// Submit button
$form->addElement('style_submit_button', 'submit', get_lang('PublishSurvey'), 'class="save"');
// The rules (required fields)
/*if ($survey_data['send_mail'] == 0) {
$form->addRule('mail_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('mail_text', get_lang('ThisFieldIsRequired'), 'required');
}*/
$portal_url = api_get_path(WEB_PATH);
if ($_configuration['multiple_access_urls']) {
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url = api_get_access_url($access_url_id);

Loading…
Cancel
Save