Project

General

Profile

Bug #5240

Open course, "Go to course" button and the empty assignment

Added by Yannick Warnier over 7 years ago. Updated over 7 years ago.

Status:
Bug resolved
Priority:
Normal
Category:
-
Target version:
Start date:
23/07/2012
Due date:
% Done:

90%

Estimated time:
Spent time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

There is a problem indirectly caused by the "Go to course" button appearing for Open courses (not public, open).

When a logged in user enters a course with the "Go to course" button but is not subscribed to the course (which should not be authorized anyway as the "open" status only allows users subscribed to the course to enter the course) and he goes to the assignment tool, if he tries to upload a document, the document is never uploaded but no error message appears.

Fix two bugs here:

  1. do not show the "Go to course" button if the course is not completely public
  2. show an error message when uploading an assignment as non-subscribed learner

Associated revisions

Revision 48a3bdbf (diff)
Added by Julio Montoya over 7 years ago

Adding message when course does not belong to the course but wants to add a work see #5240

Revision 6f223278 (diff)
Added by Yannick Warnier over 7 years ago

Fixing condition: Go to course and Subscribe to course buttons can never appear together anyway - refs #5240

Revision bb6de80a (diff)
Added by Yannick Warnier over 7 years ago

Allow subscribe/unsubscribe from course catalog for open (not public) courses - refs #5240

Revision a42958ae (diff)
Added by Yannick Warnier over 7 years ago

Updated course catalog to only show Go to course link if Subscribe link doesn't show - refs #5240

Revision a628f76f (diff)
Added by Yannick Warnier over 7 years ago

Set default allow_user_subscribe to 1 for open courses - refs #5240

Revision caa0e2b5 (diff)
Added by Yannick Warnier over 7 years ago

Links to open courses are now 'Subscribe' links for registered students until they subscribe. Now also possible to subscribe to a course (if authorized) through the course's url + ?action=subscribe&sec_token=... - refs #5240

Revision 237f49d0 (diff)
Added by Yannick Warnier over 7 years ago

Improved course access link builder and used from course catalogue - refs #5240

History

#1

Updated by Julio Montoya over 7 years ago

  • Status changed from Assigned to Needs more info
  • Assignee deleted (Julio Montoya)

1. I think the "Go to course" for "Open - access allowed for users registered on the platform" is fine. If a user is registered he can enter the course. Why not?
2. I agree with that. I will send a fix...

#2

Updated by Julio Montoya over 7 years ago

fix sent for 2.

#3

Updated by Julio Montoya over 7 years ago

  • % Done changed from 0 to 50
#4

Updated by Yannick Warnier over 7 years ago

  • Status changed from Needs more info to Assigned
  • Assignee set to Julio Montoya

Julio A. Montoya wrote:

1. I think the "Go to course" for "Open - access allowed for users registered on the platform" is fine. If a user is registered he can enter the course. Why not?

Because the idea of an "open" course is that you know who is using it (as opposed to public courses where anybody can enter).
As such, instead of being able to "anonymously" use the course, the user should be subscribed to the course in order to get access. For that, he has to say "Subscribe" and the button should say that and have that effect (which can actually be simply copied and pasted from the orange button in the course catalog).

It is important to make the distinction because the idea of an open course is that it is not public, and as such you should be able to see who is using it (and track their results), which you cannot do when the user enters without subscribing.

#5

Updated by Julio Montoya over 7 years ago

  • Status changed from Assigned to Needs more info
  • Assignee changed from Julio Montoya to Yannick Warnier

mmmmmm well, if the course is set to "Open - access allowed for users registered on the platform" why a user that is registered in the platform can't enter to the course?

If you want that change, we need to change the label in order to be more coherent something like this: "Open - access allowed for users registered on the platform (if they subscribe to the course)" and we need to change some code in local.inc.php in order to force users to be registered in the course so it will be like a private course but open for new users ... in other words you want to change how that visibility works ...

#6

Updated by Yannick Warnier over 7 years ago

Haha, no, not at all. I want it to remain a it was.

It was like this:
  • a user could only enter an open course through the catalogue by clicking the "Subscribe" button (which effectively subscribed him to the course)
Now it is like this:
  • a user can enter an open course through the "Go to course" button without registering

This is a clear change in behaviour from what used to be the open course. I know it doesn't give the details in the label of the course visibility, but if a user isn't subscribed to the course when entering, then that generates a series of situations that we haven't planned and that will be awkward.

For example:

  1. there is no way now for the student to actually register to the course
  2. when sending an announcement to the course members, the teacher will not have anybody in his list
  3. when entering the agenda (and if the teacher allowed students to update the agenda), the student will not be able to post
  4. the student will not be considered in the construction of a course group
  5. the student will not be able to see other students subscribed to his course

There are probably more cases like this.

#7

Updated by Yannick Warnier over 7 years ago

