Quiz Component For Joomla

  • Uploaded by: farcas adrian
  • 0
  • 0
  • April 2020
  • PDF

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.

More details

  • Words: 3,826
  • Pages: 39
Page 1

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

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 2

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:

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 3

The component files:

File adauga_test.php: usertype!="Super Administrator") $mainframe>redirect('index.php'); ?>
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 4

if($previz=="Previzualizare") { $titlu_test=JRequest::getVar('titlu_test',''); $editor_test=JRequest::getString('editor_test', '', 'POST', JREQUEST_ALLOWRAW); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); print("

".$titlu_test."

"); print("
"); print("".$descriere_test.""); print("
"); print("
"); $intrebari_teste=explode("", $editor_test); foreach($intrebari_teste as $intrebare) { $intrebare=trim($intrebare); $intrebare1=explode("\n", $intrebare); $i=1; foreach($intrebare1 as $raspuns) {

if($i==1) {

print("

".$raspuns."

");

$i++; continue; } print('
type="radio" value="">');

print("
"); } print("
"); }

}

print($raspuns); print("
");

if($previz=="Inregistreaza") { $titlu_test=JRequest::getVar('titlu_test',''); $editor_test=JRequest::getString('editor_test', '', 'POST', JREQUEST_ALLOWRAW); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); $table_test->reset(); $uniqid=uniqid(""); $table_test->set('nume_test', $uniqid); if (!$table_test->store()) print('

Eroare - functia $table_test->store().

');

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 5

$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);

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 6

>set('id_test', $id_test);

$table_intreb-

$table_intreb>set('nume_intrebare', addslashes( $raspuns)); if ($table_intreb->check()) { if (!$table_intreb-

>store())

{ print('

Eroare - functia $table_intreb->store().

'); } } else { print('

Eroare functia $table_intreb->check().

'); } $table_intreb->load(0); $i++; continue; } if(trim($raspuns)=="") continue; $table_rasp->reset(); $table_rasp->set('nume_raspuns',

$uniqid);

if (!$table_rasp->store()) print('

Eroare - functia $table_rasp->store().

'); $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('

Eroare functia $table_rasp->store().

'); } } else { print('

Eroare - functia $table_rasp->check().

'); } $table_rasp->load(0); } } $mainframe>redirect('index.php?option=com_componentamea&task=adauga');

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 7 } if($previz=="Reinitializeaza") { $mainframe>redirect('index.php?option=com_componentamea&task=adauga'); } ?> <script type="text/javascript"> function introduceti_entitate(tip) { if(tip=="intrebare") document.getElementById("editor_test").value=document.getElementById( "editor_test").value+""; if(tip=="raspuns") document.getElementById("editor_test").value=document.getElementById( "editor_test").value+""; if(tip=="break") document.getElementById("editor_test").value=document.getElementById( "editor_test").value+""; }
<strong>Introduceti un titlu pentru testul dumneavoastra: <strong>Introduceti o descriere pentru testul dumneavoastra: <strong>Introduceti intrebarile care compun testul dumneavoastra:


File admin.componentamea.php: Restricted access.'); ?>

File admin.edit.php: Restricted access.'); ?>
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 9 $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); ');

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_test->load($id);

$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().

'); } $mainframe>redirect('index.php?option=com_componentamea&task=edit&mesaj=salvat& cid[]='.$id.''); }

if($task== "cancel") { $mainframe>redirect('index.php?option=com_componentamea&task=admin_test'); } $mesaj = JRequest::getVar( 'mesaj', ''); if($mesaj=="salvat") { JError::raiseNotice('','Modificarile au fost efectuate.'); } $query="SELECT `id` , `nume_test` , `descriere_test`, `published` FROM `jos_cunoastere_test` WHERE id=".$id.""; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { print('
'); print('
'); print('<strong>Introduceti un titlu pentru testul dumneavoastra:'); print('');

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 10 print('<strong>Introduceti o descriere pentru testul dumneavoastra:'); print(''); print(''); print('
'); print('
'); } JRequest::setVar('hidemainmenu', 1); ?>

File admin.principal.php Restricted access.'); ?>
<script type="text/javascript"> function stabileste_ordinea(param) { document.getElementById("ord_txt").value=param; document.getElementById("ord_txt").form.submit(); }
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 11 $db =& JFactory::getDBO(); $db->setQuery('SELECT count(*) FROM `jos_cunoastere_test`'); $total = $db->loadResult(); $limit = $mainframe>getUserStateFromRequest("limit",'limit',$mainframe>getCfg('list_limit')); if($limit==0)$limit=500; $limitstart = $mainframe>getUserStateFromRequest("$option.view.limitstart",'limitstart',0); $query='SELECT * FROM `jos_cunoastere_test` ORDER BY id '.$ordine.' LIMIT '.$limitstart.','.$limit.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); $int_j=0; foreach ($rows as $row) { ?> '); print('var nr_chk='.$int_j); print(''); ?>
# Numele testului Descrierea testului Publicare test [Id]
id.'">'.$row->nume_test.'');?> descriere_test));?> published==1) print(' No'); if($row->published==0) print(' No'); ?> id);?>

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 12 $pageNav = new JPagination($total,$limitstart,$limit); print($pageNav->getListFooter()); ?>


File admin.publish.php Restricted access.'); ?> load($id); $table_test->set('published',1); if ($table_test->check()) { if (!$table_test->store()) { print('

Eroare - functia $table_test->store().

'); } } else { print('

Eroare - functia $table_test->check().

'); } ?> redirect('index.php?option=com_componentamea'); ?>

File admin.remove.php

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 13

Restricted access.'); ?> }]'; $test=JRequest::getVar('test_del',0); $test=0+$test; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_user = JTable::getInstance('cunoastere_user', 'Table'); $query='SELECT `id` FROM `jos_cunoastere_user` WHERE id_test='.$test.' OR user LIKE "'.$user.'%"'; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $table_user->delete($row->id); } $mainframe>redirect('index.php?option=com_componentamea&task=rezult_test'); ?>

File admin.rezultate.php Restricted access.'); ?>

Sterge rezultatele utilizatorului:

(Ex: Ion, Rizache, John) % - sterge tot

Sterge rezultatele care includ testul:

(Ex: 1, 100, 2000)




File admin.unpublish.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 14 // nu permite accesul direct la acest fisier defined('_JEXEC') or die('
Restricted access.
'); ?> load($id); $table_test->set('published',0); if ($table_test->check()) { if (!$table_test->store()) { print('

Eroare - functia $table_test->store().

'); } } else { print('

Eroare - functia $table_test->check().

'); } ?> redirect('index.php?option=com_componentamea'); ?>

File componentamea.php Restricted access.'); ?>

File edit_articol.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 15 if($user->usertype!="Super Administrator") $mainframe>redirect('index.php'); ?> setQuery($query); $rows = $db->loadObjectList(); $titlu_test =$rows[0]->nume_test; $descriere_test =$rows[0]->descriere_test; $editor_test=""; $query='SELECT * FROM `jos_cunoastere_intrebari` WHERE `id_test` ='.$id.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $editor_test=$editor_test.""."\n"; $editor_test=$editor_test.$row->nume_intrebare."\n"; $query_='SELECT * FROM `jos_cunoastere_raspunsuri` WHERE `id_intrebari` ='.($row->id).''; $result_ = $db->setQuery($query_); $rows_ = $db->loadObjectList(); foreach($rows_ as $row_) { $editor_test=$editor_test.$row_->nume_raspuns."\n"; } } $previz=JRequest::getVar('previz',null); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); if($previz=="Inregistreaza") { $titlu_test=JRequest::getVar('titlu_test',''); $editor_test=JRequest::getString('editor_test', '', 'POST', JREQUEST_ALLOWRAW); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); $table_test->reset(); $uniqid=uniqid(""); $table_test->set('nume_test', $uniqid);

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 16 if (!$table_test->store()) print('

Eroare - functia $table_test->store().

'); $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);

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 17

>loadResult(); >load($id_intrebare); >set('id_test', $id_test);

$id_intrebare=$db$table_intreb$table_intreb-

$table_intreb>set('nume_intrebare', addslashes( $raspuns));

>store())

