Forráskód Böngészése

[svn r10603] replacing <? with <?php
removing useless dbname, cidreq
removing unused variables
coding standards

Patrick Cool 18 éve
szülő
commit
f952c23d06

+ 23 - 30
main/survey/addanother.php

@@ -23,7 +23,7 @@
 ==============================================================================
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: addanother.php 10583 2007-01-02 14:47:19Z pcool $
+* 	@version $Id: addanother.php 10603 2007-01-06 17:01:47Z pcool $
 ==============================================================================
 */
 
@@ -73,11 +73,6 @@ $table_user 		= Database :: get_main_table(TABLE_MAIN_USER);
 $table_survey 		= Database :: get_course_table('survey');
 $table_group 		= Database :: get_course_table('survey_group');
 
-// Path variables
-/** @todo these variables are probably not used here */
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
-
 // Language variables
 $tool_name = get_lang('CreateNewSurvey');
 $tool_name1 = get_lang('AddAnotherQuestion');
@@ -91,18 +86,19 @@ $course_id = $_SESSION['_course']['id'];
 
 // $_GET and $_POST
 /** @todo replace $_REQUEST with $_GET or $_POST */
-$cidReq = $_GET['cidReq'];
-/** @todo use $_course array */
-$curr_dbname 	= $_REQUEST['curr_dbname'];
-$group_id		= $_GET['newgroupid'];
-if(isset($_REQUEST['surveyid']))
-$surveyid=$_REQUEST['surveyid'];
+$group_id	= $_GET['newgroupid'];
 if(isset($_REQUEST['groupid']))
-$groupid=$_REQUEST['groupid'];
-if(isset($_REQUEST['cidReq']))
-$cidReq=$_REQUEST['cidReq'];
+{
+	$groupid=$_REQUEST['groupid'];
+}
+if(isset($_GET['cidReq']))
+{
+	$cidReq=$_GET['cidReq'];
+}
 if(isset($_REQUEST['newgroupid']))
-$groupid=$_REQUEST['newgroupid'];
+{
+	$groupid=$_REQUEST['newgroupid'];
+}
 
 
 
