Module to display a user's quiz/test scores

larpo
larpo
  • larpo
  • 11 months ago
Hi - I am trying to create a module which will load a users quiz scores on their jomsocial profile. I will load the PHP using the FlexiCustomCode module type. I want to display this in a module position on the users profile js-profile_side_top. I don't want to do it in the form of a jomsocial plugin, because I hate the way that system works.

I have tried to create one based on your plugin, but it won't show data. Could you help point me in the right direction?

<?php


$db = JFactory::getDBO();



$uri = JURI::base();

$my = JFactory::getUser();

$user = CFactory::getActiveProfile();



$lang = JFactory::getLanguage();
$lang->load('plg_community_jsquizresponses', JPATH_ADMINISTRATOR, $lang->getDefault(), true);
$lang->load('plg_community_jsquizresponsesoverride', JPATH_ADMINISTRATOR, $lang->getDefault(), true);


$query = '

select

distinct(a.id), a.title, a.alias, a.created, a.responses

from

#__quiz_quizzes a

left join

#__quiz_responses r on a.id=r.quiz_id

where

r.created_by='.$user->id.' and a.published=1

order by

a.score desc';



$db->setQuery($query, 0, 10);

$items = $db->loadObjectList();



$content = '';



if($items && count($items)){



$content = '<ol>';

$menu = JFactory::getApplication()->getMenu();

$mnuitems = $menu->getItems('link', 'index.php?option=com_communityquiz&view=quiz');

$itemid = isset($mnuitems[0]) ? '&amp;Itemid='.$mnuitems[0]->id : '';



foreach ($items as $item){



$url = JRoute::_('index.php?option=com_communityquiz&view=quiz&task=respond&id='.$item->id.':'.$item->alias.$itemid);

$content .= '<li><a href="'.$url.'">'.htmlentities($item->title, ENT_COMPAT, 'UTF-8').'</a>&nbsp;('.$item->responses.' '.($item->responses == 1 ? JText::_('LBL_RESPONSE'): JText::_('LBL_RESPONSES')).')</li>';

}



$content .= '</ol>';

}

return $content;



?>

Access to viewing replies is restricted.
Showing 5 of 5 replies
You do not have permissions for replying to this topic.
Loading...
Confirm delete? This action is irreversible and the data will be deleted permanently. Do you want to continue? Confirm Add New Delete Unpublish Cancel Import Uninstall The selected item successfully deleted.
Shondalai