This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Overview
Download & View Quiz Component For Joomla as PDF for free.
Quiz component for Joomla How to use the component: - open the Joomla site in one browser - log in as an administrator - install the component from Administrator Panel - open the component frontend page - the first post is a link post - click on link to edit your first quiz
Press Register (Inregistreaza) and the quiz is ready. The syntax for Questions and Answers must follow the rules: SUA ? Washington New YORK Los Angeles Canada ? Ottawa Montreal Toronto Vancouver France ? Paris Marseille Nice Strasbourg
- the question is the first after the tag - the GOOD answer is always the first
You can use HTML code in questions or in answers. You CAN’T use newline “\n” in questions or answers. The newline is used to break the quiz in questions and answers and is reserved. The newline is the last escape character in every row. Usually, you push ENTER to introduce a newline. The quiz will look like this image:
$db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_test WHERE nume_test="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_test=$db->loadResult(); $table_test->load($id_test); $table_test->set('nume_test', $titlu_test); $table_test->set('descriere_test', addslashes($descriere_test)); if ($table_test->check()) { if (!$table_test->store()) { print('
Eroare - functia $table_test->store().
'); } } else { print('
Eroare - functia $table_test->check().
'); } $intrebari_teste=explode("", $editor_test); $j=1; foreach($intrebari_teste as $intrebare) { $intrebare=trim($intrebare); $intrebare1=explode("\n", $intrebare); $i=1; foreach($intrebare1 as $raspuns) { if($i==1) { if(trim($raspuns)=="")
continue; >set('nume_intrebare', $uniqid);
$table_intreb->reset(); $table_intreb-
if (!$table_intreb>store()) print('
Eroare - functia $table_intreb>store().
'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_intrebari WHERE nume_intrebare="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_intrebare=$db>loadResult(); $table_intreb>load($id_intrebare);
'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_raspunsuri WHERE nume_raspuns="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_raspuns=$db->loadResult(); $table_rasp->load($id_raspuns); $table_rasp->set('id_intrebari', $id_intrebare); $table_rasp->set('nume_raspuns', addslashes($raspuns)); if ($table_rasp->check()) { if (!$table_rasp->store()) { print('
'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_test WHERE nume_test="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_test=$db->loadResult(); $table_test->load($id_test); $table_test->set('nume_test', $titlu_test); $table_test->set('descriere_test', addslashes($descriere_test)); if ($table_test->check()) { if (!$table_test->store()) { print('
Eroare - functia $table_test->store().
'); } } else { print('
Eroare - functia $table_test->check().
'); } $intrebari_teste=explode("", $editor_test); $j=1; foreach($intrebari_teste as $intrebare) { $intrebare=trim($intrebare); $intrebare1=explode("\n", $intrebare); $i=1; foreach($intrebare1 as $raspuns) { if($i==1) { if(trim($raspuns)=="")
continue; >set('nume_intrebare', $uniqid);
$table_intreb->reset(); $table_intreb-
if (!$table_intreb>store()) print('
Eroare - functia $table_intreb>store().
'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_intrebari WHERE nume_intrebare="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query);
'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_raspunsuri WHERE nume_raspuns="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_raspuns=$db->loadResult(); $table_rasp->load($id_raspuns); $table_rasp->set('id_intrebari', $id_intrebare); $table_rasp->set('nume_raspuns', addslashes($raspuns)); if ($table_rasp->check()) { if (!$table_rasp->store()) { print('
'); print(''); $tip_user="Super Administrator"; // setam titlul ce apare in browser $document =& JFactory::getDocument(); $document->setTitle("Teste de cunoastere"); // setam parametrii pentru bara de navigatie $limit = 20; $limitstart = JRequest::getVar('limitstart',0); $limitstart = 0 + intval($limitstart); $total = 0; //numarul total de articole // obtinem o refeinta la clasa JUser $user =& JFactory::getUser(); // obtinem o referinta la baza de date $db =& JFactory::getDBO(); // avem interogari diferite pentru un user obisnuit si un administrator // administratorul poate sa aiba acces la toate inregistrarile, si la cele marcate ca nepublicate // interogarea urmatoare va intoarce numarul total de teste din baza de date; informatia este necesara pentru bara de navigatie if($user->usertype==$tip_user) $query="SELECT count(*) FROM `jos_cunoastere_test` WHERE 1 "; else
Page 30 $query="SELECT * FROM `jos_cunoastere_test` WHERE `published`=1 ORDER BY `id` DESC LIMIT 0,30"; $db->setQuery($query); $rows = $db->loadObjectList(); $document->description="Fluxul RSS pentru componenta de teste"; foreach ($rows as $row) { $item = new JFeedItem(); $item->description =stripslashes($row>descriere_test)." "." "; $item->link = JRoute::_('index.php?option=com_componentamea&task=view_test&id='.$ro w->id); $item->title = $row->nume_test; $document->addItem($item); } jimport('joomla.utilities.date'); $date1 = new JDate(); $item->description=$date1->toFormat('%d-%m-%Y'); $item->link = JRoute::_('index.php?option=com_componentamea'); $item->title = "Data de generare a fluxului"; $document->addItem($item); $document->render(); ?>
File componenta mea.xml Componenta meaMartie 2009Farcas Adrian[email protected]http://24secunde.comCopyrightLicentaVersiunea 1.0 <description>Componenta de test <menu>Admin Teste <submenu> <menu task="rezult_test" img="js/ThemeOffice/component.png">Administrare rezultate teste <menu task="admin_test" img="js/ThemeOffice/component.png">Administrare teste admin.componentamea.phpadmin.edit.phpadmin.principal.php
Page 31 admin.publish.phpadmin.remove.phpadmin.rezultate.phpadmin.unpublish.phpcomponenta mea.xmlconfig.xmlindex.phptoolbar.componentamea.phpimaginitablesDROP DROP DROP DROP
CREATE TABLE `jos_cunoastere_intrebari` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `nume_intrebare` TEXT NOT NULL ) CREATE TABLE `jos_cunoastere_raspunsuri` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_intrebari` INT NOT NULL, `nume_raspuns` TEXT NOT NULL ) CREATE TABLE `jos_cunoastere_test` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `nume_test` TEXT NOT NULL , `descriere_test` TEXT NOT NULL , `published` TINYINT( 1 ) NOT NULL DEFAULT 0 ) CREATE TABLE `jos_cunoastere_user` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `user` VARCHAR(255) NOT NULL, `punctaj` INT NOT NULL DEFAULT 0 )
Download http://24secunde.com/joomla/media/com_componentamea.zip
Page 32 INSERT INTO `jos_cunoastere_test` ( `id` , `nume_test` , `descriere_test` , `published` ) VALUES ( '', 'Primul tau test aici / Your first quiz here:', 'Log in as Administrator and click: index.php?option=com_componentamea&task=adauga', '1' ) ]]> DROP TABLE DROP TABLE DROP TABLE DROP TABLE
File config.xml <params> <param name="zona1" type="text" default="" label="Zona de publicitate 1" description="Selecteaza modulul pentru zona de publicitate 1" size="3" /> <param name="zona2" type="text" default="" label="Zona de publicitate 2" description="Selecteaza modulul pentru zona de publicitate 2" size="3" />
Page 36 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `nume_intrebare` TEXT NOT NULL ); */ // cream variabile pentru fiecare camp din tabel si dam fiecarei valori o valoare implicita var $id = null; var $id_test=NULL; var $nume_intrebare=NULL; // functia constructor are ca parametru o referinta la baza de date function __construct( &$db ) { parent::__construct('#__cunoastere_intrebari', 'id', $db); } // validarea datelor daca este cazul function check() { if(!$this->id_test) { $this->setError(JText::_('Eroare - lipseste campul ID din tabela TEST.')); return false; } if(!$this->nume_intrebare) { $this->setError(JText::_('Eroare - intrebarea nu poate fi vida.')); return false; } return true; } } ?>
Page 37 var $id = null; var $id_intrebari=NULL; var $nume_raspuns=NULL; // functia constructor are ca parametru o referinta la baza de date function __construct( &$db ) { parent::__construct('#__cunoastere_raspunsuri', 'id', $db); } // validarea datelor daca este cazul; function check() { if(!$this->id_intrebari) { $this->setError(JText::_('Eroare - lipseste campul ID din tabela INTREBARI.')); return false; } if(!$this->nume_raspuns) { $this->setError(JText::_('Eroare - testul nu are definit un raspuns.')); return false; } return true; } } ?>
Page 38 parent::__construct('#__cunoastere_test', 'id', $db); } // validarea datelor daca este cazul; verificam ca testul sa aiba un titlu si o descriere function check() { if(!$this->nume_test) { $this->setError(JText::_('Eroare - testul nu are definit un titlu.')); return false; } if(!$this->descriere_test) { $this->setError(JText::_('Eroare - testul nu are definita o descriere.')); return false; } return true; } } ?>