@@ -110,7 +106,7 @@ $groupid=$_REQUEST['newgroupid'];
 
 if(isset($_POST['back']))
 { 
-	header("location:select_question_group.php?add_question=$add_question&groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+	header("location:select_question_group.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']."&cidReq=$cidReq");
 }
 
 if(isset($_POST['next']))
@@ -121,24 +117,23 @@ if(isset($_POST['next']))
 		{
 			$groupid=$_POST['exiztinggroup'];
 			$add_question=$_POST['add_question'];
-			$curr_dbname = $_REQUEST['curr_dbname'];
 			/** @todo it seems a bad idea to use language strings for switch statements and $_POST variables */
 			switch ($_POST['add_question'])
 			{
 				case get_lang('YesNo'):
-				header("location:yesno.php?add_question=$add_question&groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+				header("location:yesno.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']."&cidReq=$cidReq");
 				break;
 				case get_lang('MultipleChoiceSingle'):
-				header("location:mcsa.php?add_question=$add_question&groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+				header("location:mcsa.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']."&cidReq=$cidReq");
 				break;
 				case get_lang('MultipleChoiceMulti'):
-				header("location:mcma.php?add_question=$add_question&groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+				header("location:mcma.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']."&cidReq=$cidReq");
 				break;
 				case get_lang('Open'):
-				header("location:open.php?add_question=$add_question&groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+				header("location:open.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']."&cidReq=$cidReq");
 				break;
 				case get_lang('Numbered'):
-				header("location:numbered.php?add_question=$add_question&groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+				header("location:numbered.php?add_question=$add_question&groupid=$groupid&surveyid=".$_GET['surveyid']."&cidReq=$cidReq");
 				break;
 				default :
 				header("location:select_question_type.php?cidReq=$cidReq");
@@ -155,7 +150,7 @@ if(isset($_POST['next']))
 	$error_message=get_lang('PleaseSelectQuestionAndGroup');
 }
 Display::display_header($tool_name1);
-$query="SELECT * FROM $table_survey WHERE survey_id='$surveyid'";
+$query="SELECT * FROM $table_survey WHERE survey_id='".mysql_real_escape_string($_GET['surveyid'])."'";
 $result=api_sql_query($query);
 $surveyname=mysql_result($result,0,'title');
 //$surveyname=get_lang('SurveyName').$surveyname;
@@ -171,16 +166,14 @@ if(isset($group_id))
  $obj= mysql_fetch_object($res);
  ?>
  <div align="center"><strong><font color="#FF0000"><?php echo "Group";?>&nbsp;&nbsp;<font color="#0000CC"><u><?php echo $obj->groupname;?></u>&nbsp;&nbsp;</font><?php echo get_lang('GroupCreated');?></font></strong></div>
-<?
+<?php
 }
 
 ?>
 <form name="question" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?php echo $cidReq; ?>">
 <input type="hidden" name="groupid" value="<?php echo $groupid; ?>">
-<input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
+<input type="hidden" name="surveyid" value="<?php echo $_GET['surveyid']; ?>">
 <input type="hidden" name="newgroupid" value="<?php echo $group_id; ?>">
-<input type="hidden" name="curr_dbname" value="<?php echo $curr_dbname; ?>">
-<!--<input type="hidden" name="cidReq" value="<?php echo $cidReq; ?>">-->
 <table>
 <tr>
 <td>
@@ -208,12 +201,12 @@ if(isset($group_id))
 </td>
 <td>
 <?php 
-	echo SurveyManager::select_group_list($surveyid, $groupid, $extra_script);
+	echo SurveyManager::select_group_list($_GET['surveyid'], $groupid, $extra_script);
 ?>
 <!--<select name="select_group" >-->
 
 <?php 
-	/*$query="SELECT * FROM $table_group WHERE survey_id='$surveyid'";
+	/*$query="SELECT * FROM $table_group WHERE survey_id='$_GET['surveyid']'";
 	//echo $query;
 	$result=api_sql_query($query);
 	$num=mysql_num_rows($result);

+ 1 - 6
main/survey/attach_existingsurvey.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: attach_existingsurvey.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: attach_existingsurvey.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -72,11 +72,6 @@ $table_question 			= Database :: get_course_table('questions');
 $table_course 				= Database :: get_main_table(TABLE_MAIN_COURSE);
 $table_course_survey_rel	= Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY);
 
-// Path variables
-/** @todo these variables are probably not used here */
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
-
 // Language variables
 $MonthsLong = array(get_lang('JanuaryLong'), get_lang('FebruaryLong'), get_lang('"MarchLong'), get_lang('AprilLong'), get_lang('MayLong'), get_lang('JuneLong'), get_lang('JulyLong'), get_lang('AugustLong'), get_lang('SeptemberLong'), get_lang('OctoberLong'), get_lang('NovemberLong'), get_lang('DecemberLong')); 
 $tool_name = get_lang('CreateNewSurvey');

+ 1 - 6
main/survey/attach_question.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: attach_question.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: attach_question.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -72,11 +72,6 @@ $table_question 			= Database :: get_course_table('questions');
 $table_course 				= Database :: get_main_table(TABLE_MAIN_COURSE);
 $table_course_survey_rel 	= Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY);
 
-// Path variables
-/** @todo these variables are probably not used here */
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
-
 // Language variables
 $MonthsLong = array(get_lang('JanuaryLong'), get_lang('FebruaryLong'), get_lang('"MarchLong'), get_lang('AprilLong'), get_lang('MayLong'), get_lang('JuneLong'), get_lang('JulyLong'), get_lang('AugustLong'), get_lang('SeptemberLong'), get_lang('OctoberLong'), get_lang('NovemberLong'), get_lang('DecemberLong')); 
 $tool_name = get_lang('CreateNewSurvey');

+ 1 - 6
main/survey/attach_survey.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: attach_survey.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: attach_survey.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -72,11 +72,6 @@ $table_user 				= Database :: get_main_table(TABLE_MAIN_USER);
 $table_course 				= Database :: get_main_table(TABLE_MAIN_COURSE);
 $table_course_survey_rel 	= Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY);
 
-// Path variables
-/** @todo these variables are probably not used here */
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
-
 // Language variables
 $MonthsLong = array(get_lang('JanuaryLong'), get_lang('FebruaryLong'), get_lang('"MarchLong'), get_lang('AprilLong'), get_lang('MayLong'), get_lang('JuneLong'), get_lang('JulyLong'), get_lang('AugustLong'), get_lang('SeptemberLong'), get_lang('OctoberLong'), get_lang('NovemberLong'), get_lang('DecemberLong')); 
 $tool_name = get_lang('CreateNewSurvey');

+ 24 - 21
main/survey/create_new_group.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: create_new_group.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: create_new_group.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -41,6 +41,7 @@ require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
 require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php");
 require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php");
 require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
+require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
 
 /** @todo replace this with the correct code */
 /*
@@ -60,11 +61,17 @@ if (!api_is_allowed_to_edit())
 	exit;
 }
 
-require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
+// Database table definitions
+/** @todo use database constants for the survey tables */
+$table_survey 		= Database :: get_course_table('survey');
+$table_group 		= Database :: get_course_table('survey_group');
+$table_question 	= Database :: get_course_table('questions');
+$table_course 		= Database :: get_main_table(TABLE_MAIN_COURSE);
+$table_survey_group = Database :: get_course_table('survey_group');
+
+
+
 $cidReq=$_GET['cidReq'];
-$curr_dbname = $_REQUEST['curr_dbname'];
-$table_group = Database :: get_course_table('survey_group');
-$table_user = Database :: get_main_table(TABLE_MAIN_USER);
 $tool_name1 = get_lang('CreateNewGroup');
 $tool_name = get_lang('CreateNewGroup');
 $header1 = get_lang('GroupList');
@@ -98,20 +105,18 @@ if(isset($_REQUEST['delete']))
  {
    $group_id = $_REQUEST['group_delete'];
    $surveyid = $_REQUEST['surveyid'];
-   $curr_dbname = $_REQUEST['curr_dbname'];
-   SurveyManager::delete_group($group_id,$curr_dbname);
-   header("Location:create_new_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+   SurveyManager::delete_group($group_id);
+   header("Location:create_new_group.php?surveyid=$surveyid&cidReq=$cidReq");
    exit;		
  }
 if ($_POST['action'] == 'new_group')
 {
 	$surveyid = $_POST['surveyid'];
 	$groupname = $_POST['groupname'];
-	$curr_dbname = $_REQUEST['curr_dbname'];
 	$surveyintroduction = $_POST['content'];
 	 if(isset($_POST['back']))
 	   { 
-		 header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+		 header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq");
 		 exit;
 	   } 
 	
@@ -128,7 +133,7 @@ if ($_POST['action'] == 'new_group')
 		if(isset($_POST['next']) && $groupid)
 		{ 
 		
-		 header("location:addanother.php?surveyid=$surveyid&newgroupid=$groupid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+		 header("location:addanother.php?surveyid=$surveyid&newgroupid=$groupid&cidReq=$cidReq");
 		 exit;
 		
 		}elseif(isset($_POST['saveandexit']) && $groupid){
@@ -150,18 +155,17 @@ Display::display_header($tool_name1);
 <tr>
 <td><?php api_display_tool_title($header1); ?></td>
 </tr>
-<?
+<?php
 if( isset($error_message) )
 {
 	Display::display_error_message($error_message);	
 }
 
-$table_group =  Database :: get_course_table('survey_group');
+
 		
-		$sql = "SELECT * FROM $curr_dbname.survey_group Where survey_id='$surveyid' ORDER BY sortby ASC";
+		$sql = "SELECT * FROM $table_survey_group WHERE survey_id='$surveyid' ORDER BY sortby ASC";
 		
 		$parameters = array ();
-		$parameters['curr_dbname']=$curr_dbname;
         $parameters['surveyid']=$surveyid;
 		$parameters['groupid']=$groupid;
 		$parameters['cidReq']=$cidReq;		
@@ -185,21 +189,21 @@ $table_group =  Database :: get_course_table('survey_group');
 				$survey[] = $author;
 				$directions = '<table cellpadding="0" cellspacing="0" border="0" style="border:0px"><tr>';
 				if($i < $countGroups-1){
-					$directions .= '<td><a href="'.$_SERVER['PHP_SELF'].'?surveyid='.$surveyid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&direction=down&id_group='.$gid.'"><img src="../img/down.gif" border="0" title="lang_move_down"></a></td>';
+					$directions .= '<td><a href="'.$_SERVER['PHP_SELF'].'?surveyid='.$surveyid.'&cidReq='.$cidReq.'&direction=down&id_group='.$gid.'"><img src="../img/down.gif" border="0" title="lang_move_down"></a></td>';
 				}
 				else {
 					$directions .= '<td width="20"></td>';
 				}
 				if($i > 0){
-					$directions .= '<td><a href="'.$_SERVER['PHP_SELF'].'?surveyid='.$surveyid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&direction=up&id_group='.$gid.'"><img src="../img/up.gif" border="0" title="lang_move_up"></a></td>';
+					$directions .= '<td><a href="'.$_SERVER['PHP_SELF'].'?surveyid='.$surveyid.'&cidReq='.$cidReq.'&direction=up&id_group='.$gid.'"><img src="../img/up.gif" border="0" title="lang_move_up"></a></td>';
 				}
 				else {
 					$directions .= '<td></td>';
 				}
 				$directions .= '</tr></table>';
 				$survey[] = $directions;
-				$survey[] =  '<a href="group_edit.php?groupid='.$obj->group_id.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&surveyid='.$surveyid.'"><img src="../img/edit.gif" border="0" align="absmiddle" alt="'.get_lang('Edit').'"/></a>'
-				.'<a href="create_new_group.php?cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&delete=1&group_delete='.$gid.'&surveyid='.$surveyid.'"  onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" alt="'.get_lang('Delete').'"/></a>'
+				$survey[] =  '<a href="group_edit.php?groupid='.$obj->group_id.'&cidReq='.$cidReq.'&&surveyid='.$surveyid.'"><img src="../img/edit.gif" border="0" align="absmiddle" alt="'.get_lang('Edit').'"/></a>'
+				.'<a href="create_new_group.php?cidReq='.$cidReq.'&delete=1&group_delete='.$gid.'&surveyid='.$surveyid.'"  onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" alt="'.get_lang('Delete').'"/></a>'
 				;
                $surveys[] = $survey;
                $i++;
@@ -216,7 +220,7 @@ $table_group =  Database :: get_course_table('survey_group');
 	{
 		echo get_lang('NoSearchResults');
 	}
-	echo '<a href="select_question_group.php?surveyid='.$surveyid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'">'.get_lang('BackToQuestions').'</a><br><br>';
+	echo '<a href="select_question_group.php?surveyid='.$surveyid.'&cidReq='.$cidReq.'">'.get_lang('BackToQuestions').'</a><br><br>';
 api_display_tool_title($tool_name);
 ?>
 <script src=tbl_change.js type="text/javascript" language="javascript"></script>
@@ -224,7 +228,6 @@ api_display_tool_title($tool_name);
 <input type="hidden" name="action" value="new_group">
 <input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
 <input type="hidden" name="groupid" value="<?php echo $groupid; ?>">
-<input type="hidden" name="curr_dbname" value="<?php echo $curr_dbname; ?>">
 <!--<input type="hidden" name="cidReq" value="<?php echo $_REQUEST['cidReq']; ?>">-->
 <table>
 <tr>

+ 31 - 21
main/survey/create_new_survey.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: create_new_survey.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: create_new_survey.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 // name of the language file that needs to be included 
@@ -28,6 +28,7 @@ $language_file = 'survey';
 
 // including the global dokeos file
 require_once ('../inc/global.inc.php');
+
 // including additional libraries
 /** @todo check if these are all needed */
 /** @todo check if the starting / is needed. api_get_path probably ends with an / */
@@ -240,17 +241,25 @@ if($surveyid = $_REQUEST['surveyid'])
 	        <!-- month: january ->
 	december -->
 	<select name="fmonth">
-		<?
+		<?php
 			for($i=1;$i<=count($MonthsLong);$i++)
 			{
 				if($i<=9)
-				$val = "0".$i;
+				{
+					$val = "0".$i;
+				}
 				else
-				$val = $i;
+				{
+					$val = $i;
+				}
 				if($val == $avail_month_from)
-				echo   "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
+				{
+					echo   "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
+				}
 				else
-				echo   "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
+				{
+					echo   "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
+				}
 			}
 		?>
 	</select>
@@ -558,26 +567,27 @@ else
 	<!-- month: january ->
 	december -->
 	<select name="fmonth">
-	<?
-			for($i=1;$i<=count($MonthsLong);$i++)
+	<?php
+			for($i=1; $i<=12; $i++)
 			{
 				if($i<=9)
-		{
-				$val = "0".$i;
-		}
+				{
+					$val = "0".$i;
+				}
 				else
-		{
-				$val = $i;
-		}
+				{
+					$val = $i;
+				}
+				
 				if($val == $curr_month)
-		{
-				echo   "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
-		}
+				{
+					echo   "<option value=\"$val\" selected>".$MonthsLong[$i-1]."</option>\n";
+				}
 				else
-		{
-				echo   "<option value=\"$val\">".$MonthsLong[$i-1]."</option>\n";
+				{
+					echo   "<option value=\"$val\">".$MonthsLong[$i-1]."y</option>\n";
+				}
 			}
-	}
 	?>
 	</select>
 	<select name="fyear">
@@ -628,7 +638,7 @@ else
 	    <!-- month: january ->
 	december -->
 	<select name="end_fmonth">
-	<?
+	<?php
 			for($i=1;$i<=count($MonthsLong);$i++)
 			{
 				if($i<=9)

+ 4 - 5
main/survey/create_survey.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: create_survey.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: create_survey.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -60,14 +60,13 @@ if (!api_is_allowed_to_edit())
 	exit;
 }
 
-
-//$table_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
+// Database table definitions
+/** @todo use database constants for the survey tables */
 $table_survey = Database :: get_main_table(MAIN_SURVEY_IFA_TABLE);
 $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
+
 $tool_name = get_lang('CreateSurvey');
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('AdministrationTools'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $newsurvey = '0';
 
 if ($_POST['action'] == 'add_survey')

+ 2 - 2
main/survey/existing_surveys_new.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: existing_surveys_new.php 10583 2007-01-02 14:47:19Z pcool $
+* 	@version $Id: existing_surveys_new.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -140,7 +140,7 @@ function displayTemplate(url) {
 		$table_header[] = array (' ', false);
 		if(!empty($surveys))
 		{
-		Display :: display_sortable_table($table_header, $surveys, array (), array (), $parameters);
+			Display :: display_sortable_table($table_header, $surveys, array (), array (), $parameters);
 		}
 		else
 		{$flag=1;}

+ 1 - 3
main/survey/group_add_question.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: group_add_question.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: group_add_question.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -50,8 +50,6 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
 $tool_name1 = get_lang('AddQuestion');
 $tool_name = get_lang('AddQuestion');
 $interbreadcrumb[] = array ("url" => "survey.php", "name" => get_lang('CreateSurvey'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $surveyid=$_GET['surveyid'];
 $groupid = $_GET['groupid'];
 if (isset($_POST['back']))

+ 1 - 3
main/survey/group_edit.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: group_edit.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: group_edit.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -68,8 +68,6 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
 $tool_name1 = get_lang('CreateNewGroup');
 $tool_name = get_lang('ModifyGroupInformation');
 $interbreadcrumb[] = array ("url" => "survey_list.php?", "name" => get_lang('Survey'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $groupid = $_GET['groupid'];
 $surveyid = $_GET['surveyid'];
 if($_POST['action'] == 'new_group')

+ 20 - 19
main/survey/mcma.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: mcma.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: mcma.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 // name of the language file that needs to be included 
@@ -207,7 +207,7 @@ if ($_POST['action'] == 'addquestion')
 	}
 }
 ?>
-<?
+<?php
 $tool = get_lang('AddAnotherQuestion');
 Display::display_header($tool);
 ?>
@@ -219,7 +219,7 @@ function changeAction()
 	return true;
 }
 </script>
-<?
+<?php
 select_question_type($add_question12,$groupid,$surveyid,$cidReq,$curr_dbname);
 ?>
 <table>
@@ -499,33 +499,34 @@ function checkLength(form){
 					</td>
 					<td width="10" class="form_text"><img src="../img/blank.gif" width="10" height="8">
 					</td>					
-<?					if($i>$start)
+<?php
+					if($i>$start)
 					{
 ?>
 					<td width="30" align="center" class="form_text1"> 
-						<input type="image" src="../img/up.gif" width="24" height="24" border="0" onclick="this.form.submit();" name="<?echo "up".$i;?>" style="cursor:hand"> 
+						<input type="image" src="../img/up.gif" width="24" height="24" border="0" onclick="this.form.submit();" name="<?php echo "up".$i;?>" style="cursor:hand"> 
 					</td>
-<?					}
+<?php					}
 					else
 					{
 ?>						<td width="30" align="center" class="form_text1"> 
 						</td>
-<?					}
+<?php					}
 					$sn++;
 ?>
 
-<?					if($i<$end)
+<?php					if($i<$end)
 					{
 ?>
 					<td width="30" align="center" class="form_text"> 
-						<input type="image" src="../img/down.gif" width="24" height="24" border="0" onclick="this.form.submit();" name="<?echo "down".$i;?>" style="cursor:hand"> 
+						<input type="image" src="../img/down.gif" width="24" height="24" border="0" onclick="this.form.submit();" name="<?php echo "down".$i;?>" style="cursor:hand"> 
 					</td>
-<?					}
+<?php					}
 					else
 					{
 ?>						<td width="30" align="center" class="form_text1"> 
 						</td>
-<?					}
+<?php					}
 ?>
 					<td width="30" align="center" class="form_text">
 
@@ -533,7 +534,7 @@ function checkLength(form){
 					
 					<input type="image" src="../img/delete.gif" width="24" height="24" border="0" style="cursor:hand" name="<?php echo "id".$i;?>" value="<?php echo $end;?>" onclick="this.form.submit();">					
 			</tr>
-<?		}	
+<?php		}	
 	}
 	
 ?>   
@@ -544,11 +545,11 @@ function checkLength(form){
 					  <td height="30"><span class="form_text1">Add&nbsp;&nbsp;</span>
 							<select name="addnewrows" class="text_field_small" style="width:100px" onChange="this.form.submit();">
 								
-								<!--<option value="1" <?if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="1")echo "selected";}?>>1</option>
-								<option value="2" <?if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="2")echo "selected";}?>>2</option>
-								<option value="3" <?if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="3")echo "selected";}?>>3</option>
-								<option value="4" <?if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="4")echo "selected";}?>>4</option>
-								<option value="5" <?if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="5")echo "selected";}?>>5</option>-->
+								<!--<option value="1" <?php if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="1")echo "selected";}?>>1</option>
+								<option value="2" <?php if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="2")echo "selected";}?>>2</option>
+								<option value="3" <?php if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="3")echo "selected";}?>>3</option>
+								<option value="4" <?php if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="4")echo "selected";}?>>4</option>
+								<option value="5" <?php if(isset($_POST['addnewrows'])){if($_POST['addnewrows']=="5")echo "selected";}?>>5</option>-->
 								
 								<option value="0" >0</option>
 								<option value="1" >1</option>
