Fisheye: Tag c8c8851ebc6c34fc0e8e13c8a880fe21fc03b8cc refers to a dead (removed) revision in file `moodle/mod/lamslesson/callback.php'.
Fisheye: No comparison available. Pass `N' to diff?
Index: moodle/mod/lamslesson/lib.php
===================================================================
diff -u -rde0123e92410e972ef17ff6f4c252cfa3fc2cd85 -r4b0e8db9f2b4f097606ba7dda5ea0c6f61094f45
--- moodle/mod/lamslesson/lib.php (.../lib.php) (revision de0123e92410e972ef17ff6f4c252cfa3fc2cd85)
+++ moodle/mod/lamslesson/lib.php (.../lib.php) (revision 4b0e8db9f2b4f097606ba7dda5ea0c6f61094f45)
@@ -548,8 +548,8 @@
return file_get_contents($request);
}
-function lamslesson_get_outputs($username, $lang, $country, $lessonid, $courseid, $method,$foruser) {
- global $CFG;
+function lamslesson_get_lams_outputs($username,$lamslesson,$foruser) {
+ global $CFG, $DB;
$datetime = date('F d,Y g:i a');
$plaintext = trim($datetime)
@@ -559,28 +559,69 @@
$hash = sha1(strtolower($plaintext));
$request = $CFG->lamslesson_serverurl. LAMSLESSON_LESSON_MANAGER
.'?serverId='.$CFG->lamslesson_serverid
- .'&courseId='.$courseid
+ .'&courseId='.$lamslesson->course
.'&username='.$username
.'&datetime='.urlencode(strtolower($datetime))
.'&hashValue='.$hash
- .'&lang='.$lang
- .'&country='.$country
- .'&method='.$method
- .'&lsId='.$lessonid
+ .'&lang=en'
+ .'&country=AU'
+ .'&method='.LAMSLESSON_OUTPUT_METHOD
+ .'&lsId='.$lamslesson->lesson_id
.'&outputsUser='.$foruser;
// GET call to LAMS
$xml = file_get_contents($request);
- $xml_array = xmlize($xml);
+ $results = xmlize($xml);
- return $xml_array;
+ // Get the outputs from the activities
+ $learneroutputs = $results['ToolOutputs']['#']['LearnerOutput'];
+ $activityoutputs = $learneroutputs['0']['#']['Activity'];
+
+ $maxresult = 0;
+ $userresult = 0;
+
+ // Calculate max and user results (if they exist)
+
+ foreach ($activityoutputs as $k => $v){
+ // If activities don't have or produce any output then we just ignore them
+ if (!empty($v['#'])) {
+ foreach ($v['#']['ToolOutput'] as $k2 => $v2) {
+ $activityoutputname = $v2['@']['name'];
+ // The only numeric outputs we get from LAMS are for the MCQ and Assessment activities
+ // learner.total.score = Assessment
+ // learner.mark = MCQ
+ if ($activityoutputname == 'learner.mark' || $activityoutputname == 'learner.total.score') {
+ $actname = $v2['@']['name'];
+ $actmaxresult = $v2['@']['marksPossible'];
+ $actuserresult = $v2['@']['output'];
+ $userresult += $actuserresult;
+ $maxresult += $actmaxresult;
+
+ }
+ }
+ }
+
+ }
+
+ // If there's outputs from LAMS, then we process them and add them to the gradebook
+ if (!$maxresult == 0) {
+
+ // Now calculate the percentage and then multiply it by the lamslesson grade.
+ $gradebookmark = ($userresult / $maxresult) * $lamslesson->grade;
+
+ // Put this into gradebook
+ $user = $DB->get_record('user', array('username'=>$foruser));
+ lamslesson_update_grades($lamslesson, $user->id, $gradebookmark);
+ return $gradebookmark;
+
+ }
+
}
-
/**
* Return URL to join a LAMS lesson as a learner or staff depending on method.
* URL redirects LAMS to learner or monitor interface depending on method.
Index: moodle/mod/lamslesson/view.php
===================================================================
diff -u -rf7407b9bda714e8a309c3742e915dee4027c3f93 -r4b0e8db9f2b4f097606ba7dda5ea0c6f61094f45
--- moodle/mod/lamslesson/view.php (.../view.php) (revision f7407b9bda714e8a309c3742e915dee4027c3f93)
+++ moodle/mod/lamslesson/view.php (.../view.php) (revision 4b0e8db9f2b4f097606ba7dda5ea0c6f61094f45)
@@ -111,6 +111,7 @@
echo $OUTPUT->box_end();
// Once we have progress info ready
+
$progress = lamslesson_get_student_progress($USER->username,$lamslesson->lesson_id, $course->id);
// Progress details
@@ -150,53 +151,12 @@
// Now let's get the score from LAMS and add it into gradebook
// Getting result from LAMS
- $results = lamslesson_get_outputs($USER->username,'en','AU',$lamslesson->lesson_id,$cm->course,LAMSLESSON_OUTPUT_METHOD,$USER->username);
+ $gradebookmark = lamslesson_get_lams_outputs($USER->username,$lamslesson,$USER->username);
- // Get the outputs from the activities
- $learneroutputs = $results['ToolOutputs']['#']['LearnerOutput'];
- $activityoutputs = $learneroutputs['0']['#']['Activity'];
-
- $maxresult = 0;
- $userresult = 0;
-
- // Calculate max and user results (if they exist)
-
- foreach ($activityoutputs as $k => $v){
- // If activities don't have or produce any output then we just ignore them
- if (!empty($v['#'])) {
- foreach ($v['#']['ToolOutput'] as $k2 => $v2) {
- $activityoutputname = $v2['@']['name'];
- // The only numeric outputs we get from LAMS are for the MCQ and Assessment activities
- // learner.total.score = Assessment
- // learner.mark = MCQ
- if ($activityoutputname == 'learner.mark' || $activityoutputname == 'learner.total.score') {
- $actname = $v2['@']['name'];
- $actmaxresult = $v2['@']['marksPossible'];
- $actuserresult = $v2['@']['output'];
- $userresult += $actuserresult;
- $maxresult += $actmaxresult;
-
- }
- }
- }
-
- }
-
-
- // If there's outputs from LAMS, then we process them and add them to the gradebook
- if (!$maxresult == 0) {
-
- //print("Max total result: " . $maxresult . "
User total result: " . $userresult . " " . $lamslesson->grade);
-
- // Now calculate the percentage and then multiply it by the lamslesson grade.
- $gradebookmark = ($userresult / $maxresult) * $lamslesson->grade;
+ if (!empty($gradebookmark)) {
echo '