Previously, the Subscribe button loaded this URL (taken from the first course found on the free campus' catalogue):

Which loaded this piece of code in auth/courses.php:

// subscribe user to course
if (isset($_GET['subscribe_course'])) {
    $courses_controller->subscribe_user($_GET['subscribe_course'], $_GET['search_term'], $_GET['category_code']);
}

However, this didn't send you to the course directly, which is something that we should do now.

So, to conclude:
  • for anonymous users, everything is great, don't change anything
  • for courses that are not "open", everything is great, don't change anything
  • for the open courses
    • if the (registered) user is already subscribed to the course, show the "Go to course" button (that's great now, don't change)
    • if the (registered) user is not subscribed to the course yet, show the "Subscribe me" button (orange one)

So there's only one case (this last one) in which something should be changed.

#8

Updated by Yannick Warnier over 7 years ago

The code to show the orange "Subscribe" button in the course catalog was:

                    if (!in_array($course['code'], $user_coursecodes)) {
                        if ($course['subscribe'] == SUBSCRIBE_ALLOWED) {
                            echo '<div class="course-link-desc left"><a class="a_button orange medium" href="'. api_get_self().'?action=subscribe_course&amp;sec_token='.$stok.'&amp;subscribe_course='.$course['code'].'&amp;search_term='.$search_term.'&amp;category_code='.$code.'">'.get_lang('Subscribe').'</a></div>';
                        }
                    }

It can technically still be used, I guess.

#9

Updated by Yannick Warnier over 7 years ago

  • Status changed from Needs more info to Assigned

Doing it myself :-)

#10

Updated by Yannick Warnier over 7 years ago

Actually there is definitely still code to do that in the catalogue, but the condition for the "Go to course" button is too large so it never gets there.

Here is a snippet from main/templates/default/auth/courses_categories.php, ~line 171

                    // Go To Course button
                    if (api_is_platform_admin() || (
                            $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD ||
                            ($course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && api_user_is_login()) ||
                            in_array($course['code'], $user_coursecodes && $course['visibility'] != COURSE_VISIBILITY_CLOSED   )
                            )
                        ) {
                        echo ' <a class="btn btn-primary" href="'.  api_get_course_url($course['code']).'">'.get_lang('GoToCourse').'</a>';
                    }

                    // Subscribe button
                    if (!api_is_anonymous()
                            && ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
                            && $course['subscribe'] == SUBSCRIBE_ALLOWED
                            && (!in_array($course['code'], $user_coursecodes) || empty($user_coursecodes))) {
                        echo ' <a class="btn btn-primary" href="'. api_get_self().'?action=subscribe_course&amp;sec_token='.$stok.'&amp;subscribe_course='.$course['code'].'&amp;search_term='.$search_term.'&amp;category_code='.$code.'">'.get_lang('Subscribe').'</a>';
                    }

#11

Updated by Yannick Warnier over 7 years ago

This is a little bit more complex than planned: if a course is open but the "Allow students to subscribe" is false, then we cannot allow the student to subscribe.

I changed the course catalog this way:
  • if
    • the course is open and
    • subscribe_allowed is true
    • and the user is registered but
    • the user is not subscribed to the course,
    • then show a "Subscribe" button
  • in any other case, show the "Go to course" link

Currently it looks like this:

                    $sub_btn = '';
                    if (!api_is_anonymous() // Subscribe button
                            && ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
                            && $course['subscribe'] == SUBSCRIBE_ALLOWED
                            && (!in_array($course['code'], $user_coursecodes) || empty($user_coursecodes))) {
                        $sub_btn = ' <a class="btn btn-primary" href="'. api_get_self().'?action=subscribe_course&amp;sec_token='.$stok.'&amp;subscribe_course='.$course['code'].'&amp;search_term='.$search_term.'&amp;category_code='.$code.'">'.get_lang('Subscribe').'</a>';
                    }
                    // Go To Course button (only if admin, if course public or if student already subscribed)
                    if (empty($sub_btn) && (api_is_platform_admin()
                        || $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
                        || (api_user_is_login() && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
                        || in_array($course['code'], $user_coursecodes && $course['visibility'] != COURSE_VISIBILITY_CLOSED   )
                    )) {
                        echo ' <a class="btn btn-primary" href="'.  api_get_course_url($course['code']).'">'.get_lang('GoToCourse').'</a>';
                    }
                    // Print register button (if any)
                    echo $sub_btn;

Now I'll transfer that to the popular courses

#12

Updated by Yannick Warnier over 7 years ago

  • % Done changed from 50 to 70
There you go. That's 5 commits and a long time to think about everything that might happen around it, but I think that now:
  • it matches the previous behaviour
  • it's easier to get the access link to the course (just call CourseManager::get_access_link_by_user($uid,$cid))
  • it ensures even the popular courses have the correct links

Only thing left: make the course catalog use the get_access_link_by_user() function so we get all the logic in one place.

#13

Updated by Yannick Warnier over 7 years ago

  • Status changed from Assigned to Needs testing
  • Assignee deleted (Yannick Warnier)
  • % Done changed from 70 to 90

Done!

#14

Updated by Yannick Warnier over 7 years ago

  • Status changed from Needs testing to Bug resolved
  • Assignee set to Yannick Warnier

I'm not assuming a lot of people will want to verify this before Monday...

Also available in: Atom PDF