123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?php
- /*
- ==============================================================================
- Dokeos - elearning and course management software
- Copyright (c) 2004 Dokeos S.A.
- Copyright (c) 2003 University of Ghent (UGent)
- Copyright (c) 2001 Universite catholique de Louvain (UCL)
- Copyright (c) Olivier Brouckaert
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- See the GNU General Public License for more details.
- Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
- ==============================================================================
- */
- /**
- ==============================================================================
- @author Bart Mollet
- * @package dokeos.admin
- ==============================================================================
- */
- /*
- ==============================================================================
- INIT SECTION
- ==============================================================================
- */
- $langFile = 'survey';
- require ('../inc/global.inc.php');
- //api_protect_admin_script();
- require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
- require_once (api_get_path(LIBRARY_PATH)."/surveymanager.lib.php");
- $status = surveymanager::get_status();
- if($status==5)
- {
- api_protect_admin_script();
- }
- $interbredcrump[] = array ("url" => "survey_list.php", "name" => get_lang('Survey'));
- $cidReq = $_REQUEST['cidReq'];
- $db_name = $_REQUEST['db_name'];
- $curr_dbname = $_REQUEST['curr_dbname'];
- $tool_name = get_lang('SelectQuestion');
- $Sname = get_lang('SurveyName');
- $GName = get_lang('groupname');
- $Author = get_lang('Author');
- $surveyid=$_REQUEST['surveyid'];
- $groupid=$_REQUEST['groupid'];
- $sid = $_REQUEST['sid'];
- //$sname =surveymanager::get_surveyname($surveyid,$db_name);
- $table_group = Database :: get_course_table('survey_group');
- $table_question = Database :: get_course_table('questions');
- $gide=$_POST['course'];
- $arraycount=0;
- $arraycount=count($_REQUEST['course']);
- if($_REQUEST['gid1'])
- {
- $gid1=explode(",",$_REQUEST['gid1']);
- }
- else
- {
- $gid1=$_REQUEST['course'];
- }
- for($r=0;$r<count($gid1);$r++)
- {
- if($r<count($gid1)-1)
- $str.=$gid1[$r].",";
- else
- $str.=$gid1[$r];
- }
- $arraycount=0;
- $arraycount=count($_REQUEST['course']);
- if(isset($_POST['back1']))
- {
- $db_name = $_REQUEST['db_name'];
- $curr_dbname = $_REQUEST['curr_dbname']; header("location:existing_surveys_new.php?cidReq=$cidReq&db_name=$db_name&surveyid=$surveyid&groupid=$groupid&curr_dbname=$curr_dbname");
- exit;
- }
- if(isset($_POST['view']))
- {
- if($arraycount<=0)
- {
- $pls=1;
- $db_name = $_REQUEST['db_name'];
- $curr_dbname = $_REQUEST['curr_dbname']; header("location:group_list.php?cidReq=$cidReq&surveyid=$surveyid&groupid=$groupid&pls=$pls&db_name=$db_name&sid=$sid");
- exit;
- }
- }
- if(isset($_POST['back']))
- {
- $pls=0;
- $sid = $_REQUEST['sid'];
- $db_name = $_REQUEST['db_name'];
- $surveyid=$_REQUEST['surveyid'];
- $curr_dbname = $_REQUEST['curr_dbname']; header("location:group_list.php?cidReq=$cidReq&db_name=$db_name&curr_dbname=$curr_dbname&surveyid=$surveyid&sid=$sid&pls=$pls");
- exit;
- }
- if(isset($_POST['import']))
- {
- if($arraycount<=0)
- {
- $pls=1;
- $db_name = $_REQUEST['db_name'];
- $curr_dbname = $_REQUEST['curr_dbname']; header("location:group_list.php?cidReq=$cidReq&surveyid=$surveyid&groupid=$groupid&pls=$pls&db_name=$db_name&sid=$sid&curr_dbname=$curr_dbname");
- exit;
- }
- else
- {
- $gid_arr = $_REQUEST['course'];
- $db_name = $_REQUEST['db_name'];
- $curr_dbname = $_REQUEST['curr_dbname'];
- $gids = implode(",",$gid_arr);
- $surveyid = $_POST['surveyid'];
- $groupid = $_POST['groupid'];
- //$flag = surveymanager::insert_old_groups($surveyid,$gids,$table_group,$table_question,$db_name,$cidReq);
- //$message_me = surveymanager::import_group($surveyid,$gids,$db_name,$curr_dbname);
- $flag = surveymanager::import_group($surveyid,$gids,$db_name,$curr_dbname);
- header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&flag=$flag&curr_dbname=$curr_dbname");
- exit;
- }
- }
- if(isset($_POST['importquestion']))
- {
- $gidnext=$_POST['gid1'];
- $surveyid = $_POST['surveyid'];
- $groupid = $_POST['groupid'];
- $db_name = $_REQUEST['db_name'];
- $curr_dbname = $_REQUEST['curr_dbname'];
- $selectcount=count($_POST['question']);
- if($selectcount<=0)
- {
- $error_message=get_lang("PleaseSelectAChoice");
- }
- else
- {
- $qid_arr = $_REQUEST['question'];
- $qids = implode(",",$qid_arr);
- $message_me=surveymanager::question_import($surveyid,$qids,$db_name,$curr_dbname);
- if(isset($message_me) && $message_me)
- {
- header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&messege=$message_me");
- exit;
- }
- else
- {
- header("location:select_question_group.php?surveyid=$surveyid&cidReq=$cidReq&curr_dbname=$curr_dbname&messege=$message_me");
- exit;
- }
- }
- }
- Display :: display_header($tool_name);
- if( isset($error_message) )
- {
- Display::display_error_message($error_message);
- }
- ?>
- <SCRIPT LANGUAGE="JavaScript">
- function displayTemplate(url) {
- window.open(url, 'popup', 'width=600,height=800,scrollbars=yes,toolbar = no, status = no');
- }
- </script>
- <table>
- <tr>
- <td><strong><? echo get_lang('SurveyName'); ?></strong></td>
- <td><?echo $sname;?></td>
- </tr>
- <tr><td></td></tr>
- <tr><td></td></tr>
- </table>
- <?php
- echo get_lang('SelectQuestion');
- ?>
- <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?cidReq=<?=$cidReq?>">
- <input type="hidden" name="action" value="add_survey"/>
- <input type="hidden" name="surveyid" value="<?=$surveyid?>">
- <input type="hidden" name="sid" value="<?=$sid?>">
- <input type="hidden" name="groupid" value="<?=$groupid?>">
- <input type="hidden" name="gid1" value="<?=$str?>">
- <input type="hidden" name="db_name" value="<?=$db_name?>">
- <input type="hidden" name="curr_dbname" value="<?=$curr_dbname;?>">
- <?
- $questions = array ();
- $cidReq=$_GET['cidReq'];
- $endloop=count($gid1);
- $datacount=0;
- $parameters = array ();
- $parameters['surveyid']=$surveyid;
- $parameters['sid']=$sid;
- $parameters['groupid']=$groupid;
- $parameters['cidReq']=$cidReq;
- $parameters['db_name']=$db_name;
- $parameters['curr_dbname']=$curr_dbname;
- $parameters['gid1']=$str;
- for($i=0;$i<$endloop;$i++)
- {
- $gidi=$gid1[$i];
- $sql = "SELECT * FROM $db_name.questions WHERE gid='$gidi' AND survey_id = '$sid'";
- $res = api_sql_query($sql,__FILE__,__LINE__);
- while ($obj = mysql_fetch_object($res))
- {
- $question = array ();
- $question[] = '<input type="checkbox" name="question[]" value="'.$obj->qid.'"/>';
- $question[] = $obj->caption;
- $question[] = $obj->qtype;
- $groupid = $obj->gid;
- $GName = surveymanager::get_groupname($db_name,$groupid);
- $question[] = $GName;
- $sid = surveymanager::get_surveyid($db_name,$groupid);
- $sname = surveymanager::get_surveyname($db_name,$sid);
- $question[] = $sname;
- /**********for displaying the 'edit' 'delete' etc. buttons***********/
- $url = "default.php?qid=".$obj->qid."&qtype=".$obj->qtype."&cidReq=".$cidReq."&surveyid=".$surveyid."&groupid=".$groupid."&db_name=".$db_name;
- $question[] = "<a href=\"#\" onClick=\"displayTemplate('".$url."')\"><img src=\"../img/info_small.gif\" border=\"0\" align=\"absmiddle\" alt=\"".get_lang('Info')."\" /></a>";
- $questions[] = $question;
- $datacount++;
- }
- }
- $table_header[] = array (' ', false);
- $table_header[] = array (get_lang('Question'), true);
- $table_header[] = array (get_lang('QuestionType1'), true);
- $table_header[] = array (get_lang('Group'),true);
- $table_header[] = array (get_lang('surveyname'),true);
- $table_header[] = array('', false);
- if($datacount>0)
- Display :: display_sortable_table($table_header, $questions, array (), array (), $parameters);
- else
- {
- $noquestions=get_lang("NoQuestionAvailableInThisGroup");
- api_display_tool_title($noquestions);
- }
- ?>
- <table>
- <tr>
- <td><input type="submit" name="back" value="<?echo get_lang("back");?>"></td>
- <td><input type="submit" name="importquestion" value="<? echo get_lang('ImportQuestion');?>"></td>
- </tr>
- </table>
- </form>
- <?php
- Display :: display_footer();
- ?>
|