diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index 5b5d934e53..77cc9afcc6 100644 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -85,13 +85,13 @@ if (!isset($_GET['course']) OR !isset($_GET['invitationcode'])) // now we check if the invitationcode is valid $sql = "SELECT * FROM $table_survey_invitation WHERE invitation_code = '".Database::escape_string($_GET['invitationcode'])."'"; $result = api_sql_query($sql, __FILE__, __LINE__); -if (mysql_num_rows($result) < 1) +if (Database::num_rows($result) < 1) { Display :: display_error_message(get_lang('WrongInvitationCode'), false); Display :: display_footer(); exit; } -$survey_invitation = mysql_fetch_assoc($result); +$survey_invitation = Database::fetch_array($result,'ASSOC'); // now we check if the user already filled the survey if ($survey_invitation['answered'] == 1) @@ -116,7 +116,7 @@ if (Database::num_rows($result) > 1) { echo '
'; + /* + echo ''; echo 'Group id => %'; echo ""; print_r($final_results); - + echo ''; + */ $result=array(); foreach ($final_results as $key =>$sub_result) @@ -530,22 +536,23 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) if ($equal_count==0 || $equal_count==1 ) { - //i.e 70% - 70% -0% - 0% - $equal_count = 0 only we get the first 2 options + //i.e 70% - 70% -0% - 0% - $equal_count = 0 we only get the first 2 options if ( ($result[0]['value'] == $result[1]['value']) && ($result[2]['value']==0 ) ) { $group_cant=0; } - //i.e 70% - 70% -60% - 60% $equal_count = 0 only we get the first 2 options - elseif ( ($result[0]['value'] == $result[1]['value']) && ($result[2]['value']==$result[3]['value']) ) + //i.e 70% - 70% -60% - 60% $equal_count = 0 we only get the first 2 options + elseif ( ($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value']) ) { $group_cant=0; } - elseif ( ($result[1]['value'] == $result[2]['value']) && ($result[2]['value']==$result[3]['value']) ) + //i.e. 70% - 70% - 70% + elseif ( ($result[1]['value'] == $result[2]['value']) && ($result[2]['value'] == $result[3]['value']) ) { $group_cant=-1; } else - { // by default we chose the highest 3 + { // by default we choose the highest 3 $group_cant=2; } } @@ -594,9 +601,12 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) } } } - echo "Pair of Groups "; + /* + echo ''; + echo "Pair of Groups "; echo $combi; - + echo ''; + */ // create the new select with the questions $sql = "SELECT * FROM $table_survey_question WHERE survey_id = '".$my_survey_id."' @@ -604,7 +614,7 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) ORDER BY sort ASC"; $result = api_sql_query($sql, __FILE__, __LINE__); $counter=0; - while ($row = mysql_fetch_assoc($result)) + while ($row = Database::fetch_array($result,'ASSOC')) { if ($survey_data['one_question_per_page']==0) { @@ -646,11 +656,11 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) ORDER $shuffle "; $result = api_sql_query($sql, __FILE__, __LINE__); - $question_counter_max = mysql_num_rows($result); + $question_counter_max = Database::num_rows($result); $counter = 0; $limit=0; $questions = array(); - while ($row = mysql_fetch_assoc($result)) + while ($row = Database::fetch_array($result,'ASSOC')) { // if the type is not a pagebreak we store it in the $questions array if($row['type'] <> 'pagebreak') @@ -701,7 +711,7 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) //echo "";echo ""; $result = api_sql_query($sql, __FILE__, __LINE__); $counter=0; - while ($row = mysql_fetch_assoc($result)) + while ($row = Database::fetch_array($result,'ASSOC')) { if ($survey_data['one_question_per_page']==0) { @@ -748,12 +758,12 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) $result = api_sql_query($sql, __FILE__, __LINE__); - $question_counter_max = mysql_num_rows($result); + $question_counter_max = Database::num_rows($result); $counter = 0; $limit=0; $questions = array(); - while ($row = mysql_fetch_assoc($result)) + while ($row = Database::fetch_array($result,'ASSOC')) { // if the type is not a pagebreak we store it in the $questions array if($row['type'] <> 'pagebreak') @@ -778,7 +788,11 @@ if ( isset($_GET['show']) || isset($_POST['personality'])) $counter++; } } - } + } + else //in case it's another type than 0 or 1 + { + die(get_lang('ErrorSurveyTypeUnknown')); + } } // selecting the maximum number of pages diff --git a/main/survey/preview.php b/main/survey/preview.php index f19050dc47..bb94be0f35 100644 --- a/main/survey/preview.php +++ b/main/survey/preview.php @@ -1,20 +1,22 @@ , Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code @author Julio Montoya Armas , Dokeos: Personality Test modification and rewriting large parts of the code -* @version $Id: survey.lib.php 15880 2008-07-31 19:58:31Z yannoo $ +* @version $Id: survey.lib.php 15882 2008-08-01 05:50:33Z yannoo $ * * @todo move this file to inc/lib * @todo use consistent naming for the functions (save vs store for instance) @@ -78,7 +78,7 @@ class survey_manager $return['survey_share'] = $return['is_shared']; $return['survey_introduction'] = $return['intro']; $return['survey_thanks'] = $return['surveythanks']; - $return['survey_type'] = $return['survey_type']; + $return['survey_type'] = $return['survey_type']; $return['one_question_per_page'] = $return['one_question_per_page']; $return['shuffle'] = $return['shuffle']; $return['parent_id'] = $return['parent_id'];
'; echo 'Group id => %'; echo ""; print_r($final_results); - + echo '
'; + echo "Pair of Groups "; echo $combi; - + echo '