فهرست منبع

Rename function, fix variables

Julio Montoya 9 سال پیش
والد
کامیت
f3518fc502
4فایلهای تغییر یافته به همراه20 افزوده شده و 19 حذف شده
  1. 1 1
      main/announcements/announcements.php
  2. 9 6
      main/inc/lib/tracking.lib.php
  3. 8 10
      main/tracking/courseLog.php
  4. 2 2
      tests/main/inc/lib/tracking.lib.test.php

+ 1 - 1
main/announcements/announcements.php

@@ -237,7 +237,7 @@ switch ($action) {
                 // determines which users have to be warned (i.e the users who have been inactive for x days or more
                 $since = isset($_GET['since']) ? intval($_GET['since']) : 6;
                 // getting the users who have to be reminded
-                $to = Tracking:: get_inactives_students_in_course(
+                $to = Tracking:: getInactiveStudentsInCourse(
                     api_get_course_int_id(),
                     $since,
                     api_get_session_id()

+ 9 - 6
main/inc/lib/tracking.lib.php

@@ -3674,11 +3674,11 @@ class Tracking
     /**
      * Get inactive students in course
      * @param    int   $courseId
-     * @param    string    Since login course date (optional, default = 'never')
-     * @param    int        Session id    (optional)
-     * @return    array    Inactives users
+     * @param    string  $since  Since login course date (optional, default = 'never')
+     * @param    int        $session_id    (optional)
+     * @return    array    Inactive users
      */
-    public static function get_inactives_students_in_course($course_code, $since = 'never', $session_id=0)
+    public static function getInactiveStudentsInCourse($courseId, $since = 'never', $session_id = 0)
     {
         $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
         $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
@@ -3686,9 +3686,11 @@ class Tracking
         $tableCourse   = Database :: get_main_table(TABLE_MAIN_COURSE);
         $inner = '';
         $now = api_get_utc_datetime();
+        $courseId = intval($courseId);
 
-        $courseInfo = api_get_course_info($course_code);
-        $courseId = $courseInfo['real_id'];
+        if (empty($courseId)) {
+            return false;
+        }
 
         if ($session_id != 0) {
             $inner = ' INNER JOIN '.$tbl_session_course_user.' session_course_user
@@ -3721,6 +3723,7 @@ class Tracking
         while($user = Database::fetch_array($rs)) {
             $inactive_users[] = $user['user_id'];
         }
+
         return $inactive_users;
     }
 

+ 8 - 10
main/tracking/courseLog.php

@@ -157,10 +157,10 @@ $TABLETRACK_LINKS       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS
 $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
 $TABLETRACK_ACCESS_2    = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
 $TABLETRACK_EXERCISES 	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
-$TABLECOURSUSER	        = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-$TABLECOURSE	        = Database::get_main_table(TABLE_MAIN_COURSE);
-$table_user             = Database::get_main_table(TABLE_MAIN_USER);
-$TABLEQUIZ              = Database::get_course_table(TABLE_QUIZ_TEST);
+$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+$TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
+$table_user = Database::get_main_table(TABLE_MAIN_USER);
+$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
 
 $sessionId = api_get_session_id();
 
@@ -342,12 +342,7 @@ if (count($a_students) > 0) {
     $form = new FormValidator(
         'reminder_form',
         'get',
-        api_get_path(REL_CODE_PATH).'announcements/announcements.php'
-    );
-    $renderer = $form->defaultRenderer();
-    $renderer->setElementTemplate(
-        '<span>{label} {element}</span>&nbsp;<button class="save" type="submit">'.get_lang('SendNotification').'</button>',
-        'since'
+        api_get_path(REL_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq()
     );
     $options = array (
         2 => '2 '.get_lang('Days'),
@@ -372,6 +367,9 @@ if (count($a_students) > 0) {
 
     $form->addElement('hidden', 'action', 'add');
     $form->addElement('hidden', 'remindallinactives', 'true');
+    $form->addElement('hidden', 'cidReq', $courseInfo['code']);
+    $form->addElement('hidden', 'id_session', api_get_session_id());
+    $form->addButtonSend(get_lang('SendNotification'));
 
     $extra_field_select = TrackingCourseLog::display_additional_profile_fields();
 

+ 2 - 2
tests/main/inc/lib/tracking.lib.test.php

@@ -210,12 +210,12 @@ class TestTracking extends UnitTestCase {
 	 	//var_dump($res);
 	}
 
-	function testget_inactives_students_in_course() {
+	function testGetInactiveStudentsInCourse() {
 		global $_course;
 		$course_code = $_course;
 		$since='2010-10-02';
 		$session_id='';
-		$res=Tracking::get_inactives_students_in_course($course_code, $since, $session_id);
+		$res=Tracking::getInactiveStudentsInCourse($course_code, $since, $session_id);
 	 	if(!is_null($res))$this->assertTrue(is_array($res));
 	 	//var_dump($res);
 	}