Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 19 #27

Open
wants to merge 8 commits into
base: MOODLE_27_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ims-blti/blti.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ function isInstructor() {
}

function getUserEmail() {
$email = $this->info['lis_person_contact_email_primary'];
if ( strlen($email) > 0 ) return $email;
# set default email in the event privacy settings don't pass in email.
$email = $this->info['user_id'] . "@ltiuser.com";
if ( isset($this->info['lis_person_contact_email_primary']) ) $email = $this->info['lis_person_contact_email_primary'];
# Sakai Hack
$email = $this->info['lis_person_contact_emailprimary'];
if ( strlen($email) > 0 ) return $email;
return false;
if ( isset($this->info['lis_person_contact_emailprimary']) ) $email = $this->info['lis_person_contact_emailprimary'];
return $email;
}

function getUserShortName() {
Expand Down
73 changes: 53 additions & 20 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,22 @@ function local_ltiprovider_extends_navigation ($nav) {
}

// Delete all the navigation nodes except the course one
$coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE);
foreach (array('myprofile', 'users', 'site', 'home', 'myhome', 'mycourses', 'courses', '1') as $nodekey) {
if ($node = $nav->get($nodekey)) {
$node->remove();
if ($coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE)) {
foreach (array('myprofile', 'users', 'site', 'home', 'myhome', 'mycourses', 'courses', '1') as $nodekey) {
if ($node = $nav->get($nodekey)) {
$node->remove();
}
}
$nav->children->add($coursenode);
}
$nav->children->add($coursenode);

// Custom CSS
if (isset($SESSION->ltiprovider) and !$PAGE->requires->is_head_done()) {
$PAGE->requires->css(new moodle_url('/local/ltiprovider/styles.php', array('id' => $SESSION->ltiprovider->id)));
} else {
$url = new moodle_url('/local/ltiprovider/styles.js.php',
array('id' => $SESSION->ltiprovider->id, 'rand' => rand(0, 1000)));
$PAGE->requires->js($url);
}
}
}
Expand All @@ -132,14 +137,28 @@ function local_ltiprovider_add_tool($tool) {
$tool->timemodified = $tool->timecreated;
}

$tool->sendgrades = (isset($tool->sendgrades)) ? 1 : 0;
$tool->forcenavigation = (isset($tool->forcenavigation)) ? 1 : 0;
$tool->hidepageheader = (isset($tool->hidepageheader)) ? 1 : 0;
$tool->hidepagefooter = (isset($tool->hidepagefooter)) ? 1 : 0;
$tool->hideleftblocks = (isset($tool->hideleftblocks)) ? 1 : 0;
$tool->hiderightblocks = (isset($tool->hiderightblocks)) ? 1 : 0;
$tool->syncmembers = (isset($tool->syncmembers)) ? 1 : 0;

if (!isset($tool->sendgrades)) {
$tool->sendgrades = 0;
}
if (!isset($tool->forcenavigation)) {
$tool->forcenavigation = 0;
}
if (!isset($tool->hidepageheader)) {
$tool->hidepageheader = 0;
}
if (!isset($tool->hidepagefooter)) {
$tool->hidepagefooter = 0;
}
if (!isset($tool->hideleftblocks)) {
$tool->hideleftblocks = 0;
}
if (!isset($tool->hiderightblocks)) {
$tool->hiderightblocks = 0;
}
if (!isset($tool->syncmembers)) {
$tool->syncmembers = 0;
}

$tool->id = $DB->insert_record('local_ltiprovider', $tool);

return $tool->id;
Expand All @@ -155,13 +174,27 @@ function local_ltiprovider_update_tool($tool) {

$tool->timemodified = time();

$tool->sendgrades = (isset($tool->sendgrades)) ? 1 : 0;
$tool->forcenavigation = (isset($tool->forcenavigation)) ? 1 : 0;
$tool->hidepageheader = (isset($tool->hidepageheader)) ? 1 : 0;
$tool->hidepagefooter = (isset($tool->hidepagefooter)) ? 1 : 0;
$tool->hideleftblocks = (isset($tool->hideleftblocks)) ? 1 : 0;
$tool->hiderightblocks = (isset($tool->hiderightblocks)) ? 1 : 0;
$tool->syncmembers = (isset($tool->syncmembers)) ? 1 : 0;
if (!isset($tool->sendgrades)) {
$tool->sendgrades = 0;
}
if (!isset($tool->forcenavigation)) {
$tool->forcenavigation = 0;
}
if (!isset($tool->hidepageheader)) {
$tool->hidepageheader = 0;
}
if (!isset($tool->hidepagefooter)) {
$tool->hidepagefooter = 0;
}
if (!isset($tool->hideleftblocks)) {
$tool->hideleftblocks = 0;
}
if (!isset($tool->hiderightblocks)) {
$tool->hiderightblocks = 0;
}
if (!isset($tool->syncmembers)) {
$tool->syncmembers = 0;
}

$DB->update_record('local_ltiprovider', $tool);
}
Expand Down
4 changes: 2 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ function local_ltiprovider_enrol_user($tool, $user, $roles, $return = false) {
*/
function local_ltiprovider_populate($user, $context, $tool) {
global $CFG;
$user->firstname = isset($context->info['lis_person_name_given'])? $context->info['lis_person_name_given'] : $context->getUserEmail();
$user->lastname = isset($context->info['lis_person_name_family'])? $context->info['lis_person_name_family']: '';
$user->firstname = isset($context->info['lis_person_name_given'])? $context->info['lis_person_name_given'] : $context->info['user_id'];
$user->lastname = isset($context->info['lis_person_name_family'])? $context->info['lis_person_name_family']: $context->info['context_id'];
$user->email = clean_param($context->getUserEmail(), PARAM_EMAIL);
$user->city = (!empty($tool->city)) ? $tool->city : "";
$user->country = (!empty($tool->country)) ? $tool->country : "";
Expand Down
53 changes: 53 additions & 0 deletions styles.js.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Custom styles for a tool.
*
* @package local
* @subpackage ltiprovider
* @copyright 2011 Juan Leyva <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(dirname(__FILE__) . '/../../config.php');

$toolid = required_param('id', PARAM_INT);

$url = $CFG->wwwroot . "/local/ltiprovider/styles.php?id=$toolid";
?>

function local_ltiprovider_loadjscssfile(){
var url = "<?php echo $url; ?>";
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", url);
var head = document.getElementsByTagName("head");
if (head) {
head[0].appendChild(fileref)
}
}

// Waiting DOM ready (hide effect).
YUI().use('node', function(Y) {
Y.on("domready", function(){
local_ltiprovider_loadjscssfile();
});
});

// Without waiting.
local_ltiprovider_loadjscssfile();
4 changes: 4 additions & 0 deletions styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#page-header{
display: none;
}

header.navbar {
display: none;
}
';
}
if ($tool->hidepagefooter or $SESSION->ltiprovider->hidepagefooter) {
Expand Down
4 changes: 2 additions & 2 deletions tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@

if ($moodlecontext->contextlevel == CONTEXT_MODULE) {
// Enrol the user in the activity
if (($tool->aroleinst and in_array('Instructor', $roles)) or ($tool->arolelearn and in_array('Learner', $roles))) {
$roleid = ($role == 'Instructor')? $tool->aroleinst: $tool->arolelearn;
if (($tool->aroleinst and in_array('instructor', $roles)) or ($tool->arolelearn and in_array('learner', $roles))) {
$roleid = ($role == 'instructor')? $tool->aroleinst: $tool->arolelearn;
role_assign($roleid, $user->id, $tool->contextid);
}
}
Expand Down