/**
* Local Redirect
*
* This local plugin that adds a 'friendly url' version of Google analytics
* to Moodle
*
* @package local
* @subpackage local_googleanalytics
* @copyright 2013 Bas Brands, www.basbrands.nl
* @author Bas Brands and Gavin Henrick.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function ga_trackurl() {
global $CFG, $DB, $PAGE, $COURSE, $OUTPUT;
$pageinfo = get_context_info_array($PAGE->context->id);
$trackurl = array();
if ($COURSE->id == 1) {
return '';
}
// Adds course category name.
if (isset($pageinfo[1]->category)) {
if ($category = $DB->get_record('course_categories', array('id'=>$pageinfo[1]->category))) {
$trackurl[] = urlencode($category->name);
}
}
// Adds course full name.
if (isset($pageinfo[1]->fullname)) {
$trackurl[] = urlencode($pageinfo[1]->fullname);
}
// Adds activity name.
if (isset($pageinfo[2]->name)) {
$trackurl[] = urlencode($pageinfo[2]->name);
}
return implode('/', $trackurl);
}
开发者ID:anilch,项目名称:Personel,代码行数:43,代码来源:lib.php
示例3: analytics_trackurl
/**
* Analytics
*
* This module provides extensive analytics on a platform of choice
* Currently support Google Analytics and Piwik
*
* @package local_analytics
* @copyright David Bezemer <[email protected]>, www.davidbezemer.nl
* @author David Bezemer <[email protected]>, Bas Brands <[email protected]>, Gavin Henrick <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function analytics_trackurl()
{
global $DB, $PAGE;
$pageinfo = get_context_info_array($PAGE->context->id);
$trackurl = "'/";
// Adds course category name.
if (isset($pageinfo[1]->category)) {
if ($category = $DB->get_record('course_categories', array('id' => $pageinfo[1]->category))) {
$cats = explode("/", $category->path);
foreach (array_filter($cats) as $cat) {
if ($categorydepth = $DB->get_record("course_categories", array("id" => $cat))) {
$trackurl .= urlencode($categorydepth->name) . '/';
}
}
}
}
// Adds course full name.
if (isset($pageinfo[1]->fullname)) {
if (isset($pageinfo[2]->name)) {
$trackurl .= urlencode($pageinfo[1]->fullname) . '/';
} else {
if ($PAGE->user_is_editing()) {
$trackurl .= urlencode($pageinfo[1]->fullname) . '/' . get_string('edit');
} else {
$trackurl .= urlencode($pageinfo[1]->fullname) . '/' . get_string('view');
}
}
}
// Adds activity name.
if (isset($pageinfo[2]->name)) {
$trackurl .= urlencode($pageinfo[2]->modname) . '/' . urlencode($pageinfo[2]->name);
}
$trackurl .= "'";
return $trackurl;
}
/**
* Serve questiontext files in the question text when they are displayed in this report.
*
* @package mod_offlinequiz
* @category files
* @param stdClass $context the context
* @param int $questionid the question id
* @param array $args remaining file args
* @param bool $forcedownload
* @param array $options additional options affecting the file serving
*/
function offlinequiz_statistics_questiontext_preview_pluginfile($context, $questionid, $args, $forcedownload, array $options = array())
{
global $CFG;
require_once $CFG->dirroot . '/mod/offlinequiz/locallib.php';
list($context, $course, $cm) = get_context_info_array($context->id);
require_login($course, false, $cm);
// Assume only trusted people can see this report. There is no real way to
// validate questionid, becuase of the complexity of random quetsions.
require_capability('offlinequiz/statistics:view', $context);
question_send_questiontext_file($questionid, $args, $forcedownload, $options);
}
/**
* Serve question files when they are displayed in this export format.
*
* @param context $previewcontext the quiz context
* @param int $questionid the question id.
* @param context $filecontext the file (question) context
* @param string $filecomponent the component the file belongs to.
* @param string $filearea the file area.
* @param array $args remaining file args.
* @param bool $forcedownload.
* @param array $options additional options affecting the file serving.
*/
function qformat_xhtml_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
global $CFG;
list($context, $course, $cm) = get_context_info_array($previewcontext->id);
require_login($course, false, $cm);
question_require_capability_on($questionid, 'view');
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $options);
}
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:lib.php
示例9: quiz_statistics_question_preview_pluginfile
/**
* Serve questiontext files in the question text when they are displayed in this report.
*
* @package quiz_statistics
* @category files
* @param context $previewcontext the quiz context
* @param int $questionid the question id.
* @param context $filecontext the file (question) context
* @param string $filecomponent the component the file belongs to.
* @param string $filearea the file area.
* @param array $args remaining file args.
* @param bool $forcedownload.
* @param array $options additional options affecting the file serving.
*/
function quiz_statistics_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
global $CFG;
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
list($context, $course, $cm) = get_context_info_array($previewcontext->id);
require_login($course, false, $cm);
// Assume only trusted people can see this report. There is no real way to
// validate questionid, becuase of the complexity of random quetsions.
require_capability('quiz/statistics:view', $context);
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $options);
}
// get manager by id
$manager = get_grading_manager($areaid);
} else {
// get manager by context and component
if (is_null($contextid) or is_null($component) or is_null($area)) {
throw new coding_exception('The caller script must identify the gradable area.');
}
$context = context::instance_by_id($contextid, MUST_EXIST);
$manager = get_grading_manager($context, $component, $area);
}
if ($manager->get_context()->contextlevel < CONTEXT_COURSE) {
throw new coding_exception('Unsupported gradable area context level');
}
// get the currently active method
$method = $manager->get_active_method();
list($context, $course, $cm) = get_context_info_array($manager->get_context()->id);
require_login($course, true, $cm);
require_capability('moodle/grade:managegradingforms', $context);
if (!empty($returnurl)) {
$returnurl = new moodle_url($returnurl);
} else {
$returnurl = null;
}
$PAGE->set_url($manager->get_management_url($returnurl));
navigation_node::override_active_url($manager->get_management_url());
$PAGE->set_title(get_string('gradingmanagement', 'core_grading'));
$PAGE->set_heading(get_string('gradingmanagement', 'core_grading'));
$output = $PAGE->get_renderer('core_grading');
// process the eventual change of the active grading method
if (!empty($setmethod)) {
require_sesskey();
/**
* Called via pluginfile.php -> question_pluginfile to serve files belonging to
* a question in a question_attempt when that attempt is a preview.
*
* @package core_question
* @category files
* @param stdClass $course course settings object
* @param stdClass $context context object
* @param string $component the name of the component we are serving files for.
* @param string $filearea the name of the file area.
* @param int $qubaid the question_usage this image belongs to.
* @param int $slot the relevant slot within the usage.
* @param array $args the remaining bits of the file path.
* @param bool $forcedownload whether the user must be forced to download the file.
* @param array $options additional options affecting the file serving
* @return bool false if file not found, does not return if found - justsend the file
*/
function question_preview_question_pluginfile($course, $context, $component, $filearea, $qubaid, $slot, $args, $forcedownload, $fileoptions)
{
global $USER, $DB, $CFG;
list($context, $course, $cm) = get_context_info_array($context->id);
require_login($course, false, $cm);
$quba = question_engine::load_questions_usage_by_activity($qubaid);
if (!question_has_capability_on($quba->get_question($slot), 'use')) {
send_file_not_found();
}
$options = new question_display_options();
$options->feedback = question_display_options::VISIBLE;
$options->numpartscorrect = question_display_options::VISIBLE;
$options->generalfeedback = question_display_options::VISIBLE;
$options->rightanswer = question_display_options::VISIBLE;
$options->manualcomment = question_display_options::VISIBLE;
$options->history = question_display_options::VISIBLE;
if (!$quba->check_file_access($slot, $options, $component, $filearea, $args, $forcedownload)) {
send_file_not_found();
}
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$context->id}/{$component}/{$filearea}/{$relativepath}";
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $fileoptions);
}
请发表评论