Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed context selection

  • Loading branch information...
commit 0d699c2449606b39cbba269388e2db1105a624b1 1 parent 6086e1a
bobopinna authored
View
5 mod/scorm/aicc.php
@@ -135,7 +135,10 @@
break;
case 'putparam':
if ($status == 'Running') {
- if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', $context)) {
+ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $scorm->course)) {
+ echo "error = 1\nerror_text = Unknown\n"; // No one must see this error message if not hacked
+ }
+ if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
$initlessonstatus = 'not attempted';
$lessonstatus = 'not attempted';
if (isset($SESSION->scorm_lessonstatus)) {
View
2  mod/scorm/datamodel.php
@@ -37,7 +37,7 @@
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
- if (has_capability('mod/scorm:savetrack', $context)) {
+ if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {
foreach ($_POST as $element => $value) {
if (substr($element,0,3) == 'cmi') {
$element = str_replace('__','.',$element);
View
15 mod/scorm/db/access.php
@@ -47,6 +47,20 @@
)
),
+ 'mod/scorm:viewreport' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_PREVENT,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
'mod/scorm:savetrack' => array(
'captype' => 'write',
@@ -75,7 +89,6 @@
)
)
-
);
?>
View
3  mod/scorm/index.php
@@ -52,6 +52,7 @@
foreach ($scorms as $scorm) {
+ $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
$tt = "";
if ($course->format == "weeks" or $course->format == "topics") {
if ($scorm->section) {
@@ -61,7 +62,7 @@
$tt = userdate($scorm->timemodified);
}
$report = ' ';
- if (has_capability('moodle/user:viewuseractivitiesreport', $context)) {
+ if (has_capability('mod/scorm:viewreport', $context)) {
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
if ($trackedusers->c > 0) {
$reportshow = '<a href="report.php?a='.$scorm->id.'">'.get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
View
3  mod/scorm/locallib.php
@@ -376,6 +376,7 @@ function scorm_course_format_display($user,$course) {
$strupdate = get_string('update');
$strmodule = get_string('modulename','scorm');
+ $context get_context_instance(CONTEXT_COURSE,$course->id);
echo '<div class="mod-scorm">';
if ($scorms = get_all_instances_in_course('scorm', $course)) {
@@ -410,7 +411,7 @@ function scorm_course_format_display($user,$course) {
print_simple_box($headertext,'','100%');
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%');
} else {
- if (has_capability('moodle/course:', $context)) {
+ if (has_capability('moodle/course:update', $context)) {
// Create a new activity
redirect($CFG->wwwroot.'/course/mod.php?id='.$course->id.'&amp;section=0&sesskey='.sesskey().'&amp;add=scorm');
} else {
View
2  mod/scorm/player.php
@@ -60,7 +60,7 @@
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
- if (!$cm->visible and !has_capability('moodle/user:viewhiddenactivities',$context)) {
+ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE,$course->id))) {
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);
View
2  mod/scorm/report.php
@@ -42,7 +42,7 @@
require_login($course->id, false, $cm);
- if (!has_capability('moodle/user:viewuseractivitiesreport',$context)) {
+ if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id)) {
error("You are not allowed to use this script");
}
View
19 mod/scorm/view.php
@@ -5,10 +5,10 @@
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
- //$organization = optional_param('organization', '', PARAM_INT); // organization ID
+ $organization = optional_param('organization', '', PARAM_INT); // organization ID
if (!empty($id)) {
- if (! $cm = $cm = get_coursemodule_from_id('scorm', $id)) {
+ if (! $cm = get_coursemodule_from_id('scorm', $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
@@ -33,6 +33,8 @@
require_login($course->id, false, $cm);
+ $context = get_context_instance(CONTEXT_COURSE, $course->id)
+
if (isset($SESSION->scorm_scoid)) {
unset($SESSION->scorm_scoid);
}
@@ -69,25 +71,14 @@
}
if (has_capability('moodle/course:manageactivities', $context)) {
- // Added by Pham Minh Duc
- $examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount');
- if ($examNumber->examCount > 0){
- echo "<div class=\"reportlink\"><img src='pix/SuaHeSoDiem.png' /><a target=\"{$CFG->framename}\" href=\"coefficientSetting.php?id=$cm->id\"> ".get_string('scorecoefficientsetting','scorm',$examNumber->examCount).'</a></div>';
- }
- // End Add
-
$trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
if ($trackedusers->c > 0) {
- echo "<div class=\"reportlink\"><img src='pix/ThongKe.png' /><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
+ echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
} else {
echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
}
}
- // Added by Pham Minh Duc
- $USER->setAttempt = 'notset';
- // End Add
-
// Print the main part of the page
print_heading(format_string($scorm->name));
print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');
Please sign in to comment.
Something went wrong with that request. Please try again.