if ($table_intreb->check()) { if (!$table_intreb-

{ print('

Eroare - functia $table_intreb->store().

'); } } else { print('

Eroare functia $table_intreb->check().

'); } $table_intreb->load(0); $i++; continue; }

$uniqid);

if(trim($raspuns)=="") continue; $table_rasp->reset(); $table_rasp->set('nume_raspuns',

if (!$table_rasp->store()) print('

Eroare - functia $table_rasp->store().

'); $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('

Eroare functia $table_rasp->store().

'); } } else { print('

Eroare - functia $table_rasp->check().

'); } $table_rasp->load(0); }

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 18 } $mainframe>redirect('index.php?option=com_componentamea&task=view_test&id='.$id _test.''); } include_once("adauga_test.php"); ?>

File index.php

File nu_publica.php usertype!="Super Administrator") $mainframe>redirect('index.php'); ?> load($id); $table_test->set('published',0); if ($table_test->check()) { if (!$table_test->store()) { print('

Eroare - functia $table_test->store().

'); } } else { print('

Eroare - functia $table_test->check().

'); } $mainframe>redirect('index.php?option=com_componentamea&task=view_test&id='.$id .''); ?>

File principal.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 19 ?>
'); $url_partaj=JURI::base()."index.php?option=com_componentamea%26task=x ml_feed%26format=feed"; jimport('joomla.utilities.date'); $date1 = new JDate(); $date1=$date1->toFormat('%d-%m-%Y %H:%M:%S EET'); print('
'); print('
Ora vizitei: '.$date1.'
'); print('
'); print('RSS'); print('Yahoo'); print('Google'); print('Netvibes'); print('
'); 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

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 20 $query="SELECT count(*) FROM `jos_cunoastere_test` WHERE `published`=1 "; $result = $db->setQuery($query); $total=$db->loadResult(); if($user->usertype=="Super Administrator") $query="SELECT `id` , `nume_test` , `descriere_test` FROM `jos_cunoastere_test` WHERE 1 ORDER BY `id` DESC LIMIT ".$limitstart." , ".$limit.""; else $query="SELECT `id` , `nume_test` , `descriere_test` FROM `jos_cunoastere_test` WHERE `published`=1 ORDER BY `id` DESC LIMIT ".$limitstart." , ".$limit.""; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach ($rows as $row) { print('id.'" style="text-decoration:none; cursor: pointer; " title="'.$row>nume_test.'">

'.$row->nume_test.'

'); print(stripslashes($row->descriere_test)); print("
"); print("
"); } jimport('joomla.html.pagination'); $_pagination = new JPagination($total, $limitstart, $limit); ?>


File publica.php usertype!="Super Administrator") $mainframe>redirect('index.php'); ?> load($id); $table_test->set('published',1);

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 21 if ($table_test->check()) { if (!$table_test->store()) { print('

Eroare - functia $table_test->store().

'); } } else { print('

Eroare - functia $table_test->check().

'); } $mainframe>redirect('index.php?option=com_componentamea&task=view_test&id='.$id .''); ?>

File sterge_articol.php usertype!="Super Administrator") $mainframe>redirect('index.php'); ?> delete($id); $query='SELECT `id` FROM `jos_cunoastere_intrebari` WHERE `id_test` ='.$id.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $query_='SELECT id FROM `jos_cunoastere_raspunsuri` WHERE `id_intrebari` ='.($row->id).''; $result_ = $db->setQuery($query_); $rows_ = $db->loadObjectList(); foreach($rows_ as $row_) { $table_rasp->delete($row_->id); } $table_intreb->delete($row->id); } $mainframe->redirect('index.php?option=com_componentamea'); ?>

File toolbar.componentamea.php

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 22 Restricted access.'); ?>

File vezi_test.php redirect('index.php?option=com_componentamea&task=view_test&id='.$id .''); } if($previz=="Inregistreaza") { if(!isset($user->name)) $mainframe>redirect('index.php?option=com_componentamea&task=view_test&alert_us er=not&id='.$id.''); $sir="".JRequest::getVar('sir',''); $sir_array=explode(":",$sir);

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 23 if(!isset($sir_array[2])) $mainframe>redirect('index.php?option=com_componentamea&task=view_test&alert_us er=script&id='.$id.''); jimport('joomla.utilities.date'); $date_ = new JDate(); $date = $date_->toFormat('%d/%m/%Y'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_user = JTable::getInstance('cunoastere_user', 'Table'); $table_user->reset(); $table_user->set('id_test', $sir_array[2]); $table_user->set('user', $user->name." :: ".$date); $table_user->set('punctaj', $sir_array[1]*1000+$sir_array[0]); if ($table_user->check()) { if (!$table_user->store()) { print('

Eroare - functia $table_user->store().

'); } } else { print('

Eroare - functia $table_user->check().

'); } $mainframe>redirect('index.php?option=com_componentamea&task=view_test&alert_us er=BD&id='.$id.''); } $query="SELECT `id` , `nume_test` , `descriere_test`, `published` FROM `jos_cunoastere_test` WHERE id=".$id.""; $result = $db->setQuery($query); $rows = $db->loadObjectList(); $url_partaj=JURI::base()."index.php?option=com_componentamea%26task=v iew_test%26id=".$id; foreach($rows as $row) { if($user->usertype!="Super Administrator") { print('
'); print('Facebook'); print('Diggit');

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 24 print('title.'" title="Partajeaza pe Delicious">Delicious'); print('Live'); print('nume_test.'" title="Partajeaza pe Blogmarks">Blogmarks'); print('Technorati'); print('Myspace'); print('nume_test.'" title="Partajeaza pe Twitter">Twitter'); print('
'); } if($user->usertype=="Super Administrator") { print('
'); if($row->published==1) print('id.'" title="Nu publica acest articol">yes.png'); if($row->published==0) print('id.'" title="Publica articol">no.png'); print('id.'" title="Editeaza articol">edit.png'); print('id.'" title="Sterge articol">del.png'); print('
'); }

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 25 print('
'); $alert_user=JRequest::getVar('alert_user',''); $alert_user=$alert_user.""; if($alert_user=="not") { print('
'); print('

Trebuie sa va conectati ca sa puteti inregistra rezultatele testelor.

'); print('
'); } if($alert_user=="script") { print('
'); print('

Programul necesita Javascript pentru a rula.

'); print('
'); } if($alert_user=="BD") { print('
'); print('

Rezultatul testului a fost inregistrat in baza de date.

'); print('
'); } $document =& JFactory::getDocument(); $document->setTitle($row->nume_test); print("

".$row->nume_test."

"); print("
"); print("".stripslashes($row->descriere_test).""); print("
"); print("
"); $id_test=$row->id; $tablou_int=array(); $tablou_raspuns=array(); $query = 'SELECT `id` , `nume_intrebare` FROM `jos_cunoastere_intrebari` WHERE `id_test` ='.$id_test.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); ?> <script type="text/javascript"> var radio=new Array(); var raspuns_dat=new Array(); var rasp_date=0;

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 26 var total=0; function verifica(param, param2) { var diviz="div["+param2+"]"; if(radio[param2]==param.value) { //visibility:visible document.getElementById(diviz).style.visibility="visible"; document.getElementById(diviz).style.color="green"; document.getElementById(diviz).innerHTML="Raspuns corect"; if(raspuns_dat[param2]==-1) { raspuns_dat[param2]=raspuns_dat[param2]+2; rasp_date=rasp_date+raspuns_dat[param2]; total++; document.getElementById("div_raspuns").innerHTML="Total test: "+ rasp_date + " / " + total + " : "+ parseInt(rasp_date*100/total) +"%"; } } else { document.getElementById(diviz).style.visibility="visible"; document.getElementById(diviz).style.color="red"; document.getElementById(diviz).innerHTML="Raspuns incorect"; if(raspuns_dat[param2]==-1) { raspuns_dat[param2]=raspuns_dat[param2]+1; rasp_date=rasp_date+raspuns_dat[param2]; total++; document.getElementById("div_raspuns").innerHTML="Total test: "+ rasp_date + " / " + total + " : "+ parseInt(rasp_date*100/total) +"%"; } } } usertype!="Super Administrator") { $doc =& JFactory::getDocument(); $params =&$mainframe>getPageParameters('com_componentamea'); $zone = $params->get('zona1'); if($doc->countModules('publicitate') && $doc>countModules('publicitate')>$zone) { jimport('joomla.application.module.helper'); $module = JModuleHelper::getModules('publicitate'); echo JModuleHelper::renderModule($module[$zone]); } }

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 27 foreach($rows as $row) { print("

".stripslashes($row->nume_intrebare)."

"); $id_intreb=$row->id; $tablou_int[]=$id_intreb; $query='SELECT `id`,`nume_raspuns` FROM `jos_cunoastere_raspunsuri` WHERE `id_intrebari`='.$id_intreb.''; $result_ = $db->setQuery($query); $rows_ = $db->loadObjectList(); $tablou_rasp=array(); $tablou_rasp_indice=array(); foreach($rows_ as $row_) { $tablou_rasp_indice[]=$row_->id; $tablou_rasp[$row_->id]=stripslashes($row_>nume_raspuns); } $tablou_raspuns[]=$tablou_rasp_indice[0]; print('<script type="text/javascript">'); print('radio['.$id_intreb.']='.$tablou_rasp_indice[0].';'); print('raspuns_dat['.$id_intreb.']=-1;'); print('var test_id='.$id_test.';'); print(''); srand((double)microtime()*1000000); shuffle($tablou_rasp_indice); foreach($tablou_rasp_indice as $value) { print(''); print($tablou_rasp[$value]); print("
"); } print(''); print("
"); } } print('<script type="text/javascript">'); print('var total_ver='.count($tablou_int).';'); print(''); ?>

Rezultat test



Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 28
Nici un rezultat inca.
<script type="text/javascript"> var tip_submit=null; function verifica_form() { document.getElementById("sir").value=rasp_date+":"+total+":"+ test_id; if(tip_submit.value=="Reinitializeaza") return true; if(tip_submit.value=="Inregistreaza") { if(total_ver==total) { return true; } else return false; } }
sau
"); $query='SELECT DISTINCT `id_test` FROM BY id DESC LIMIT 0, 10'; $result = $db->setQuery($query); $rows = $db->loadObjectList();

`jos_cunoastere_user` ORDER

$teste_recom=array(); foreach($rows as $row) { $teste_recom[]=$row->id_test; } print("

Alte teste de cunostinte recomandate:

"); foreach($teste_recom as $value) { $query='SELECT `id`,`nume_test` FROM `jos_cunoastere_test` WHERE id='.$value.' AND `published`=1 '; $result = $db->setQuery($query); $rows = $db->loadObjectList(); if(trim($rows[0]->nume_test."")=="")continue; print('id).'" style="text-decoration:none" title="Citeste mai mult...">'); print($rows[0]->nume_test); print('
');

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 29 } if(isset($user->name)) { print("

"); print("Rezultate obtinute la test:");print("

"); $id_test=0+$id_test; $query='SELECT `user` , `punctaj` FROM `jos_cunoastere_user` WHERE `id_test` ='.$id_test.' AND `user` LIKE "'.($user->name).'%" ORDER BY id DESC LIMIT 0 , 30'; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $user_data=explode("::",$row->user); print($user_data[1]); print(" "); $total_intreb=(int)($row->punctaj/1000); $total_dat=(int) ($row->punctaj- $total_intreb*1000); print(" ".$total_dat."/");print("".$total_intreb." "); print("Procentaj: ".(int)($total_dat*100/$total_intreb)."%"); print("
"); } } if($user->usertype!="Super Administrator") { $doc =& JFactory::getDocument(); $params =&$mainframe>getPageParameters('com_componentamea'); $zone = $params->get('zona2'); if($doc->countModules('publicitate') && $doc>countModules('publicitate')>$zone) { jimport('joomla.application.module.helper'); $module = JModuleHelper::getModules('publicitate'); echo JModuleHelper::renderModule($module[$zone]); } } ?>

File xml_feed.php setLink(JRoute::_('index.php?option=com_componentamea')); $db =& JFactory::getDBO();

Download http://24secunde.com/joomla/media/com_componentamea.zip

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 mea Martie 2009 Farcas Adrian [email protected] http://24secunde.com Copyright Licenta Versiunea 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.php admin.edit.php admin.principal.php

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 31 admin.publish.php admin.remove.php admin.rezultate.php admin.unpublish.php componenta mea.xml config.xml index.php toolbar.componentamea.php imagini tables
DROP DROP DROP DROP

TABLE TABLE TABLE TABLE

IF IF IF IF

EXISTS EXISTS EXISTS EXISTS

`jos_cunoastere_intrebari`;
`jos_cunoastere_raspunsuri`;
`jos_cunoastere_test`;
`jos_cunoastere_user`;


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

IF IF IF IF

EXISTS EXISTS EXISTS EXISTS

`jos_cunoastere_intrebari`; `jos_cunoastere_raspunsuri`; `jos_cunoastere_test`; `jos_cunoastere_user`;

adauga_test.php componentamea.php edit_articol.php index.php nu_publica.php principal.php publica.php sterge_articol.php vezi_test.php xml_feed.php imagini


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" />

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 33

The folder imagini

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 34

Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 35

The folder tables

File index.html Ooops! Nu e chiar ceea ce cauti!

File cunoastere_intrebari.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

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; } } ?>

File cunoastere_raspunsuri.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

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; } } ?>

File cunoastere_test.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

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; } } ?>

File cunoastere_user.php
Download http://24secunde.com/joomla/media/com_componentamea.zip

Page 39 {

if(!$this->id_test) { $this->setError(JText::_('Eroare - lipseste campul ID din tabela TEST.')); return false; } if(!$this->user) { $this->setError(JText::_('Eroare - testul nu are definit un USER.')); return false; } return true; } } ?>

Download http://24secunde.com/joomla/media/com_componentamea.zip

Related Documents

Component Joomla
June 2020 15
Component Cho Joomla
July 2020 6
Component
November 2019 36

More Documents from ""