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 '