Skip to main content

Module to display a user's quiz/test scores

1.7K Views
0 Replies
2 min read
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) ? '&amp;Itemid='.$mnuitems->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;



?>

0 Replies

No Replies Yet

Topic Author

L

larpo

@larpo

Topic Stats

Created Friday, 13 December 2013 21:52
Last Updated Friday, 13 December 2013 21:52
Replies 0
Views 1.7K
Likes 0

Share This Topic