From c6209ec7accc6cbf03ed63f550420f310532d71e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 16 Dec 2014 10:07:47 +0100 Subject: [PATCH] Adding "student_publication_to_take_in_gradebook" setting see BT#8816 --- .../lib/be/studentpublicationlink.class.php | 15 +++++++++++++-- main/install/configuration.dist.php | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/main/gradebook/lib/be/studentpublicationlink.class.php b/main/gradebook/lib/be/studentpublicationlink.class.php index 0c09c1afd5c..1a8cf227746 100755 --- a/main/gradebook/lib/be/studentpublicationlink.class.php +++ b/main/gradebook/lib/be/studentpublicationlink.class.php @@ -183,8 +183,19 @@ public function calc_score($stud_id = null) $sql .= " AND user_id = $stud_id "; } - // order by id, that way the student's first attempt is accessed first - $sql .= ' ORDER BY id'; + $order = api_get_configuration_value('student_publication_to_take_in_gradebook'); + + switch ($order) { + case 'last': + // latest attempt + $sql .= ' ORDER BY sent_date DESC'; + break; + case 'first': + default: + // first attempt + $sql .= ' ORDER BY id'; + break; + } $scores = Database::query($sql); diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index f5dbfaa3534..a12065ee274 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -267,3 +267,5 @@ //$_configuration['redirect_admin_to_courses_list'] = true; // Shows the custom course icon instead of the classic green board icon //$_configuration['course_images_in_courses_list'] = false; +// Which student publication will be taken when connected to the gradebook: first|last +//$_configuration['student_publication_to_take_in_gradebook'] = 'first';