@@ -576,10 +577,10 @@ function checkLength(form){
 			<input type="HIDDEN" name="end1" value="<?php echo $end; ?>">
 
 
-<?			if(isset($_POST['add_question']))
+<?php 			if(isset($_POST['add_question']))
 			{
 ?>				<input type="hidden" name="add_question" value="<?php echo $_POST['add_question'];?>" >
-<?			}
+<?php 			}
 
 			$sql = "SELECT * FROM $curr_dbname.survey WHERE survey_id='$surveyid'";
 			$res=api_sql_query($sql);

+ 2 - 1
main/survey/new_survey.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: new_survey.php 10559 2006-12-27 10:52:50Z pcool $
+* 	@version $Id: new_survey.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 // name of the language file that needs to be included 
@@ -72,6 +72,7 @@ $group_table = Database :: get_main_table(TABLE_MAIN_GROUP);
 		$table_header[] = array ('', false);
 
 echo '<form method="post" action="new_survey.php">';
+		/** @todo remove $curr_dbname from the parameters. This is not used. */
 		Display :: display_sortable_table($table_header, $users, array (), array (), $parameters);
 		echo '<input type="submit" value="'.get_lang('Ok').'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;"/>';
 		echo '</form>';

+ 1 - 3
main/survey/preview_mcma.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: preview_mcma.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: preview_mcma.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -53,8 +53,6 @@ $header1 = get_lang('SurveyName');
 $header2 = get_lang('GroupName');
 $header3 = get_lang('Type');
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('Survey'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $questionid = '1';
 $enterquestion = $_REQUEST['enterquestion'];
 $mutlichkboxtext = $_REQUEST['mutlichkboxtext'];

+ 1 - 3
main/survey/preview_open.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: preview_open.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: preview_open.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -52,8 +52,6 @@ $header1 = get_lang('SurveyName');
 $header2 = get_lang('GroupName');
 $header3 = get_lang('Type');
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('Survey'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $questionid = '1';
 $surveyid = $_REQUEST['surveyid'];
 $groupid = $_REQUEST['groupid'];

+ 1 - 3
main/survey/preview_yesno.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: preview_yesno.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: preview_yesno.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 /*
@@ -72,8 +72,6 @@ $header1 = get_lang('SurveyName');
 $header2 = get_lang('GroupName');
 $header3 = get_lang('Type');
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('Survey'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $questionid = '1';
 $surveyid = $_REQUEST['surveyid'];
 $groupid = $_REQUEST['groupid'];

+ 3 - 5
main/survey/select_question_group-uploaded.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: select_question_group-uploaded.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: select_question_group-uploaded.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 
@@ -80,8 +80,6 @@ else
 {
  $interbreadcrumb[] = array ("url" => "create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page", "name" => get_lang('CreateFromExistingSurvey'));
 }*/
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $default_group = '0';
 $new_group = '1';
 $existing_group = '2';
@@ -364,8 +362,8 @@ $result=api_sql_query($query);*/
 <?
 if(!empty($courses))
 {
-
-				SurveyManager :: display_sortable_table($groupid,$surveyid,$curr_dbname,$table_header, $courses, array (), array (), $parameters);
+	/** @todo remove $curr_dbname from the parameters. This is not used. */
+	SurveyManager :: display_sortable_table($groupid,$surveyid,$curr_dbname,$table_header, $courses, array (), array (), $parameters);
 
 ?>	
 	<!--<input type="submit" name="delete" value="<?php  echo get_lang('Delete');?>">-->

+ 76 - 92
main/survey/select_question_group.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: select_question_group.php 10584 2007-01-02 15:09:21Z pcool $
+* 	@version $Id: select_question_group.php 10603 2007-01-06 17:01:47Z pcool $
 */
 
 
@@ -61,27 +61,21 @@ if (!api_is_allowed_to_edit())
 	exit;
 }
 
-$table_survey = Database :: get_course_table('survey');
-$table_group =  Database :: get_course_table('survey_group');
-$table_question = Database :: get_course_table('questions');
-$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
+// Database table definitions
+/** @todo use database constants for the survey tables */
+$table_survey 		= Database :: get_course_table('survey');
+$table_group 		= Database :: get_course_table('survey_group');
+$table_question 	= Database :: get_course_table('questions');
+$table_course 		= Database::get_main_table(TABLE_MAIN_COURSE);
+$table_survey_group = Database :: get_course_table('survey_group');
+
 $cidReq = $_GET['cidReq'];
 $db_name = $_REQUEST['db_name'];
-$curr_dbname = $_REQUEST['curr_dbname'];
-//$table_survey = Database :: get_course_table('survey');
+
+
 $tool_name1 = get_lang('AddQuestionGroup');
 $tool_name = get_lang('AddQuestionGroup');
 $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
-/*if($page = $_REQUEST['page'])
-{
- $interbreadcrumb[] = array ("url" => "create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page", "name" => get_lang('CreateNewSurvey'));
-}
-else
-{
- $interbreadcrumb[] = array ("url" => "create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page", "name" => get_lang('CreateFromExistingSurvey'));
-}*/
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $default_group = '0';
 $new_group = '1';
 $existing_group = '2';
@@ -94,20 +88,22 @@ $flag = $_REQUEST['flag'];
 $action1 = $_REQUEST['action1'];
 $sort = $_REQUEST['sortby'];
 
+
 if(!isset($page_nr)||!isset($column)||!isset($per_page))
 {
-$page_nr =1;
-$column =0;
-$per_page = 10;
+	$page_nr =1;
+	$column =0;
+	$per_page = 10;
 }
 else
 {
-$page_nr = $_REQUEST['page_nr'];
-$column = $_REQUEST['column'];
-$per_page = $_REQUEST['per_page'];
+	$page_nr = $_REQUEST['page_nr'];
+	$column = $_REQUEST['column'];
+	$per_page = $_REQUEST['per_page'];
 }
+
 /*
-$sql="SELECT * FROM $curr_dbname.questions WHERE gid='$groupid' AND survey_id = '$surveyid'";
+$sql="SELECT * FROM $table_question WHERE gid='$groupid' AND survey_id = '$surveyid'";
 $res=api_sql_query($sql,__FILE__,__LINE__);
 $obj=mysql_fetch_object($res);
 $number=mysql_num_rows($res);
@@ -166,38 +162,38 @@ for($i=1;$i<=$number;$i++)
 		}
 	}
 */
+
 if ($_POST['action'] == 'selectquestion_group')
 {
 	$surveyid = $_POST['newsurveyid'];	
-	 $questiongroup = $_POST['question_group'];
-if (isset($questiongroup))
+	$questiongroup = $_POST['question_group'];
+	if (isset($questiongroup))
 	{	 
 	     $cidReq=$_REQUEST['cidReq'];
 		 $exiztinggroup = $_POST['exiztinggroup'];
-		 $curr_dbname = $_REQUEST['curr_dbname'];
-		 header("Location:existing_surveys_new.php?cidReq=$cidReq&surveyid=$surveyid&curr_dbname=$curr_dbname");	
+		 header("Location:existing_surveys_new.php?cidReq=$cidReq&surveyid=$surveyid");	
 		 exit;	
 	}
 }
+
 //from question_added
 if (isset($_POST['back']))
 {
 	    $groupid = $_POST['groupid'];
 	    $surveyid = $_POST['surveyid'];
 		$cidReq=$_REQUEST['cidReq'];
-		$curr_dbname = $_REQUEST['curr_dbname'];
 		$page = $_REQUEST['page'];
-		header("Location:create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&page=$page");
+		header("Location:create_new_survey.php?surveyid=$surveyid&cidReq=$cidReq&page=$page");
 		//header("Location:select_question_type.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
 	    exit;
 }
+
 if (isset($_POST['addanother']))
 {
 	    $groupid = $_POST['groupid'];
 	    $surveyid = $_POST['surveyid'];
 		$cidReq=$_REQUEST['cidReq'];
-		$curr_dbname = $_REQUEST['curr_dbname'];
-		header("Location:addanother.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+		header("Location:addanother.php?surveyid=$surveyid&cidReq=$cidReq");
 		//header("Location:select_question_type.php?groupid=$groupid&surveyid=$surveyid&cidReq=$cidReq");
 	    exit;
 }
@@ -206,13 +202,11 @@ if (isset($_POST['addanotherg']))
 	    //$groupid = $_POST['groupid'];
 	    $surveyid = $_POST['surveyid'];
 		$cidReq=$_REQUEST['cidReq'];
-		$curr_dbname = $_REQUEST['curr_dbname'];	
-		header("Location:create_new_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+		header("Location:create_new_group.php?surveyid=$surveyid&cidReq=$cidReq");
 	    exit;
 }
 if(isset($_REQUEST['delete']))
 {
-	$curr_dbname = $_REQUEST['curr_dbname'];
 	if(isset($_REQUEST['qid']))
 	{
 		$endloop=count($_REQUEST['qid']);
@@ -220,13 +214,14 @@ if(isset($_REQUEST['delete']))
 		for($i=0;$i<$endloop;$i++)
 		{
 			$qid2=$qid1[$i];
-			$query="DELETE FROM $curr_dbname.questions WHERE qid='$qid2'";
+			$query="DELETE FROM $table_question WHERE qid='$qid2'";
 			api_sql_query($query);
-			header("Location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+			header("Location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq");
 			exit;
 		}
 	}
 }
+
 if (isset($_POST['finish']))
 {
 		$cidReq=$_REQUEST['cidReq'];
@@ -236,54 +231,52 @@ if (isset($_POST['finish']))
 
 if(isset($action1))
 {
- $curr_dbname = $_REQUEST['curr_dbname'];
- $groupid = $_REQUEST['gid'];
- $surveyid = $_REQUEST['surveyid'];
- $qid = $_GET['qid'];
- $pre_qid = $_GET['pre_qid'];
- $post_qid = $_GET['post_qid'];
- $direction = $_GET['direction'];
- $pre_sort = $_GET['pre_sort'];
- $sort = $_GET['sortby'];
- $post_sort = $_GET['post_sort'];
- if($direction=="up")
- {
-	$sql_update2="UPDATE $curr_dbname.questions SET sortby='".$sort."' WHERE qid='".$pre_qid."'";
-	mysql_query($sql_update2);
-	$sql_update1="UPDATE $curr_dbname.questions SET sortby='".$pre_sort."' WHERE qid='".$qid."'";
+	$groupid = $_REQUEST['gid'];
+	$surveyid = $_REQUEST['surveyid'];
+	$qid = $_GET['qid'];
+	$pre_qid = $_GET['pre_qid'];
+	$post_qid = $_GET['post_qid'];
+	$direction = $_GET['direction'];
+	$pre_sort = $_GET['pre_sort'];
+	$sort = $_GET['sortby'];
+	$post_sort = $_GET['post_sort'];
+ 	if($direction=="up")
+ 	{
+		$sql_update2="UPDATE $table_question SET sortby='".$sort."' WHERE qid='".$pre_qid."'";
+		mysql_query($sql_update2);
+		$sql_update1="UPDATE $table_question SET sortby='".$pre_sort."' WHERE qid='".$qid."'";
+		mysql_query($sql_update1);
+	}
+	else
+	{
+	$sql_update1="UPDATE $table_question SET sortby='".$sort."' WHERE qid='".$post_qid."'";
 	mysql_query($sql_update1);
-		 
- }
-else
-{
-$sql_update1="UPDATE $curr_dbname.questions SET sortby='".$sort."' WHERE qid='".$post_qid."'";
-mysql_query($sql_update1);
-$sql_update2="UPDATE $curr_dbname.questions SET sortby='".$post_sort."' WHERE qid='".$qid."'";
-mysql_query($sql_update2);
+	$sql_update2="UPDATE $table_question SET sortby='".$post_sort."' WHERE qid='".$qid."'";
+	mysql_query($sql_update2);
+	}
+ 	//surveymanager::move_question($direction,$qid,$pre_sort,$sort,$post_sort,$curr_dbname);
 }
 
- //surveymanager::move_question($direction,$qid,$pre_sort,$sort,$post_sort,$curr_dbname);
-}
 Display::display_header($tool_name1);
 api_display_tool_title("Survey Name : ".$sname);
 api_display_tool_title($tool_name);
 if($flag==1)
 {
-?>
-<div align="center"><strong><font color="#FF0000"><?echo get_lang('AlreadyImported');?></font></strong></div>
-<?
+	?>
+	<div align="center"><strong><font color="#FF0000"><?php echo get_lang('AlreadyImported');?></font></strong></div>
+	<?php
 }
 if(isset($messege) && $messege )
 {
-?>
-<div align="center"><strong><font color="#FF0000">Already Imported !</font></strong></div>
-<?
+	?>
+	<div align="center"><strong><font color="#FF0000"><?php echo get_lang('AlreadyImported');?></font></strong></div>
+	<?php
 }
 ?>
+
 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?php echo $cidReq; ?>">
 <input type="hidden" name="action" value="selectquestion_group">
 <input type="hidden" name="newsurveyid" value="<?php echo $surveyid;?>">
-<input type="hidden" name="curr_dbname" value="<?php echo $curr_dbname; ?>">
 <input type="hidden" name="cidReq" value="<?php echo $_REQUEST['cidReq']; ?>">
 <!--<input type="hidden" name="qid" value="<?php echo $_REQUEST['qid']; ?>">
 <input type="hidden" name="direction" value="<?php echo $_REQUEST['direction']; ?>">-->
@@ -306,12 +299,9 @@ if(isset($messege) && $messege )
 </table>
 </form>
 <?php
-/*$query="SELECT * FROM $curr_dbname.survey WHERE survey_id='$surveyid'";
-$result=api_sql_query($query);*/
-    $sql="SELECT * FROM $curr_dbname.survey_group WHERE survey_id='$surveyid' ORDER BY sortby";	
+    $sql="SELECT * FROM $table_survey_group WHERE survey_id='$surveyid' ORDER BY sortby";	
 	$res = api_sql_query($sql,__FILE__,__LINE__);
 	$num=mysql_num_rows($res);	
-	$parameters['curr_dbname']=$curr_dbname;
 	$parameters['surveyid']=$surveyid;
 	$parameters['cidReq']=$cidReq;
 	//$table_header[] = array (' ', false);
@@ -324,13 +314,13 @@ $result=api_sql_query($query);*/
 	$table_header[]=array('',true);
 	$courses = array ();
 	$question_number = 0;
-	if($num){
-		
+	if($num)
+	{
 		for($i=0;$i<$num;$i++)
 		{
 			$groupid=@mysql_result($res,$i,'group_id');
 			$gname=@mysql_result($res,$i,'groupname');
-			$sql="SELECT * FROM $curr_dbname.questions WHERE gid='$groupid' AND survey_id = '$surveyid' order by `sortby` asc";
+			$sql="SELECT * FROM $table_question WHERE gid='$groupid' AND survey_id = '$surveyid' order by `sortby` asc";
 			
 			$res1=api_sql_query($sql,__FILE__,__LINE__);
 			$num1=mysql_num_rows($res1);
@@ -358,19 +348,19 @@ $result=api_sql_query($query);*/
 				$course[] = $question_number.' - '.$question;
 				if($num1==1)
 				{
-				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down></a>&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up></a>';				
+				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down></a>&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up></a>';				
 				}
 				elseif($k==0){
-				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down><img src="../img/down.gif" border="0" title="lang_move_down"></a>&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up></a>';
+				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down><img src="../img/down.gif" border="0" title="lang_move_down"></a>&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up></a>';
 				}elseif($k==$num1-1){
-				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up><img src="../img/up.gif" border="0" title="lang_move_up"></a>';
+				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up><img src="../img/up.gif" border="0" title="lang_move_up"></a>';
 				}
 				else{
-				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down><img src="../img/down.gif" border="0" title="lang_move_down"></a>&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&curr_dbname='.$curr_dbname.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up><img src="../img/up.gif" border="0" title="lang_move_up"></a>';
+				$course[] = '<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=down><img src="../img/down.gif" border="0" title="lang_move_down"></a>&nbsp;&nbsp;&nbsp;'.'<a href='.$_SERVER['PHP_SELF'].'?gid='.$groupid.'&pre_sort='.$pre_sort.'&sortby='.$sort.'&post_sort='.$post_sort.'&surveyid='.$surveyid.'&pre_qid='.$pre_qid.'&qid='.$qid.'&post_qid='.$post_qid.'&cidReq='.$cidReq.'&page_nr='.$page_nr.'&per_page='.$per_page.'&column='.$column.'&action1=moveitem&direction=up><img src="../img/up.gif" border="0" title="lang_move_up"></a>';
 				}				
 				$course[] = mysql_result($res1,$k,'qtype');//$obj->qtype;
 				$course[] = @mysql_result($res,$i,'groupname');	
-				$course[]='<a href="question_edit.php?qid='.$qid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&qtype='.$q_type.'&groupid='.$groupid.'&surveyid='.$surveyid.'"><img src="../img/edit.gif" border="0" align="absmiddle" alt="'.get_lang('Edit').'"/></a>'.'<a href="select_question_group.php?delete=1&qid[]='.$qid.'&cidReq='.$cidReq.'&curr_dbname='.$curr_dbname.'&qtype='.$q_type.'&groupid='.$groupid.'&surveyid='.$surveyid.'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" alt="'.get_lang('Delete').'"/></a>';
+				$course[]='<a href="question_edit.php?qid='.$qid.'&cidReq='.$cidReq.'&qtype='.$q_type.'&groupid='.$groupid.'&surveyid='.$surveyid.'"><img src="../img/edit.gif" border="0" align="absmiddle" alt="'.get_lang('Edit').'"/></a>'.'<a href="select_question_group.php?delete=1&qid[]='.$qid.'&cidReq='.$cidReq.'&qtype='.$q_type.'&groupid='.$groupid.'&surveyid='.$surveyid.'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."'".')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" alt="'.get_lang('Delete').'"/></a>';
 				
 				$courses[] = $course;
 				$x++;
@@ -381,13 +371,13 @@ $result=api_sql_query($query);*/
 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?php echo $cidReq; ?>">
 <input type="hidden" name="groupid" value="<?php echo $groupid; ?>">
 <input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
-<input type="hidden" name="curr_dbname" value="<?php echo $curr_dbname;?>">
 <input type="hidden" name="page" value="<?php echo $page; ?>">
 <?
 if(!empty($courses))
 {
 
-				SurveyManager :: display_sortable_table($groupid,$surveyid,$curr_dbname,$table_header, $courses, array (), array (), $parameters);
+	/** @todo remove $curr_dbname from the parameters. This is not used. */
+	SurveyManager :: display_sortable_table($groupid,$surveyid,$curr_dbname,$table_header, $courses, array (), array (), $parameters);
 
 ?>	
 	<!--<input type="submit" name="delete" value="<?php echo get_lang('Delete');?>">-->
@@ -400,19 +390,13 @@ if(!empty($courses))
 else
 {
 ?>
-    <input type="submit" name="back" value="<?echo get_lang('Back');?>">
-	<input type="submit" name="addanother" value="<?echo get_lang('AddAnotherQuestion');?>">
-	<input type="submit" name="addanotherg" value="<?echo get_lang('AddNewGroup');?>">
+    <input type="submit" name="back" value="<?php echo get_lang('Back');?>">
+	<input type="submit" name="addanother" value="<?php echo get_lang('AddAnotherQuestion');?>">
+	<input type="submit" name="addanotherg" value="<?php echo get_lang('AddNewGroup');?>">
 <?
 }	
 ?>
 </form>
-<!-- question_added-->
 <?php
-/*
-==============================================================================
-		FOOTER 
-==============================================================================
-*/
 Display :: display_footer();
 ?>

+ 38 - 31
main/survey/survey_edit.php

@@ -20,7 +20,7 @@
 /**
 *	@package dokeos.survey
 * 	@author 
-* 	@version $Id: survey_edit.php 10596 2007-01-05 14:09:55Z elixir_inter $
+* 	@version $Id: survey_edit.php 10603 2007-01-06 17:01:47Z pcool $
 */
 /*
 ==============================================================================
@@ -30,9 +30,11 @@
 // name of the language file that needs to be included 
 $language_file = 'survey';
 
+// including the global dokeos file
 include ('../inc/global.inc.php');
-//api_protect_admin_script();
-include (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
+
+// including additional libraries
+require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
 require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
 require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php");
 
@@ -54,32 +56,33 @@ if (!api_is_allowed_to_edit())
 	exit;
 }
 
-// the variables for the days and the months
-// Defining the months of the year to allow translation of the months
+// Database table definitions
+/** @todo use database constants for the survey tables */
+$table_course 				= Database :: get_main_table(TABLE_MAIN_COURSE);
+$table_course_survey_rel 	= Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY);
+$table_survey 				= Database :: get_course_table('survey');
+$tbl_category 				= Database :: get_main_table(TABLE_MAIN_CATEGORY);
+
+// language variables
 $MonthsLong = array(get_lang('JanuaryLong'), get_lang('FebruaryLong'), get_lang('"MarchLong'), get_lang('AprilLong'), get_lang('MayLong'), get_lang('JuneLong'), get_lang('JulyLong'), get_lang('AugustLong'), get_lang('SeptemberLong'), get_lang('OctoberLong'), get_lang('NovemberLong'), get_lang('DecemberLong')); 
+$tool_name = get_lang('ModifySurveyInformation');
+
+
+
 $arr_date = explode("-",date("Y-m-d"));
 $curr_year = $arr_date[0];
 $curr_month = $arr_date[1];
 $curr_day = $arr_date[2];
-$cidReq=$_GET['cidReq'];
-$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
-$table_course_survey_rel = Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY);
-$table_survey = Database :: get_course_table('survey');
-$tbl_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
+
 $noPHP_SELF = true;
-$tool_name = get_lang('ModifySurveyInformation');
+
 $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
-$coursePathWeb = api_get_path(WEB_COURSE_PATH);
-$coursePathSys = api_get_path(SYS_COURSE_PATH);
 $maxFilledSpace = get_setting('default_document_quotum');
 $course_code = $id; //note confusion again: int id - string id - string code...
-$surveyid = $_REQUEST['surveyid'];
 $formSent=0;
 if ($_POST['action'] == 'update_survey')
 {
 	$formSent=1;
-	$cidReq=$_GET['cidReq'];
-    $surveyid=$_REQUEST['surveyid'];
 	$surveycode=$_POST['survey_code'];
 	$surveytitle = $_POST['survey_title'];
 	$surveysubtitle = $_POST['survey_subtitle'];	
@@ -95,9 +98,10 @@ if ($_POST['action'] == 'update_survey')
     $savailabletill=mktime(0,0,0,$_POST['end_fmonth'],$_POST['end_fday'], $_POST['end_fyear']); 
 	$surveytitle=trim($surveytitle);
 	$surveycode=trim($surveycode);
-	if(isset($_POST['back'])){
-	header("location:survey_list.php?cidReq=$cidReq");
-	exit;
+	if(isset($_POST['back']))
+	{
+		header('location:survey_list.php');
+		exit;
 	}
 	if(empty ($surveytitle))
 	{
@@ -111,16 +115,15 @@ if ($_POST['action'] == 'update_survey')
 	}
 	else
     {		
-	  $cidReq = $_GET['cidReq'];
-	  $table_survey = Database :: get_course_table('survey');	   $curr_dbname=SurveyManager::update_survey($surveyid,$surveycode,$surveytitle,$surveysubtitle,$author,$survey_language,$availablefrom,$availabletill,$isshare,$surveytemplate,$surveyintroduction,$surveythanks,$cidReq,$table_course);	  
+	  $curr_dbname=SurveyManager::update_survey($_GET['survey_id'],$surveycode,$surveytitle,$surveysubtitle,$author,$survey_language,$availablefrom,$availabletill,$isshare,$surveytemplate,$surveyintroduction,$surveythanks,$cidReq,$table_course);	  
 		if(isset($_POST['next']))
 		{
-			header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname");
+			header("location:select_question_group.php?surveyid=".$_GET['survey_id']."&cidReq=$cidReq&curr_dbname=$curr_dbname");
 			exit;
 		}
 		else
 		{
-		header("location:survey_list.php?cidReq=$cidReq");
+		header('location:survey_list.php');
 	    exit;
 		}
 	}	
@@ -151,7 +154,11 @@ window.open(inf+".htm", 'popup', 'width=600,height=600,toolbar = no, status = no
 </script>
 <script src=tbl_change.js type="text/javascript" language="javascript"></script>
 <?php
-$sql = "select * from $table_survey where survey_id='$surveyid'";
+/**
+ * Finding the survey we are editing
+ * @todo use a function for this because this is probably a very common functionality 
+ */
+$sql = "SELECT * FROM $table_survey WHERE survey_id='".$_GET['survey_id']."'";
 $res = api_sql_query($sql);
 $obj = mysql_fetch_object($res);
 $arr_avail_from = explode("-",$obj->avail_from);
@@ -167,8 +174,8 @@ $template = $obj->template;
 $lang=$obj->lang;
 
 ?>
-<form name="new_calendar_item" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?php echo $cidReq; ?>">
-<input type="hidden" name="surveyid" value="<?php echo $surveyid; ?>">
+<form name="new_calendar_item" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
+<input type="hidden" name="surveyid" value="<?php echo $_GET['survey_id']; ?>">
 <input type="hidden" name="action" value="update_survey">
 <table>
 <tr>
@@ -195,9 +202,9 @@ $lang=$obj->lang;
   <td><?php echo get_lang('SurveyLanguage'); ?>&nbsp;</td>
   <td>
 	<select name="survey_language">
-    <option value="english" <?if($lang=='english') echo "selected";?>>English</option>
-    <option value="french" <?if($lang=='french') echo "selected";?>>Fran&ccedil;ais</option>
-    <option value="dutch" <?if($lang=='dutch') echo "selected";?>>Nederlands</option>
+    <option value="english" <?php if($lang=='english') echo "selected";?>>English</option>
+    <option value="french" <?php if($lang=='french') echo "selected";?>>Fran&ccedil;ais</option>
+    <option value="dutch" <?php if($lang=='dutch') echo "selected";?>>Nederlands</option>
     </select>
   </td>
 </tr>
@@ -219,7 +226,7 @@ $lang=$obj->lang;
         <!-- month: january ->
 december -->
 <select name="fmonth">
-	<?
+	<?php
 		for($i=1;$i<count($MonthsLong);$i++)
 		{
 			if($i<=9)
@@ -264,7 +271,7 @@ december -->
     <!-- month: january ->
 december -->
 <select name="end_fmonth">
-	<?
+	<?php
 		for($i=1;$i<count($MonthsLong);$i++)
 		{
 			if($i<=9)