Quiz Component For Joomla
-
Upload
guestebb21a -
Category
Self Improvement
-
view
1.180 -
download
1
description
Transcript of Quiz Component For Joomla
Page 1
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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
Page 2
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Press Register (Inregistreaza) and the quiz is ready.
The syntax for Questions and Answers must follow the rules:
<intrebare/>
SUA ? - the question is the first after the tag
Washington - the GOOD answer is always the first
New YORK
Los Angeles
<intrebare/>
Canada ?
Ottawa
Montreal
Toronto
Vancouver
<intrebare/>
France ?
Paris
Marseille
Nice
Strasbourg
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:
Page 3
Download
http://24secunde.com/joomla/media/com_componentamea.zip
The component files:
File adauga_test.php:
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $mainframe-
>redirect('index.php');
?>
<?php
$previz=JRequest::getVar('previz',null);
Page 4
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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("<h1>".$titlu_test."</h1>"); print("<br/>");
print("".$descriere_test.""); print("<br/>"); print("<br/>");
$intrebari_teste=explode("<intrebare/>", $editor_test);
foreach($intrebari_teste as $intrebare)
{
$intrebare=trim($intrebare);
$intrebare1=explode("\n", $intrebare);
$i=1;
foreach($intrebare1 as $raspuns)
{
if($i==1)
{
print("<h3>".$raspuns."</h3>");
$i++; continue;
}
print('<input name=""
type="radio" value="">');
print($raspuns);
print("<br/>");
}
print("<br/>");
}
print("<br/>");
}
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('<h1>Eroare - functia
$table_test->store().</h1>');
Page 5
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$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('<h1>Eroare - functia $table_test->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
$intrebari_teste=explode("<intrebare/>", $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;
$table_intreb->reset();
$table_intreb-
>set('nume_intrebare', $uniqid);
if (!$table_intreb-
>store()) print('<h1>Eroare - functia $table_intreb-
>store().</h1>');
$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);
Page 6
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$table_intreb-
>set('id_test', $id_test);
$table_intreb-
>set('nume_intrebare', addslashes( $raspuns));
if ($table_intreb->check())
{
if (!$table_intreb-
>store())
{
print('<h1>Eroare - functia $table_intreb->store().</h1>'); }
}
else
{
print('<h1>Eroare -
functia $table_intreb->check().</h1>');
}
$table_intreb->load(0);
$i++; continue;
}
if(trim($raspuns)=="") continue;
$table_rasp->reset();
$table_rasp->set('nume_raspuns',
$uniqid);
if (!$table_rasp->store())
print('<h1>Eroare - functia $table_rasp->store().</h1>');
$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('<h1>Eroare -
functia $table_rasp->store().</h1>'); }
}
else
{
print('<h1>Eroare - functia
$table_rasp->check().</h1>');
}
$table_rasp->load(0);
}
}
$mainframe-
>redirect('index.php?option=com_componentamea&task=adauga');
Page 7
Download
http://24secunde.com/joomla/media/com_componentamea.zip
}
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+"<intrebare/>";
if(tip=="raspuns")
document.getElementById("editor_test").value=document.getElementById(
"editor_test").value+"<raspuns/>";
if(tip=="break")
document.getElementById("editor_test").value=document.getElementById(
"editor_test").value+"<break/>";
}
</script>
<form method="post" action="">
<strong>Introduceti un titlu pentru testul dumneavoastra:
</strong>
<input name="titlu_test" type="text" id="titlu_test"
style="width:98%" value="<?php print($titlu_test); ?>"
maxlength="255">
<strong>Introduceti o descriere pentru testul dumneavoastra:
</strong>
<textarea id="descriere_test" name="descriere_test" rows="3" cols="1"
style="width:98%"><?php print($descriere_test); ?></textarea>
<strong>Introduceti intrebarile care compun testul dumneavoastra:
</strong>
<div style="border-width:1px; border-style:solid; background-
color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px;
margin-bottom:2px">
<a href="javascript: void(0);"
onClick='introduceti_entitate("intrebare")'>Intrebare</a>
<a href="javascript: void(0);"
onClick='introduceti_entitate("raspuns")'>Raspuns</a>
<a href="javascript: void(0);"
onClick='introduceti_entitate("break")'>Break</a>
</div>
<textarea id="editor_test" name="editor_test" rows="20" cols="1"
style="width:98%"><?php print($editor_test); ?></textarea>
<input name="previz" type="submit" value="Previzualizare">
<input name="previz" type="submit" value="Inregistreaza">
<input name="previz" type="submit" value="Reinitializeaza">
</form>
<textarea rows="3" cols="1" style="width:98%"><intrebare/>
Care este capitala Timisului?
Buzias
Timisoara
Lugoj
Page 8
Download
http://24secunde.com/joomla/media/com_componentamea.zip
<intrebare/>
Care este capitala Romaniei?
Bucuresti
Budapesta
Sofia
<intrebare/>
Care este capitala Turciei?
Ankara
Istanbul
Atena
</textarea>
File admin.componentamea.php:
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$task=JRequest::getVar('task',null)."";
if(!isset($task) || trim($task)=="")
JRequest::setVar('task','admin_test');
$task=JRequest::getVar('task',null)."";
if($task=="admin_test") include_once("admin.principal.php");
if($task=="publish") include_once("admin.publish.php");
if($task=="unpublish") include_once("admin.unpublish.php");
if($task=="edit") include_once("admin.edit.php");
if($task=="apply") include_once("admin.edit.php");
if($task=="cancel") include_once("admin.edit.php");
if($task=="rezult_test") include_once("admin.rezultate.php");
if($task=="remove") include_once("admin.remove.php");
?>
File admin.edit.php:
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$cid = JRequest::getVar( 'cid', array(0));
$id=$cid[0];
// obtinem o refeinta la clasa JUser
$user =& JFactory::getUser();
// obtinem o referinta la baza de date
$db =& JFactory::getDBO();
if($task== "apply")
{
$titlu_test=JRequest::getVar('titlu_test','');
Page 9
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$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('<h1>Eroare - functia $table_test-
>store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
$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('<div style="width:50%">');
print('<form action="" method="post" name="adminForm">');
print('<strong>Introduceti un titlu pentru testul
dumneavoastra:</strong>');
print('<input name="titlu_test" type="text" id="titlu_test"
style="width:98%" value="'.$row->nume_test.'" maxlength="255">');
Page 10
Download
http://24secunde.com/joomla/media/com_componentamea.zip
print('<strong>Introduceti o descriere pentru testul
dumneavoastra:</strong>');
print('<textarea id="descriere_test" name="descriere_test" rows="3"
cols="1" style="width:98%">'.stripslashes($row-
>descriere_test).'</textarea>');
print('<input id="task_txt" type="hidden" name="task" value="" />');
print('</form>');
print('</div>');
}
JRequest::setVar('hidemainmenu', 1);
?>
File admin.principal.php
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$ordine=JRequest::getVar('ordine',null);
if(!isset($ordine))$ordine="DESC";
?>
<form action="" method="post" name="adminForm">
<script type="text/javascript">
function stabileste_ordinea(param)
{
document.getElementById("ord_txt").value=param;
document.getElementById("ord_txt").form.submit();
}
</script>
<table class="adminlist">
<thead>
<tr>
<th width="20" class='title'>#</th>
<th width="20" class='title'>
<input type="checkbox" name="toggle" value=""
onclick="checkAll(nr_chk);" /></th>
<th class='title'>Numele testului</th>
<th class='title'>Descrierea testului</th>
<th width="30" class='title'>Publicare test</th>
<th width="30" class='title'>
<a href="javascript: void(0);" onClick="stabileste_ordinea('ASC')"
title="Ascendent">[I</a><a href="javascript: void(0);"
onClick="stabileste_ordinea('DESC')" title="Descendent">d]</a>
</th>
</tr>
</thead>
<?php
Page 11
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$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)
{
?>
<tr class="row<?php print($int_j%2);?>">
<td align="center"><?php print($int_j);?></td>
<td><input type="checkbox" id="cb<?php print($int_j);?>" name="cid[]"
value="<?php print($row->id);?>" onclick="isChecked(this.checked);"
/></td>
<td><?php print('<a
href="index.php?option=com_componentamea&task=edit&cid[]='.$row-
>id.'">'.$row->nume_test.'</a>');?></td>
<td><?php print(stripslashes($row->descriere_test));?></td>
<td>
<?php
if($row->published==1)
print('<a href="javascript:void(0);" onclick="return
listItemTask(\'cb'.$int_j.'\',\'unpublish\')" title="Unpublish Item">
<img src="images/tick.png" width="16" height="16" border="0"
alt="No" /></a>');
if($row->published==0)
print('<a href="javascript:void(0);" onclick="return
listItemTask(\'cb'.$int_j.'\',\'publish\')" title="Publish Item">
<img src="images/publish_x.png" width="16" height="16" border="0"
alt="No" /></a>');
?>
</td>
<td><?php print($row->id);?></td>
</tr>
<?php
$int_j++;
}
print('<script type="text/javascript">');
print('var nr_chk='.$int_j);
print('</script>');
?>
<tfoot>
<td colspan="10">
<?php
jimport('joomla.html.pagination');
if($limit==500)$limit=0;
Page 12
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$pageNav = new JPagination($total,$limitstart,$limit);
print($pageNav->getListFooter());
?>
</td>
</tfoot>
</table>
<input id="id_txt" type="hidden" name="id" value="" />
<input id="task_txt" type="hidden" name="task" value="" />
<input id="ord_txt" type="hidden" name="ordine" value="<?php
print($ordine); ?>" />
<input type="hidden" name="boxchecked" value="0" />
</form>
File admin.publish.php
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$cid = JRequest::getVar( 'cid', array(0));
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
foreach($cid as $value)
{
$id=$value;
?>
<?php
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_test->load($id);
$table_test->set('published',1);
if ($table_test->check())
{
if (!$table_test->store())
{
print('<h1>Eroare - functia $table_test->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
?>
<?php
}
$mainframe->redirect('index.php?option=com_componentamea');
?>
File admin.remove.php
Page 13
Download
http://24secunde.com/joomla/media/com_componentamea.zip
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$db =& JFactory::getDBO();
$user=JRequest::getVar('user_del','');
$user=$user.'';
if(trim($user)=="")$user='[{<##>}]';
$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
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<form action="" method="post" name="adminForm">
<h4>Sterge rezultatele utilizatorului: </h4>
<input type="text" name="user_del" id="user_del" class="text_area" />
(Ex: Ion, Rizache, John) % - sterge tot
<br/>
<h4>Sterge rezultatele care includ testul:</h4>
<input type="text" name="test_del" id="test_del" class="text_area" />
(Ex: 1, 100, 2000)
<br/><br/>
<button onclick="this.form.submit();">Go</button><br/>
<input id="id_txt" type="hidden" name="id" value="" />
<input id="task_txt" type="hidden" name="task" value="remove" />
<input type="hidden" name="boxchecked" value="1" />
</form>
File admin.unpublish.php
<?php
Page 14
Download
http://24secunde.com/joomla/media/com_componentamea.zip
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$cid = JRequest::getVar( 'cid', array(0));
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
foreach($cid as $value)
{
$id=$value;
?>
<?php
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_test->load($id);
$table_test->set('published',0);
if ($table_test->check())
{
if (!$table_test->store())
{
print('<h1>Eroare - functia $table_test->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
?>
<?php
}
$mainframe->redirect('index.php?option=com_componentamea');
?>
File componentamea.php
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$task=JRequest::getVar('task',null);
if($task=="adauga") include_once("adauga_test.php");
if($task=="view_test") include_once("vezi_test.php");
if($task=="nu_publica") include_once("nu_publica.php");
if($task=="publica") include_once("publica.php");
if($task=="sterge_articol") include_once("sterge_articol.php");
if($task=="edit_articol") include_once("edit_articol.php");
if($task=="xml_feed") include_once("xml_feed.php");
if(!isset($task)) include_once("principal.php");
?>
File edit_articol.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
Page 15
Download
http://24secunde.com/joomla/media/com_componentamea.zip
if($user->usertype!="Super Administrator") $mainframe-
>redirect('index.php');
?>
<?php
$db =& JFactory::getDBO();
$id=JRequest::getVar('id',0);
$id=$id+0;
$query='SELECT * FROM `jos_cunoastere_test` WHERE id='.$id.'';
$result = $db->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."<intrebare/>"."\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);
Page 16
Download
http://24secunde.com/joomla/media/com_componentamea.zip
if (!$table_test->store()) print('<h1>Eroare - functia
$table_test->store().</h1>');
$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('<h1>Eroare - functia $table_test->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
$intrebari_teste=explode("<intrebare/>", $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;
$table_intreb->reset();
$table_intreb-
>set('nume_intrebare', $uniqid);
if (!$table_intreb-
>store()) print('<h1>Eroare - functia $table_intreb-
>store().</h1>');
$db = &JFactory::getDBO();
$query = 'SELECT id FROM
#__cunoastere_intrebari WHERE nume_intrebare="'.$uniqid.'"'.'ORDER BY
id DESC LIMIT 1' ;
$db->setQuery($query);
Page 17
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$id_intrebare=$db-
>loadResult();
$table_intreb-
>load($id_intrebare);
$table_intreb-
>set('id_test', $id_test);
$table_intreb-
>set('nume_intrebare', addslashes( $raspuns));
if ($table_intreb->check())
{
if (!$table_intreb-
>store())
{
print('<h1>Eroare - functia $table_intreb->store().</h1>'); }
}
else
{
print('<h1>Eroare -
functia $table_intreb->check().</h1>');
}
$table_intreb->load(0);
$i++; continue;
}
if(trim($raspuns)=="") continue;
$table_rasp->reset();
$table_rasp->set('nume_raspuns',
$uniqid);
if (!$table_rasp->store())
print('<h1>Eroare - functia $table_rasp->store().</h1>');
$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('<h1>Eroare -
functia $table_rasp->store().</h1>'); }
}
else
{
print('<h1>Eroare - functia
$table_rasp->check().</h1>');
}
$table_rasp->load(0);
}
Page 18
Download
http://24secunde.com/joomla/media/com_componentamea.zip
}
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
_test.'');
}
include_once("adauga_test.php");
?>
File index.php
<?php
print("Componenta mea");
?>
File nu_publica.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $mainframe-
>redirect('index.php');
?>
<?php
$id=JRequest::getVar('id',0);
$id=$id+0;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_test->load($id);
$table_test->set('published',0);
if ($table_test->check())
{
if (!$table_test->store())
{
print('<h1>Eroare - functia $table_test->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
.'');
?>
File principal.php
<?php
defined("_JEXEC") or exit("Restricted access");
Page 19
Download
http://24secunde.com/joomla/media/com_componentamea.zip
?>
<?php
print('<div style="clear:both;"></div>');
$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('<div style="background-color:#e1e1e1; padding:3px 3px 3px 3px;
margin-bottom:5px; font-weight:bold">');
print('<div style="float:left;">Ora vizitei: '.$date1.'</div>');
print('<div style="float:right;background-color:#e1e1e1; padding:0px
0px 1px 0px;">');
print('<a
href="'.JURI::base().'index.php?option=com_componentamea&task=xml_fee
d&format=feed" title="RSS"><img
src="components/com_hello/imagini/rss.gif" alt="RSS"></a>');
print('<a href="http://add.my.yahoo.com/rss?url='.$url_partaj.'"
title="Yahoo"><img src="components/com_hello/imagini/yahoo.gif"
alt="Yahoo"></a>');
print('<a href="http://fusion.google.com/add?feedurl='.$url_partaj.'"
title="Google"><img src="components/com_hello/imagini/google.gif"
alt="Google"></a>');
print('<a
href="http://www.netvibes.com/subscribe.php?url='.$url_partaj.'"
title="Netvibes"><img src="components/com_hello/imagini/netvibes.gif"
alt="Netvibes"></a>');
print('</div>');
print('.</div>');
print('<div style="clear:both;"></div>');
$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 20
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$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('<a
href="index.php?option=com_componentamea&task=view_test&id='.$row-
>id.'" style="text-decoration:none; cursor: pointer; " title="'.$row-
>nume_test.'"><h3>'.$row->nume_test.'</h3></a>');
print(stripslashes($row->descriere_test));
print("<br/>"); print("<br/>");
}
jimport('joomla.html.pagination');
$_pagination = new JPagination($total, $limitstart, $limit);
?>
<div style="clear:both"></div>
<div class="pagenav" style="text-align:center; margin-top:10px; ">
<?php print($_pagination->getPagesLinks()); ?>
<br/>
<?php print($_pagination->getPagesCounter()); ?>
</div>
File publica.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $mainframe-
>redirect('index.php');
?>
<?php
$id=JRequest::getVar('id',0);
$id=$id+0;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_test->load($id);
$table_test->set('published',1);
Page 21
Download
http://24secunde.com/joomla/media/com_componentamea.zip
if ($table_test->check())
{
if (!$table_test->store())
{
print('<h1>Eroare - functia $table_test->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_test->check().</h1>');
}
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
.'');
?>
File sterge_articol.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $mainframe-
>redirect('index.php');
?>
<?php
$db =& JFactory::getDBO();
$id=JRequest::getVar('id',0);
$id=$id+0;
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->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
Page 22
Download
http://24secunde.com/joomla/media/com_componentamea.zip
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
if($task=="admin_test")
{
JToolBarHelper::title('Administrare teste');
JToolBarHelper::editList();
JToolBarHelper::divider();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::divider();
JToolBarHelper::preferences('com_componentamea');
}
if($task=="edit" || $task=="apply" )
{
JToolBarHelper::title('Editare test');
JToolBarHelper::apply();
JToolBarHelper::cancel();
}
if($task=="rezult_test")
{
JToolBarHelper::title('Rezultate teste');
JToolBarHelper::deleteList();
}
?>
File vezi_test.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$id=JRequest::getVar('id',0);
$id=$id+0;
$previz=JRequest::getVar('previz',null);
if($previz=="Reinitializeaza")
{
$mainframe-
>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);
Page 23
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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('<h1>Eroare - functia $table_user->store().</h1>');
}
}
else
{
print('<h1>Eroare - functia $table_user->check().</h1>');
}
$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('<div style="float:right;">');
print('<a
href="http://www.facebook.com/sharer.php?u='.$url_partaj.'"
title="Partajeaza pe Facebook"><img
src="components/com_hello/imagini/facebook.gif"
alt="Facebook"></a>');
print('<a
href="http://digg.com/submit?phase=2&url='.$url_partaj.'"
title="Partajeaza pe Digg"><img
src="components/com_hello/imagini/diggit.gif" alt="Diggit"></a>');
Page 24
Download
http://24secunde.com/joomla/media/com_componentamea.zip
print('<a
href="http://del.icio.us/post?url='.$url_partaj.'&title='.$row-
>title.'" title="Partajeaza pe Delicious"><img
src="components/com_hello/imagini/delicious.gif"
alt="Delicious"></a>');
print('<a
href="https://favorites.live.com/quickadd.aspx?marklet=1&top=1&url='.
$url_partaj.'" title="Partajeaza pe Live"><img
src="components/com_hello/imagini/live.gif" alt="Live"></a>');
print('<a
href="http://blogmarks.net/my/new.php?mini=1&simple=1&url='.$url_part
aj.'&title='.$row->nume_test.'" title="Partajeaza pe Blogmarks"><img
src="components/com_hello/imagini/blogmarks.gif"
alt="Blogmarks"></a>');
print('<a
href="http://www.technorati.com/faves?add='.$url_partaj.'"
title="Partajeaza pe Technorati"><img
src="components/com_hello/imagini/technorati.gif"
alt="Technorati"></a>');
print('<a
href="http://www.myspace.com/Modules/PostTo/Pages/?c='.$url_partaj.'"
title="Partajeaza pe Myspace"><img
src="components/com_hello/imagini/myspace.gif" alt="Myspace"></a>');
print('<a
href="http://twitthis.com/twit?url='.$url_partaj.'&title='.$row-
>nume_test.'" title="Partajeaza pe Twitter"><img
src="components/com_hello/imagini/twitter.gif" alt="Twitter"></a>');
print('</div>');
}
if($user->usertype=="Super Administrator")
{
print('<div style="float:right;">');
if($row->published==1)
print('<a
href="index.php?option=com_componentamea&task=nu_publica&id='.$row-
>id.'" title="Nu publica acest articol"><img
src="components/com_componentamea/imagini/yes.png"
alt="yes.png"></a>');
if($row->published==0)
print('<a
href="index.php?option=com_componentamea&task=publica&id='.$row-
>id.'" title="Publica articol"><img
src="components/com_componentamea/imagini/no.png"
alt="no.png"></a>');
print('<a
href="index.php?option=com_componentamea&task=edit_articol&id='.$row-
>id.'" title="Editeaza articol"><img
src="components/com_componentamea/imagini/edit.png"
alt="edit.png"></a>');
print('<a
href="index.php?option=com_componentamea&task=sterge_articol&id='.$ro
w->id.'" title="Sterge articol"><img
src="components/com_componentamea/imagini/del.png"
alt="del.png"></a>');
print('</div>');
}
Page 25
Download
http://24secunde.com/joomla/media/com_componentamea.zip
print('<div style="clear:both;"></div>');
$alert_user=JRequest::getVar('alert_user','');
$alert_user=$alert_user."";
if($alert_user=="not")
{
print('<div style="width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2px">');
print('<h4>Trebuie sa va conectati ca sa puteti inregistra
rezultatele testelor.</h4>');
print('</div>');
}
if($alert_user=="script")
{
print('<div style="width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2px">');
print('<h4>Programul necesita Javascript pentru a rula.</h4>');
print('</div>');
}
if($alert_user=="BD")
{
print('<div style="width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2px">');
print('<h4>Rezultatul testului a fost inregistrat in baza de
date.</h4>');
print('</div>');
}
$document =& JFactory::getDocument();
$document->setTitle($row->nume_test);
print("<h1>".$row->nume_test."</h1>"); print("<br/>");
print("".stripslashes($row->descriere_test).""); print("<br/>");
print("<br/>");
$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;
Page 26
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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)
+"%";
}
}
}
</script>
<?php
if($user->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]);
}
}
Page 27
Download
http://24secunde.com/joomla/media/com_componentamea.zip
foreach($rows as $row)
{
print("<h3>".stripslashes($row->nume_intrebare)."</h3>");
$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('</script>');
srand((double)microtime()*1000000);
shuffle($tablou_rasp_indice);
foreach($tablou_rasp_indice as $value)
{
print('<input name="radio'.$id_intreb.'"
type="radio" value="'.$value.'"
onclick="verifica('.this.','.$id_intreb.')">');
print($tablou_rasp[$value]);
print("<br/>");
}
print('<div id="div['.$id_intreb.']" style="visibility:hidden;
width:50%; border-width:1px; border-style:solid; background-
color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px;
margin-bottom:2px"></div>');
print("<br/>");
}
}
print('<script type="text/javascript">');
print('var total_ver='.count($tablou_int).';');
print('</script>');
?>
<h3>Rezultat test</h3>
Page 28
Download
http://24secunde.com/joomla/media/com_componentamea.zip
<div id="div_raspuns" style="width:50%; border-width:1px; border-
style:solid; background-color:#CCCCCC; padding-top:2px; padding-
left:2px; padding-bottom:2px; margin-bottom:2px">
Nici un rezultat inca.
</div>
<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;
}
}
</script>
<form action="" method="post" onSubmit="return verifica_form();">
<input id="sir" name="sir" type="hidden" value="">
<input name="previz" type="submit" value="Inregistreaza"
onClick="tip_submit=this;"> sau
<input name="previz" type="submit" value="Reinitializeaza"
onClick="tip_submit=this;">
</form>
<?php
print("<br/>");
$query='SELECT DISTINCT `id_test` FROM `jos_cunoastere_user` ORDER
BY id DESC LIMIT 0, 10';
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
$teste_recom=array();
foreach($rows as $row)
{
$teste_recom[]=$row->id_test;
}
print("<h3>Alte teste de cunostinte recomandate:</h3>");
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('<a
href="index.php?option=com_componentamea&task=view_test&id='.($rows[0
]->id).'" style="text-decoration:none" title="Citeste mai
mult...">');
print($rows[0]->nume_test);
print('</a><br/>');
Page 29
Download
http://24secunde.com/joomla/media/com_componentamea.zip
}
if(isset($user->name))
{
print("<h4>"); print("Rezultate obtinute la
test:");print("</h4>");
$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("<br/>");
}
}
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
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
/// Pasul 1 - stabileste linkul de baza
$document = & JFactory::getDocument();;
$document->setLink(JRoute::_('index.php?option=com_componentamea'));
$db =& JFactory::getDBO();
Page 30
Download
http://24secunde.com/joomla/media/com_componentamea.zip
$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)."<br/>"."<br/>";
$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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/component-
install.dtd">
<install type="component" version="1.5">
<name>Componenta mea</name>
<creationDate>Martie 2009</creationDate>
<author>Farcas Adrian</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://24secunde.com</authorUrl>
<copyright>Copyright</copyright>
<license>Licenta</license>
<version>Versiunea 1.0</version>
<description>Componenta de test</description>
<administration>
<menu>Admin Teste</menu>
<submenu>
<menu task="rezult_test"
img="js/ThemeOffice/component.png">Administrare rezultate
teste</menu>
<menu task="admin_test"
img="js/ThemeOffice/component.png">Administrare teste</menu>
</submenu>
<files>
<filename>admin.componentamea.php</filename>
<filename>admin.edit.php</filename>
<filename>admin.principal.php</filename>
Page 31
Download
http://24secunde.com/joomla/media/com_componentamea.zip
<filename>admin.publish.php</filename>
<filename>admin.remove.php</filename>
<filename>admin.rezultate.php</filename>
<filename>admin.unpublish.php</filename>
<filename>componenta mea.xml</filename>
<filename>config.xml</filename>
<filename>index.php</filename>
<filename>toolbar.componentamea.php</filename>
<folder>imagini</folder>
<folder>tables</folder>
</files>
</administration>
<install>
<queries>
<query>DROP TABLE IF EXISTS `jos_cunoastere_intrebari`;</query>
<query>DROP TABLE IF EXISTS `jos_cunoastere_raspunsuri`;</query>
<query>DROP TABLE IF EXISTS `jos_cunoastere_test`;</query>
<query>DROP TABLE IF EXISTS `jos_cunoastere_user`;</query>
<query>CREATE TABLE `jos_cunoastere_intrebari`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_test` INT NOT NULL,
`nume_intrebare` TEXT NOT NULL
)
</query>
<query>CREATE TABLE `jos_cunoastere_raspunsuri`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_intrebari` INT NOT NULL,
`nume_raspuns` TEXT NOT NULL
)
</query>
<query>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
)
</query>
<query>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
)
</query>
<query>
<![CDATA[
Page 32
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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: <a
href="index.php?option=com_componentamea&task=adauga"
title="">index.php?option=com_componentamea&task=adauga</a>', '1'
)
]]>
</query>
</queries>
</install>
<uninstall>
<queries>
<query>DROP TABLE IF EXISTS `jos_cunoastere_intrebari`;</query>
<query>DROP TABLE IF EXISTS `jos_cunoastere_raspunsuri`;</query>
<query>DROP TABLE IF EXISTS `jos_cunoastere_test`;</query>
<query>DROP TABLE IF EXISTS `jos_cunoastere_user`;</query>
</queries>
</uninstall>
<files>
<filename>adauga_test.php</filename>
<filename>componentamea.php</filename>
<filename>edit_articol.php</filename>
<filename>index.php</filename>
<filename>nu_publica.php</filename>
<filename>principal.php</filename>
<filename>publica.php</filename>
<filename>sterge_articol.php</filename>
<filename>vezi_test.php</filename>
<filename>xml_feed.php</filename>
<folder>imagini</folder>
</files>
</install>
File config.xml
<?xml version="1.0" encoding="utf-8"?>
<config>
<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" />
</params>
</config>
Page 33
Download
http://24secunde.com/joomla/media/com_componentamea.zip
The folder imagini
Page 34
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 35
Download
http://24secunde.com/joomla/media/com_componentamea.zip
The folder tables
File index.html
Ooops! Nu e chiar ceea ce cauti!
File cunoastere_intrebari.php
<?php
class Tablecunoastere_intrebari extends JTable
{
/*
CREATE TABLE `jos_cunoastere_intrebari`
(
Page 36
Download
http://24secunde.com/joomla/media/com_componentamea.zip
`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
<?php
class Tablecunoastere_raspunsuri extends JTable
{
/*
CREATE TABLE `jos_cunoastere_raspunsuri`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_intrebari` INT NOT NULL,
`nume_raspuns` TEXT NOT NULL
);
*/
// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita
Page 37
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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
<?php
class Tablecunoastere_test extends JTable
{
/*
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
);
*/
// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita
var $id = null;
var $nume_test=NULL;
var $descriere_test=NULL;
var $published = 0;
// functia constructor are ca parametru o referinta la baza de date
function __construct( &$db )
{
Page 38
Download
http://24secunde.com/joomla/media/com_componentamea.zip
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
<?php
class Tablecunoastere_user extends JTable
{
/*
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
);
*/
// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita
var $id = null;
var $id_test=NULL;
var $user=NULL;
var $punctaj = 0;
// functia constructor are ca parametru o referinta la baza de date
function __construct( &$db )
{
parent::__construct('#__cunoastere_user', 'id', $db);
}
// validarea datelor daca este cazul;
function check()
Page 39
Download
http://24secunde.com/joomla/media/com_componentamea.zip
{
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;
}
}
?>