3 /// This page prints a particular instance of lams
4 /// (Replace lams with the name of your module)
6 require_once("../../config.php");
7 require_once("lib.php");
8 require_once("constants.php");
10 $id = optional_param('id', 0, PARAM_INT
); // Course Module ID, or
12 if (! $cm = get_coursemodule_from_id('lams', $id)) {
13 error("Course Module ID was incorrect");
16 if (! $course = get_record("course", "id", $cm->course
)) {
17 error("Course is misconfigured");
20 if (! $lams = get_record("lams", "id", $cm->instance
)) {
21 error("Course module is incorrect");
24 require_login($course, true, $cm);
25 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
27 add_to_log($course->id
, "lams", "view", "view.php?id=$cm->id", "$lams->id");
29 /// Print the page header
30 $navigation = build_navigation('', $cm);
31 print_header_simple(format_string($lams->name
), "", $navigation, "", "", true,
32 update_module_button($cm->id
, $course->id
, get_string("lesson","lams")), navmenu($course, $cm));
34 echo '<table id="layout-table"><tr>';
35 echo '<td id="middle-column">';
36 print_heading(format_string($lams->name
));
38 //$strlamss = get_string("modulenameplural", "lams");
39 //$strlams = get_string("modulename", "lams");
41 //print_header("$course->shortname: $lams->name", "$course->fullname",
42 // "$navigation <A HREF=index.php?id=$course->id>$strlamss</A> -> $lams->name",
43 // "", "", true, update_module_button($cm->id, $course->id, $strlams),
44 // navmenu($course, $cm));
46 /// Print the main part of the page
47 if(has_capability('mod/lams:manage', $context)){
48 $datetime = date("F d,Y g:i a");
49 $plaintext = trim($datetime).trim($USER->username
).trim($LAMSCONSTANTS->monitor_method
).trim($CFG->lams_serverid
).trim($CFG->lams_serverkey
);
50 $hash = sha1(strtolower($plaintext));
51 $url = $CFG->lams_serverurl
.$LAMSCONSTANTS->login_request
.
52 '?'.$LAMSCONSTANTS->param_uid
.'='.$USER->username
.
53 '&'.$LAMSCONSTANTS->param_method
.'='.$LAMSCONSTANTS->monitor_method
.
54 '&'.$LAMSCONSTANTS->param_timestamp
.'='.urlencode($datetime).
55 '&'.$LAMSCONSTANTS->param_serverid
.'='.$CFG->lams_serverid
.
56 '&'.$LAMSCONSTANTS->param_hash
.'='.$hash.
57 '&'.$LAMSCONSTANTS->param_lsid
.'='.$lams->learning_session_id
.
58 '&'.$LAMSCONSTANTS->param_courseid
.'='.$lams->course
;
59 print_simple_box_start('center');
60 echo '<a target="LAMS Monitor" title="LAMS Monitor" href="'.$url.'">'.get_string("openmonitor", "lams").'</a>';
61 print_simple_box_end();
63 $plaintext = trim($datetime).trim($USER->username
).trim($LAMSCONSTANTS->learner_method
).trim($CFG->lams_serverid
).trim($CFG->lams_serverkey
);
64 $hash = sha1(strtolower($plaintext));
65 $url = $CFG->lams_serverurl
.$LAMSCONSTANTS->login_request
.
66 '?'.$LAMSCONSTANTS->param_uid
.'='.$USER->username
.
67 '&'.$LAMSCONSTANTS->param_method
.'='.$LAMSCONSTANTS->learner_method
.
68 '&'.$LAMSCONSTANTS->param_timestamp
.'='.urlencode($datetime).
69 '&'.$LAMSCONSTANTS->param_serverid
.'='.$CFG->lams_serverid
.
70 '&'.$LAMSCONSTANTS->param_hash
.'='.$hash.
71 '&'.$LAMSCONSTANTS->param_lsid
.'='.$lams->learning_session_id
.
72 '&'.$LAMSCONSTANTS->param_courseid
.'='.$lams->course
;
73 print_simple_box_start('center');
74 echo '<a target="LAMS Learner" title="LAMS Learner" href="'.$url.'">'.get_string("openlearner", "lams").'</a>';
75 print_simple_box_end();
76 }else if(has_capability('mod/lams:participate', $context)){
77 $datetime = date("F d,Y g:i a");
78 $plaintext = trim($datetime).trim($USER->username
).trim($LAMSCONSTANTS->learner_method
).trim($CFG->lams_serverid
).trim($CFG->lams_serverkey
);
79 $hash = sha1(strtolower($plaintext));
80 $url = $CFG->lams_serverurl
.$LAMSCONSTANTS->login_request
.
81 '?'.$LAMSCONSTANTS->param_uid
.'='.$USER->username
.
82 '&'.$LAMSCONSTANTS->param_method
.'='.$LAMSCONSTANTS->learner_method
.
83 '&'.$LAMSCONSTANTS->param_timestamp
.'='.urlencode($datetime).
84 '&'.$LAMSCONSTANTS->param_serverid
.'='.$CFG->lams_serverid
.
85 '&'.$LAMSCONSTANTS->param_hash
.'='.$hash.
86 '&'.$LAMSCONSTANTS->param_lsid
.'='.$lams->learning_session_id
.
87 '&'.$LAMSCONSTANTS->param_courseid
.'='.$lams->course
;
88 print_simple_box_start('center');
89 echo '<a target="LAMS Learner" title="LAMS Learner" href="'.$url.'">'.get_string("openlearner", "lams").'</a>';
90 print_simple_box_end();
93 if ($lams->introduction
) {
94 print_box(format_text($lams->introduction
), 'generalbox', 'intro');
99 echo '</td></tr></table>';
104 print_footer($course);