× Feature Requests

Please do NOT use this section of the forum to request help if Joomdle does not work for you in some particular way. Your post will be deleted.

Allow teachers to view students' gradebook

2 months 3 weeks ago 2 months 3 weeks ago by Web Buster UK Ltd.
Web Buster UK Ltd
Posts: 78
More
Topic Author
Allow teachers to view students' gradebook #1
This may be a bit of a stretch, but is it possible for a teacher to view a student's gradebook? Ideally it will be the mygrades view.

Edit: We have modified the mygrades view to allow teachers to view student's gradebook - it isn't really a clean modification but it does work for now.
2 months 3 weeks ago
Antonio Durán
Posts: 7021
More
Allow teachers to view students' gradebook #2
Hi.

Have you looked into the childrengrades view?
2 months 1 week ago
Web Buster UK Ltd
Posts: 78
More
Topic Author
Allow teachers to view students' gradebook #3
Hi Antonio, it wasn't quite what we wanted as that only displays the grade for your mentees. We needed the teachers to be able to view any of their students' gradebook.

We have basically edited the My Grades php files to allow to view other user's gradebook.
3 weeks 18 hours ago 3 weeks 18 hours ago by Web Buster UK Ltd.
Web Buster UK Ltd
Posts: 78
More
Topic Author
Allow teachers to view students' gradebook #4
Just to share what we have done to allow teachers to view students' grades. We basically replicated the mygrades view, the only file changed was view.html.php.

<?php
/**
  * @package      Joomdle
  * @copyright    Qontori Pte Ltd
  * @license      http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
  */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.view');
require_once(JPATH_SITE.'/components/com_joomdle/helpers/content.php');


/**
 * HTML View class for the Joomdle component
 */	

class JoomdleViewStudentgrades extends JViewLegacy {
    function display($tpl = null) {
        global $mainframe;

        $app        = JFactory::getApplication();
        $params = $app->getParams();
        $this->assignRef('params',              $params);

		$user = JFactory::getUser();
        $id = $user->id;
		$student = $_GET['student'];
		$username = $student;
		
		$db = JFactory::getDbo();
		$query3 = $db->getQuery(true);
		$query3->select('cb_usertype');
		$query3->from($db->quoteName('#__comprofiler'));
		$query3->where($db->quoteName('id')." = " . $id);
		$db->setQuery($query3);
		$usertype = $db->loadResult();

		if ( !in_array($usertype, ['teacher','admin'], true ) ) {
			throw new Exception(JText::_('Restricted Access'), 701);
		};
		
		
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select('id');
		$query->from($db->quoteName('#__users'));
		$query->where($db->quoteName('username'). " = '" . $student . "'");
		$db->setQuery($query);
		$studentid = $db->loadResult();
		
		if (!array_key_exists('8', $user->groups)) {
			$db = JFactory::getDbo();
			$query2 = $db->getQuery(true);
			$query2->select('cb_school');
			$query2->from($db->quoteName('#__comprofiler'));
			$query2->where($db->quoteName('id')." = " . $id, 'OR')
	      		  ->where($db->quoteName('id')." = " . $studentid);
			$db->setQuery($query2);
	
			$column= $db->loadColumn();

			if ($column[0] !== $column[1]) {
				throw new Exception(JText::_('Restricted Access'), 801);
			};
		};
		


		
		$layout = $params->get('layout');

        if ($layout == 'basic')
        {
            $this->tasks = JoomdleHelperContent::call_method ("get_my_grades", $username);
        }
        else
        {
            $this->tasks = JoomdleHelperContent::call_method ("get_my_grade_user_report", $username);
            $tpl = 'cats';
        }

        $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));

        $this->_prepareDocument();

        parent::display($tpl);
    }

    protected function _prepareDocument()
    {
        $app    = JFactory::getApplication();
        $menus  = $app->getMenu();
        $title  = null;

        // Because the application sets a default page title,
        // we need to get it from the menu item itself
        $menu = $menus->getActive();
        if ($menu)
        {
            $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
        } else {
            $this->params->def('page_heading', JText::_('COM_JOOMDLE_MY_GRADES'));
        }
    }

}
?>

We added a link to view the studentgrades from their joomla profile. As the URL for joomla profile contains their username, we retrieved the last part of the URL to be input as part of the link, hence the $_GET bit at the start.
2 weeks 5 days ago
Antonio Durán
Posts: 7021
More
Allow teachers to view students' gradebook #5
Thanks for sharing. I will take a look soon to see if we can include it in Joomdle.
Cron Job Starts