⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compquest.php

📁 太烦了
💻 PHP
📖 第 1 页 / 共 2 页
字号:
   * Display the Sections Page   *   * @return string   * @access public   */  function getSections()  {   		$j=0;//   		$getdata = $this->modGetAll($this->lang_qsection_table,array(),'ord');  		$getdata=$GLOBALS['db']->getAll("SELECT * FROM ! ORDER BY ord",array(DB_PREFIX."_".$this->lang_qsection_table));   				$this->modSmartyAssign('data',$getdata);		$text=$this->modSmartyFetch("admin/section.tpl");		return $text;  }  /**   * Display the Edit Section Page   *   * @return string   * @access public   */  function showEditSection($section)  {  	$getdata=$this->modGetRow($this->lang_qsection_table,array('sid'=>$section));	$this->modSmartyAssign('data',$getdata);	$text=$this->modSmartyFetch("admin/sectionedit.tpl");	return $text;  }    /**   * Delete section with ID $section   *   * @return none   * @access public   */  function deleteSection($section)  {		$ord=$this->modGetOne($this->lang_qsection_table,array('sid'=>$section),'ord');		$this->modDeleteRows($this->lang_qsection_table,array('sid'=>$section));		$GLOBALS['db']->query("UPDATE ! SET ord=ord-1 WHERE ord>?",array(DB_PREFIX."_".$this->lang_qsection_table,$ord));  }   /**   * Add section with title $title   *   * @return none   * @access public   */  function addSection($title)  {		$number=$this->modGetOne($this->lang_qsection_table,array(),'count(*)');		$number++;		if($title)			$this->modAddRec($this->lang_qsection_table,array('title'=>$title,'ord'=>$number));  }  /**   * Display the Questions Page of Section with id $section   *   * @return string   * @access public   */  function getQuestions($section)  {//  	$getdata=$this->modGetAll($this->lang_qquestion_table,array('sid'=>$section),'ord');  	$getdata=$GLOBALS['db']->getAll("SELECT * FROM ! WHERE sid=? ORDER BY ord",array(DB_PREFIX."_".$this->lang_qquestion_table,$section));	$this->modSmartyAssign('data',$getdata);	$this->modSmartyAssign('sid',$section);	$text=$this->modSmartyFetch("admin/showquestions.tpl");	return $text;  }   /**   * Returns the section ID corresponding the Question with id $qid   *   * @return integer   * @access public   */  function getSectionID($qid)  {  	return $this->modGetOne($this->lang_qquestion_table,array('qid'=>$qid),'sid');  }   /**   * Returns the question ID corresponding the answer with id $qcid   *   * @return integer   * @access public   */  function getQuestionID($qcid)  {  	return $this->modGetOne($this->lang_qcontent_table,array('qcid'=>$qcid),'qid');  }   /**   * Display the Add Question page (in section with id $section)   *   * @return string   * @access public   */  function showAddQuestion($section)  {  	$getdata=$this->modGetRow($this->lang_qsection_table,array('sid'=>$section));  	$this->modSmartyAssign('data',$getdata);	$text=$this->modSmartyFetch("admin/addquestion.tpl");	return $text;  }   /**   * Delete Question with id $qid   *   * @return none   * @access public   */  function deleteQuestion($qid)  {  	$row=$this->modGetRow($this->lang_qquestion_table,array('qid'=>$qid));	$ord=$row['ord'];	$sid=$row['sid'];	$this->modDeleteRows($this->lang_qquestion_table,array('qid'=>$qid));  	$GLOBALS['db']->query("UPDATE ! SET ord=ord-1 WHERE ord>?",array(DB_PREFIX."_".$this->lang_qquestion_table,$ord));  }   /**   * Display the Edit Question page. (edits question with id $qid)   *   * @return string   * @access public   */  function showEditQuestions($qid)   {   	if($this->error==0)   	{   	if(isset($_POST['delete']))	{		$qcid=$_POST['delete'];		$ord=$this->modGetOne($this->lang_qcontent_table,array('qcid'=>$qcid),'ord');		$this->modDeleteRows($this->lang_qcontent_table,array('qcid'=>$qcid));		$GLOBALS['db']->query("UPDATE ! SET ord=ord-1 WHERE ord>? AND qid=?",array(DB_PREFIX."_".$this->lang_qcontent_table,$ord,$qid));	}	if(isset($_POST['edit']))	{		$i=0;		$nr=$this->modGetOne($this->lang_qcontent_table,array('qid'=>$qid),'count(*)');		while (isset($_POST['ans'.$i])) {			$ans[$i]=$_POST['ans'.$i];			if($ans[$i])					{						$nr++;						$this->modAddRec($this->lang_qcontent_table,array('answer'=>$ans[$i],'qid'=>$qid,'ord'=>$nr));					}			$i++;		}		$question=$_POST['question'];		$maxopt=$_POST['maxopt'];		$minopt=$_POST['minopt'];		$showopt=$_POST['showopt'];		if(!$question||!$maxopt||$maxopt==1)		{			$this->error=1;			$this->modSmartyAssign('error',1);			return $this->showEditQuestions($qid);		}		$this->modEditRec($this->lang_qquestion_table,array('question'=>$question,'maxopt'=>$maxopt,'minopt'=>$minopt,'showopt'=>$showopt),array('qid'=>$qid));	}   	}	$row=$this->modGetRow($this->lang_qquestion_table,array('qid'=>$qid));	$question=$row['question'];	$maxopt=$row['maxopt'];	$minopt=$row['minopt'];	$showopt=$row['showopt'];	$type=$row['type'];	$type="questiontype".$type;	$this->modSmartyAssign('question',$question);   	$this->modSmartyAssign('sid',$this->getSectionID($qid));   	$this->modSmartyAssign('qid',$qid);   	$this->modSmartyAssign('type',$type);   	$this->modSmartyAssign('maxopt',$maxopt);   	$this->modSmartyAssign('minopt',$minopt);   	$this->modSmartyAssign('showopt',$showopt);   	if($_POST['addbtn']) $add=$_POST['add'];   	for($i=0;$i<$add;$i++)   		$answer[$i]="ans$i";   	$this->modSmartyAssign('answer',$answer);  	$getdata=$GLOBALS['db']->getAll("SELECT * FROM ! WHERE qid=? ORDER BY ord",array(DB_PREFIX."_".$this->lang_qcontent_table,$qid));	$this->modSmartyAssign('data',$getdata);   	$text=$this->modSmartyFetch("admin/showqcontent.tpl");   	return $text;   }  /**   * Adds new question in section with id $sid; Returns error if there is one   * Other parameters: $question=Question text;   * 				   $type = question type : 1- Radio-Buttons; 2- Check-Boxes; 3- Text;   * 				   $maxopt = Max Option;   *   * @return string   * @access public   */	function addQuestion($sid,$question,$type,$maxopt,$minopt,$showopt)	{		$number=$this->modGetOne($this->lang_qquestion_table,array('sid'=>$sid),'count(*)');		$number++;		if(!$minopt)$minopt=0;		if($type==1 && !$showopt) $showopt=0;		if($type==2 && !$showopt) $showopt=4;		if(!$question || !$maxopt||$maxopt==1) {$this->modSmartyAssign('error',1);			$data2['showopt']=$showopt;			$data2['maxopt']=$maxopt;			$data2['minopt']=$minopt;			$data2['question']=$question;			$data2['type']=$type;			$this->modSmartyAssign('data2',$data2);			return $this->showAddQuestion($sid);		}		$this->modAddRec($this->lang_qquestion_table,array('question'=>$question,'type'=>$type,'sid'=>$sid,'maxopt'=>$maxopt,'ord'=>$number,'minopt'=>$minopt,'showopt'=>$showopt));	}  /**   * Does the processing to display a admin page.  Called from plugin.php   *   * @return array   * @access public   */   function  displayPluginAdminPage() {   	$this->modSmartyAssign('lang', $this->modGetLang());   	$this->modSmartyAssign('plugin_name',$this->plugin_class_name);	$do=$_GET['do'];	if(!$do)	{		$text=$this->getSections();	}	if($do=="addsection")	{		if($_GET['add'])		{			$title=$_POST['title'];			$this->addSection($title);			$text=$this->getSections();		}	}	if($do=="delsection")	{		$section=$_POST['txtid'];		$this->deleteSection($section);		$text=$this->getSections();	}	if($do=="editsection")	{		if(isset($_POST['edit']))		{			$section=$_POST['section'];			$title=$_POST['title'];			if(!$title)			{				$this->error=1;				$this->modSmartyAssign('error',1);				$text=$this->showEditSection($section);			}			else			{				$this->modEditRec($this->lang_qsection_table,array('title'=>$title),array('sid'=>$section));				$text=$this->getSections();			}		}		else		{			$section=$_GET['section'];			$text=$this->showEditSection($section);		}	}	if($do=="showquestions")	{		$section=$_GET['section'];		$text=$this->getQuestions($section);	}	if($do=="addquestion")	{		if($_GET['add'])		{			$sid=$_POST['section'];			$question=$_POST['question'];			$type=$_POST['type'];			$maxopt=$_POST['maxopt'];			$minopt=$_POST['minopt'];			$showopt=$_POST['showopt'];			$text=$this->addQuestion($sid,$question,$type,$maxopt,$minopt,$showopt);			if(!$text)				$text=$this->getQuestions($sid);		}		else {		$section=$_GET['section'];		$text=$this->showAddQuestion($section);		}	}		if($do=="delquestion")	{		$qid=$_POST['txtid'];		$section=$this->getSectionID($qid);		$this->deleteQuestion($qid);		$text=$this->getQuestions($section);	}		if($do=="editquestion")	{		$qid=$_GET['qid'];		$text=$this->showEditQuestions($qid);	}		if($do=="editanswer")		{			if($_POST['edit2'])			{				$qcid=$_POST['qcid'];				$answer=$_POST['answer'];				$this->modEditRec($this->lang_qcontent_table,array('answer'=>$answer),array('qcid'=>$qcid));				$text=$this->showEditQuestions($this->getQuestionID($qcid));			}			else {			$qcid=$_GET['qcid'];			$data=$this->modGetRow($this->lang_qcontent_table,array('qcid'=>$qcid));			$this->modSmartyAssign("data",$data);			$text=$this->modSmartyFetch("admin/answeredit.tpl");			}		}		if ($do=="moveup")	{		$section=$_GET['section'];		$ord=$this->modGetOne($this->lang_qsection_table,array('sid'=>$section),'ord');		$ord--;		$ord2=$ord+1;		$section2=$this->modGetOne($this->lang_qsection_table,array('ord'=>$ord),'sid');		if($ord)		{			$this->modEditRec($this->lang_qsection_table,array('ord'=>$ord),array('sid'=>$section));			$this->modEditRec($this->lang_qsection_table,array('ord'=>$ord2),array('sid'=>$section2));		}		$text=$this->getSections();	}			if ($do=="movequp")	{		$qid=$_GET['qid'];		$ord=$this->modGetOne($this->lang_qquestion_table,array('qid'=>$qid),'ord');		$ord--;		$ord2=$ord+1;		$sid=$this->getSectionID($qid);		$qid2=$this->modGetOne($this->lang_qquestion_table,array('ord'=>$ord),'qid');		if($ord)		{			$this->modEditRec($this->lang_qquestion_table,array('ord'=>$ord),array('qid'=>$qid));			$this->modEditRec($this->lang_qquestion_table,array('ord'=>$ord2),array('qid'=>$qid2));		}		$text=$this->getQuestions($sid);	}			if ($do=="moveqcup")	{		$qcid=$_GET['qcid'];		$ord=$this->modGetOne($this->lang_qcontent_table,array('qcid'=>$qcid),'ord');		$ord--;		$ord2=$ord+1;		$qid=$this->getQuestionID($qcid);		$qcid2=$this->modGetOne($this->lang_qcontent_table,array('ord'=>$ord,'qid'=>$qid),'qcid');		if($ord)		{			$this->modEditRec($this->lang_qcontent_table,array('ord'=>$ord),array('qcid'=>$qcid));			$this->modEditRec($this->lang_qcontent_table,array('ord'=>$ord2),array('qcid'=>$qcid2));		}		$text=$this->showEditQuestions($qid);	}		if ($do=="movedown")	{		$section=$_GET['section'];		$ord=$this->modGetOne($this->lang_qsection_table,array('sid'=>$section),'ord');		$ord++;		$ord2=$ord-1;		$section2=$this->modGetOne($this->lang_qsection_table,array('ord'=>$ord),'sid');		$max=$this->modGetOne($this->lang_qsection_table,array(),'count(*)');		if($ord<=$max)		{			$this->modEditRec($this->lang_qsection_table,array('ord'=>$ord),array('sid'=>$section));			$this->modEditRec($this->lang_qsection_table,array('ord'=>$ord2),array('sid'=>$section2));		}		$text=$this->getSections();	}		if ($do=="moveqdown")	{		$qid=$_GET['qid'];		$ord=$this->modGetOne($this->lang_qquestion_table,array('qid'=>$qid),'ord');		$ord++;		$ord2=$ord-1;		$sid=$this->getSectionID($qid);		$qid2=$this->modGetOne($this->lang_qquestion_table,array('ord'=>$ord),'qid');		$max=$this->modGetOne($this->lang_qquestion_table,array('sid'=>$sid),'count(*)');		if($ord<=$max)		{			$this->modEditRec($this->lang_qquestion_table,array('ord'=>$ord),array('qid'=>$qid));			$this->modEditRec($this->lang_qquestion_table,array('ord'=>$ord2),array('qid'=>$qid2));		}		$text=$this->getQuestions($sid);	}		if ($do=="moveqcdown")	{		$qcid=$_GET['qcid'];		$ord=$this->modGetOne($this->lang_qcontent_table,array('qcid'=>$qcid),'ord');		$qid=$this->getQuestionID($qcid);		$ord++;		$ord2=$ord-1;		$qcid2=$this->modGetOne($this->lang_qcontent_table,array('ord'=>$ord,'qid'=>$qid),'qcid');		$max=$this->modGetOne($this->lang_qcontent_table,array('qid'=>$qid),'count(*)');		if($ord<=$max)		{			$this->modEditRec($this->lang_qcontent_table,array('ord'=>$ord),array('qcid'=>$qcid));			$this->modEditRec($this->lang_qcontent_table,array('ord'=>$ord2),array('qcid'=>$qcid2));		}		$text=$this->showEditQuestions($qid);	}	return $text;   }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -