ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Missing course or am I missing something


  • 2010-11-18 11:39:53

    Missing course or am I missing something

    I created 4 courses, and noticed in "Browse Courses" it was showing "Results Found: 4" but only showing three.

    I checked in the file "browse.inc.php" and saw:

    [php]// add "enroll me" link if the user is not the course owner and is not enrolled
    while ($row = mysql_fetch_assoc($courses_result)) {
    if ($_SESSION['member_id'] > 0) {
    $sql = "SELECT * FROM ".TABLE_PREFIX."course_enrollment WHERE member_id=$_SESSION[member_id] AND course_id=".$row['course_id'];
    $result = mysql_query($sql, $db);

    if ($row['access'] == 'private') {
    $enroll_link = '<a href="'.$_base_path.'users/private_enroll.php?course='.$row['course_id'].'">'. _AT('enroll_me').'</a>';
    } else {
    $enroll_link = '<a href="'.$_base_path.'enroll.php?course='.$row['course_id'].'">'. _AT('enroll_me').'</a>';
    }

    if (mysql_num_rows($result) == 0 && $_SESSION['member_id'] <> $row['member_id']) {
    $row['enroll_link'] = $enroll_link;
    } else if ($row['access'] == 'private') {
    [b]$enrollment_row = mysql_fetch_assoc($courses_result);[/b]
    if ($enrollment_row['approved'] == 'n') $row['enroll_link'] = $enroll_link;
    }
    }
    $courses_rows[] = $row;
    }
    [/php]

    This line seems odd:
    $enrollment_row = mysql_fetch_assoc($courses_result);

    I can't find anywhere in the code where "$enrollment_row" is used (except for the following line, and it makes the loop skip the next row whenever it's triggered. Should it be "$result" rather than "$courses_result"?

  • 2010-11-18 14:16:04

    Re: Missing course, or am I missing something?

    Is one of your courses set to hidden? Check course properties.

  • 2010-11-18 14:32:30

    Re: Missing course, or am I missing something?

    Hi Greg,

    There are a couple of things here:

    1. At the top of /browse.php it says "Results Found: 4" and displays 3 rows (this is wrong)

    2. $result is being initialised, but $courses_result is being used in the subsequent line calling "mysql_fetch_assoc", causing the loop to skip one of the courses when it's triggered. If this is correct, then can you explain why it's doing that?

    And no, I don't have a hidden course (I did originally, but changed it before I made my first post here and actually it wasn't the course that was missing).

    Thanks for your reply

  • 2010-11-18 15:09:37

    Re: Missing course, or am I missing something?

    Hi,

    I think the line "$enrollment_row = mysql_fetch_assoc($courses_result);" is correct. It seems like this is used to check if the user has enrolled in the course. If it is, then it manipulates the $row array for the template usage later on.

    To debug further, can you debug($sql) after before lin 85, $courses_result = mysql_query($sql, $db);

    After you got the SQL statement, can you run it in your database and see if you could fetch all four courses.

    thanks.

  • 2010-11-18 15:17:06

    Re: Missing course, or am I missing something?

    Hi Harris,

    I'm not convinced (yet) that it is correct. The SQL is:

    [php]
    SELECT COUNT(course_id) AS cnt FROM AT_courses WHERE access <>-1 AND cat_id <>-1 AND 1 AND hide=0

    SELECT * FROM AT_courses WHERE access <>-1 AND cat_id <>-1 AND 1 AND hide=0 ORDER BY title
    [/php]

    The at_courses table:
    [php]
    INSERT INTO `at_courses` (`course_id`, `member_id`, `cat_id`, `content_packaging`, `access`, `created_date`, `title`, `description`, `course_dir_name`, `notify`, `max_quota`, `max_file_size`, `hide`, `copyright`, `primary_language`, `rss`, `icon`, `home_links`, `main_links`, `side_menu`, `release_date`, `end_date`, `banner`, `home_view`) VALUES
    (1, 4, 3, 'top', 'private', '2010-10-28 16:28:46', 'Health and Safety', 'Test course', '', 1, '-2', '-3', 0, '', 'en', 0, 'books.jpg', 'mods/_standard/tests/my_tests.php|mods/_standard/tracker/my_stats.php|mods/_core/imscp/export.php', 'mods/_standard/faq/index.php|mods/certify/index.php|mods/ch_custom/index.php', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', 1),
    (4, 1, 3, 'top', 'private', '2010-11-17 14:19:56', 'Manual Handling Awareness', 'Awareness of the dangers of handling things', '', 1, '-2', '-3', 0, '(c) Changing Horizon 2010', 'en', 0, 'mail.google.com.jpeg', 'mods/_standard/faq/index.php|mods/_standard/reading_list/index.php|mods/_standard/tests/my_tests.php|mods/_standard/tracker/my_stats.php', 'mods/certify/index.php|mods/job_board/index.php|mods/ch_custom/index.php', 'menu_menu|ch_custom|glossary|search', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', 1),
    (5, 1, 4, 'top', 'private', '2010-11-17 14:53:59', 'Food Safety Course', '', '', 1, '-2', '-3', 0, '', 'en', 0, 'fly-fishing.jpg', 'mods/_standard/faq/index.php|mods/_standard/reading_list/index.php|mods/_standard/tests/my_tests.php|mods/_standard/tracker/my_stats.php', 'mods/certify/index.php|mods/job_board/index.php|mods/ch_custom/index.php', 'menu_menu|ch_custom|glossary|search', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', 1),
    (2, 1, 3, 'top', 'public', '2010-11-02 12:55:39', 'Demo Health And Safety', 'This is a trial version of the Health and Safety Course.', '', 0, '-2', '-3', 0, '', 'en', 0, '', 'mods/_standard/file_storage/index.php|mods/_standard/tests/my_tests.php|mods/_standard/tracker/my_stats.php|mods/_standard/directory/directory.php', 'mods/_standard/forums/forum/list.php|mods/_core/glossary/index.php|mods/_standard/faq/index.php|mods/_standard/reading_list/index.php|mods/_standard/gradebook/my_gradebook.php|mods/_standard/student_tools/index.php|mods/_standard/tile_search/tile.php|mods/_core/groups/groups.php|mods/certify/index.php|mods/job_board/index.php|mods/ch_custom/index.php', 'social|menu_menu|related_topics|users_online|glossary|search|poll|posts', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', 1),
    (3, 1, 3, 'top', 'private', '2010-11-02 15:32:49', 'Test Course', 'test', '', 1, '-2', '-3', 0, '', 'en', 0, '', 'mods/_standard/file_storage/index.php|mods/_standard/directory/directory.php|mods/_standard/tests/my_tests.php|mods/_standard/tracker/my_stats.php', 'mods/_standard/forums/forum/list.php|mods/_core/glossary/index.php|mods/_standard/faq/index.php|mods/_standard/reading_list/index.php|mods/_standard/gradebook/my_gradebook.php|mods/_standard/student_tools/index.php|mods/_standard/tile_search/tile.php|mods/_core/groups/groups.php|mods/certify/index.php|mods/job_board/index.php|mods/ch_custom/index.php', 'social|menu_menu|related_topics|users_online|glossary|search|poll|posts', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', 1);
    [/php]


    As I mentioned earlier - all four (actually five including the now unhidden one) rows are returned for both queries, but because that line makes it skip one then it's not included in the list below.

  • 2010-11-18 15:39:45

    Re: Missing course, or am I missing something?

    This seems a bug. The line should be

    $enrollment_row = mysql_fetch_assoc($result);

    So, use $result instead of $courses_result

    Will file into bug tracker and fix it.

    Thanks for your report.

  • 2010-11-18 15:43:26

    Re: Missing course, or am I missing something?

    Thanks cindy!

    I did think that was the problem (and brought it up in my first post), but thanks for reassuring me. I thought I was going mad, as surely it's been affecting a number of users!

    Thanks everyone for the help.