function display($tpl = null) { $app = JFactory::getApplication(); $pathway = $app->getPathWay(); $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); $this->assignRef('params', $params); $id = $params->get('course_id'); if (!$id) { $id = JRequest::getVar('course_id'); } $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($id); $this->student_no = JoomdleHelperContent::getCourseStudentsNo($id); $this->assignments = JoomdleHelperContent::getAssignmentSubmissions($id); $this->grades = JoomdleHelperContent::getAssignmentGrades($id); $this->daily_stats = JoomdleHelperContent::getCourseDailyStats($id); if (is_object($menu) && $menu->query['view'] != 'coursestats') { $pathway->addItem($this->course_info['fullname'], ''); } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_STATS')); parent::display($tpl); }
function display($tpl = null) { global $mainframe; $app = JFactory::getApplication(); $pathway = $app->getPathWay(); $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); $this->assignRef('params', $params); $id = $params->get('course_id'); if (!$id) { $id = JRequest::getVar('course_id'); } $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($id); $this->teachers = JoomdleHelperContent::getCourseTeachers($id); /* pathway */ $cat_slug = $this->course_info['cat_id'] . ":" . $this->course_info['cat_name']; $course_slug = $this->course_info['remoteid'] . ":" . $this->course_info['fullname']; if (is_object($menu) && $menu->query['view'] != 'teachers') { $pathway->addItem($this->course_info['cat_name'], 'index.php?view=coursecategory&cat_id=' . $cat_slug); $pathway->addItem($this->course_info['fullname'], 'index.php?view=detail&cat_id=' . $cat_slug . '&course_id=' . $course_slug); $pathway->addItem(JText::_('COM_JOOMDLE_COURSE_TEACHERS'), ''); } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_TEACHERS')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); parent::display($tpl); }
function display($tpl = null) { global $mainframe; $app = JFactory::getApplication(); $pathway = $app->getPathWay(); $menus = $app->getMenu(); $menu = $menus->getActive(); // Load the form validation behavior JHTML::_('behavior.formvalidation'); $params = $app->getParams(); $this->assignRef('params', $params); $id = $params->get('course_id'); if (!$id) { $id = JRequest::getVar('course_id'); } $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $user = JFactory::getUser(); $username = $user->username; $this->course_info = JoomdleHelperContent::getCourseInfo($id, $username); /* pathway */ $cat_slug = $this->course_info['cat_id'] . ":" . JFilterOutput::stringURLSafe($this->course_info['cat_name']); if (is_object($menu) && $menu->query['view'] != 'detail') { $pathway->addItem($this->course_info['cat_name'], 'index.php?view=coursecategory&cat_id=' . $cat_slug); $pathway->addItem($this->course_info['fullname'], ''); } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname']); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $params = $app->getParams(); $this->assignRef('params', $params); $this->course_id = $params->get('course_id'); if (!$this->course_id) { $this->course_id = JRequest::getVar('course_id'); } $this->course_id = (int) $this->course_id; // Only for logged users $user = JFactory::getUser(); $username = $user->username; if (!$username) { return; } if (!$this->course_id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($this->course_id, $username); // user not enroled if (!$this->course_info['enroled']) { return; } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_GRADES')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); // $this->gcats = JoomdleHelperContent::call_method ("get_course_grades_by_category", $this->course_id, $username); $this->gcats = JoomdleHelperContent::call_method("get_grade_user_report", $this->course_id, $username); $tpl = "cats"; parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $params = $app->getParams(); $this->assignRef('params', $params); $user = JFactory::getUser(); $username = $user->username; $id = $params->get('course_id'); if (!$id) { $id = JRequest::getVar('course_id'); } $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($id, $username); // user not enroled and no guest access if (!$this->course_info['enroled'] && !$this->course_info['guest']) { return; } $this->events = JoomdleHelperContent::getCourseEvents($id); $this->jump_url = JoomdleHelperContent::getJumpURL(); $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_EVENTS')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $params = $app->getParams(); $this->assignRef('params', $params); $this->course_id = $params->get('course_id'); if (!$this->course_id) { $this->course_id = JRequest::getVar('course_id'); } $this->course_id = (int) $this->course_id; // Only for logged users $user = JFactory::getUser(); $username = $user->username; if (!$username) { return; } if (!$this->course_id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($this->course_id, $username); // user not enroled if (!$this->course_info['enroled']) { return; } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_GRADES')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); // $this->gcats = JoomdleHelperContent::call_method ("get_course_grades_by_category", $this->course_id, $username); $this->gcats = JoomdleHelperContent::call_method("get_grade_user_report", $this->course_id, $username); $tpl = "catspdf"; $this->_prepareDocument(); $htmlcontent = parent::loadTemplate($tpl); require_once JPATH_SITE . '/libraries/tcpdf/tcpdf.php'; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $header = $this->course_info['fullname']; $header2 = JText::_('COM_JOOMDLEGRADES_TEACHER') . ': ' . $user->name; $header2 .= ' ' . JText::_('COM_JOOMDLEGRADES_DATE') . ': ' . date('d-m-Y'); // $pdf->SetHeaderData('', 0, $header, $header2); $pdf->SetHeaderData('', 0, $header); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFontSubsetting(false); $pdf->SetFont('times', '', 8); // add a page $pdf->AddPage("L"); // output the HTML content $pdf->writeHTML($htmlcontent, true, 0, true, 0); $pdf->Output("grades.pdf", 'D'); exit; //parent::display($tpl); }
function display($tpl = null) { $id = JRequest::getVar('course_id'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $course_info = JoomdleHelperContent::getCourseInfo((int) $id); $this->course_name = $course_info['fullname']; $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); parent::display($tpl); }
function display($tpl = null) { global $mainframe; $app = JFactory::getApplication(); $pathway =$app->getPathWay(); $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); $this->assignRef('params', $params); $id = $params->get( 'course_id' ); if (!$id) $id = JRequest::getVar( 'course_id' ); $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($id); if ($params->get('gradingsystem_show_items') == 0) $this->gcats = JoomdleHelperContent::getCourseGradeCategories($id); else { $this->gcats = JoomdleHelperContent::call_method('get_course_grade_categories_and_items', $id); $tpl = 'full'; } /* pathway */ $cat_slug = $this->course_info['cat_id'].":".$this->course_info['cat_name']; $course_slug = $this->course_info['remoteid'].":".$this->course_info['fullname']; if(is_object($menu) && $menu->query['view'] != 'coursegradecategories') { $pathway->addItem($this->course_info['cat_name'], 'index.php?view=coursecategory&cat_id='.$cat_slug); $pathway->addItem($this->course_info['fullname'], 'index.php?view=detail&cat_id='.$cat_slug.'&course_id='.$course_slug); $pathway->addItem(JText::_('COM_JOOMDLE_COURSE_GRADING_SYSTEM'), ''); } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_GRADING_SYSTEM')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); parent::display($tpl); }
function display($tpl = null) { global $mainframe, $option; $mainframe = JFactory::getApplication(); $id = JRequest::getVar('course_id'); $comp_params = JComponentHelper::getParams('com_joomdle'); $app_id = JRequest::getVar('app_id'); $this->app_info = JoomdleHelperApplications::get_application_info($app_id); $app_user = JFactory::getUser($this->app_info['user_id']); $this->app_info['name'] = $app_user->name; $course_info = JoomdleHelperContent::getCourseInfo((int) $this->app_info['course_id']); $this->app_info['course'] = $course_info['fullname']; $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { global $mainframe; $course_id = JRequest::getVar('course_id'); if (!$course_id) { $course_id = $params->get('course_id'); } $app = JFactory::getApplication(); $params = $app->getParams(); $this->assignRef('params', $params); $this->course_info = JoomdleHelperContent::getCourseInfo($course_id); $this->users = JoomdleHelperContent::call_method('get_course_students', (int) $course_id); $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_STUDENTS')); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); parent::display($tpl); }
function display($tpl = null) { global $mainframe; $app = JFactory::getApplication(); $pathway = $app->getPathWay(); $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); $this->assignRef('params', $params); $course_id = JRequest::getVar('course_id'); if (!$course_id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $id = JRequest::getVar('id'); $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_NEWS_ITEM_SELECTED'); return; } $user = JFactory::getUser(); $username = $user->username; $this->course_info = JoomdleHelperContent::getCourseInfo($course_id, $username); // user not enroled and no guest access if (!$this->course_info['enroled'] && !$this->course_info['guest']) { return; } $this->news_item = JoomdleHelperContent::call_method('get_news_item', (int) $id); /* pathway */ $cat_slug = $this->course_info['cat_id'] . ":" . $this->course_info['cat_name']; $course_slug = $this->course_info['remoteid'] . ":" . $this->course_info['fullname']; if (is_object($menu) && $menu->query['view'] != 'newsitem') { $pathway->addItem($this->course_info['cat_name'], 'index.php?view=coursecategory&cat_id=' . $cat_slug); $pathway->addItem($this->course_info['fullname'], 'index.php?view=detail&cat_id=' . $cat_slug . '&course_id=' . $course_slug); $pathway->addItem(JText::_('COM_JOOMDLE_COURSE_CONTENTS'), 'index.php?view=course&cat_id=' . $cat_slug . '&course_id=' . $course_slug); $pathway->addItem($this->news_item[0]['subject'], ''); } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname'] . ': ' . $this->news_item[0]['subject']); parent::display($tpl); }
static function getUnassignedCourses() { $user = JFactory::getUser(); $id = $user->get('id'); $username = $user->get('username'); $db = JFactory::getDBO(); $sql = "SELECT * from #__joomdle_purchased_courses" . " WHERE user_id = '{$id}' and num > 0"; $db->setQuery($sql); $courses = $db->loadObjectList(); $i = 0; if (!$courses) { return array(); } foreach ($courses as $course) { $course_info = JoomdleHelperContent::getCourseInfo((int) $course->course_id); $c[$i]['id'] = $course->course_id; $c[$i]['num'] = $course->num; $c[$i]['name'] = $course_info['fullname']; $i++; } return $c; }
function display($tpl = null) { global $mainframe; $app = JFactory::getApplication(); $pathway = $app->getPathWay(); $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); $this->assignRef('params', $params); $logged_user = JFactory::getUser(); $user_id = $logged_user->id; $id = $params->get('course_id'); if (!$id) { $id = JRequest::getVar('course_id'); } $id = (int) $id; $itemid = JoomdleHelperContent::getMenuItem(); $link = base64_encode("index.php?option=com_joomdle&view=detail&course_id={$id}&Itemid={$itemid}"); /* If user is logged, dont redirect */ if (!$user_id) { $app->redirect(JURI::base() . "index.php?option=com_users&view=login&return={$link}"); } if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $this->course_info = JoomdleHelperContent::getCourseInfo($id); $this->moodle_url = $params->get('MOODLE_URL'); /* pathway */ /* $cat_slug = $this->course_info['cat_id'].":".$this->course_info['cat_name']; if(is_object($menu) && $menu->query['view'] != 'detail') { $pathway->addItem($this->course_info['cat_name'], 'index.php?view=coursecategory&cat_id='.$cat_slug); $pathway->addItem($this->course_info['fullname'], ''); } */ parent::display($tpl); }
static function sync_course_forums($course_id) { // Create user groups $course_info = JoomdleHelperContent::getCourseInfo($course_id); JoomdleHelperJoomlagroups::add_course_groups($course_id, $course_info['fullname']); JoomdleHelperJoomlagroups::sync_group_members($course_id); // Create parent category JoomdleHelperForum::add_forum($course_id, -2, $course_info['fullname']); $sections = JoomdleHelperContent::call_method('get_course_mods', (int) $course_id, ''); foreach ($sections as $section) { foreach ($section['mods'] as $mod) { if ($mod['mod'] == 'forum' && $mod['type'] != 'news') { JoomdleHelperForum::add_forum($course_id, $mod['id'], $mod['name']); } } } }
static function send_confirmation_email($email, $course_id) { $app = JFactory::getApplication(); $comp_params = JComponentHelper::getParams('com_joomdle'); $linkstarget = $comp_params->get('linkstarget'); $moodle_url = $comp_params->get('MOODLE_URL'); $email_subject = $comp_params->get('enrol_email_subject'); $email_text = $comp_params->get('enrol_email_text'); if ($linkstarget == 'wrapper') { /* XXX After and hour tryng and searching I could not find the GOOD way to do this, so I do this kludge and it seems to work ;) */ $url = JURI::base(); $pos = strpos($url, '/administrator/'); if ($pos) { $url = substr($url, 0, $pos); } $url = trim($url, '/'); $url = $url . '/index.php?option=com_joomdle&view=wrapper&moodle_page_type=course&id=' . $course_id; // $default_itemid = $comp_params->get( 'default_itemid' ); // $url .= "&Itemid=".$default_itemid; } else { $url = $moodle_url . '/course/view.php?id=' . $course_id; } $course_info = JoomdleHelperContent::getCourseInfo((int) $course_id); $name = $course_info['fullname']; $email_text = str_replace('COURSE_NAME', $name, $email_text); $email_text = str_replace('COURSE_URL', $url, $email_text); $email_subject = str_replace('COURSE_NAME', $name, $email_subject); $email_subject = str_replace('COURSE_URL', $url, $email_subject); // Set the e-mail parameters $from = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); // Send the e-mail if (!JFactory::getMailer()->sendMail($from, $fromname, $email, $email_subject, $email_text)) { return false; } return true; }
function display($tpl = null) { global $mainframe; $app = JFactory::getApplication(); $pathway =$app->getPathWay(); $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); $this->assignRef('params', $params); $id = JRequest::getVar( 'course_id' ); if (!$id) $id = $params->get( 'course_id' ); $id = (int) $id; if (!$id) { echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED'); return; } $user = JFactory::getUser(); $username = $user->username; $this->course_info = JoomdleHelperContent::getCourseInfo($id, $username); $this->is_enroled = $this->course_info['enroled']; $moodle_version = $params->get( 'moodle_version' ); if ($moodle_version == '20') { if ($this->is_enroled) $this->mods = JoomdleHelperContent::call_method ( 'get_course_mods', (int) $id, $username); else $this->mods = JoomdleHelperContent::call_method ( 'get_course_mods', (int) $id, ''); } else { $this->mods = JoomdleHelperContent::call_method ( 'get_course_mods', (int) $id, ''); } /* pathway */ $cat_slug = $this->course_info['cat_id'].":".$this->course_info['cat_name']; $course_slug = $this->course_info['remoteid'].":".$this->course_info['fullname']; if(is_object($menu) && $menu->query['view'] != 'course') { $pathway->addItem($this->course_info['cat_name'], 'index.php?view=coursecategory&cat_id='.$cat_slug); $pathway->addItem($this->course_info['fullname'], 'index.php?view=detail&cat_id='.$cat_slug.'&course_id='.$course_slug); $pathway->addItem(JText::_('COM_JOOMDLE_COURSE_CONTENTS'), ''); } $document = JFactory::getDocument(); $document->setTitle($this->course_info['fullname']); $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); parent::display($tpl); }
static function send_confirmation_email($username, $email, $course_id, $state) { $app = JFactory::getApplication(); $comp_params = JComponentHelper::getParams('com_joomdle'); $linkstarget = $comp_params->get('linkstarget'); $moodle_url = $comp_params->get('MOODLE_URL'); $user_id = JUserHelper::getUserId($username); $user = JFactory::getUser($user_id); if ($linkstarget == 'wrapper') { /* XXX After and hour tryng and searching I could not find the GOOD way to do this, so I do this kludge and it seems to work ;) */ $url = JURI::base(); $pos = strpos($url, '/administrator/'); if ($pos) { $url = substr($url, 0, $pos); } $url = $url . '/index.php?option=com_joomdle&view=wrapper&moodle_page_type=course&id=' . $course_id; } else { $url = $moodle_url . '/course/view.php?id=' . $course_id; } $course_info = JoomdleHelperContent::getCourseInfo((int) $course_id); $name = $course_info['fullname']; /* Set language for email to the one chosen by user */ $user_lang = $user->getParam('language', ''); $default_language = JComponentHelper::getParams('com_languages')->get('administrator'); if ($user_lang) { $lang = new JLanguage($user_lang); $lang->load('com_joomdle', JPATH_ADMINISTRATOR, $user_lang, true); } else { $lang = JLanguage::getInstance($default_language); } // Set the e-mail parameters $from = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); switch ($state) { case JOOMDLE_APPLICATION_STATE_APPROVED: $subject = JText::sprintf('COM_JOOMDLE_APPLICATION_ACCEPTED_MESSAGE_SUBJECT', $name); $body = JText::sprintf($lang->_('COM_JOOMDLE_APPLICATION_ACCEPTED_MESSAGE_BODY'), $user->name, $name); break; case JOOMDLE_APPLICATION_STATE_REJECTED: $subject = JText::sprintf('COM_JOOMDLE_APPLICATION_REJECTED_MESSAGE_SUBJECT', $name); $body = JText::sprintf($lang->_('COM_JOOMDLE_APPLICATION_REJECTED_MESSAGE_BODY'), $user->name, $name); break; } // Send the e-mail if (!JFactory::getMailer()->sendMail($from, $fromname, $email, $subject, $body)) { $this->setError('ERROR_SENDING_CONFIRMATION_EMAIL'); return false; } return true; }
static function save_course_mailing_list($course_id, $type = 'course_students') { $db = JFactory::getDBO(); //XXX checkar q no existe ya $comp_params = JComponentHelper::getParams('com_joomdle'); $ml = $comp_params->get('mailing_list_integration'); $type_str = JoomdleHelperMailinglist::get_type_str($type); // Add to mailing list component $course_info = JoomdleHelperContent::getCourseInfo($course_id); switch ($ml) { case 'acymailing': $list_id = JoomdleHelperAcymailing::save_list($course_info['fullname'] . $type_str, $course_info['summary']); break; default: // No component selected, do nothing return; } // Add to joomdle table $mlist = new JObject(); $mlist->course_id = $course_id; $mlist->list_id = $list_id; $mlist->type = $type; $status = $db->insertObject('#__joomdle_mailinglists', $mlist); // Add all course members to list JoomdleHelperMailinglist::add_list_members($course_id, $type); }