OpenMOOC / moocng

MOOC Engine
Apache License 2.0
88 stars 43 forks source link

"Enroll me in this Course?" one time and time again #5

Closed versae closed 11 years ago

versae commented 11 years ago

We are experiencing the weirdest issue: we have several courses with almost 100 students each, but suddenly, and we couldn't still identify why, all students enrolled in the course just disappear. I go to the Django administration and I can see the students widget empty. Then, I add one by one by manually (thanks God we have a copy of students' registrations), and then it happens again. It's making us crazy, and it's really annoying for students to have to enrol every time.

So, I was wondering if there is any point in the code in which you remove all students of a course or something. All I found so far is https://github.com/OpenMOOC/moocng/blob/master/moocng/courses/views.py#L72 Is it possible that somehow the browser is doing a POST without noticing and then the user gets un-enrolled?

versae commented 11 years ago

Well, I think I found the reason. It's because this line in teachersadmin: https://github.com/OpenMOOC/moocng/blob/master/moocng/teacheradmin/forms.py#L25 So, because you are not excluding 'students', every time you do a change using that form, all 'students' are removed from that course. Hope this can help.

lorenzogil commented 11 years ago

Thanks Javier for reporting this bug.

I checked the code yesterday but didn't see anything unusual. I didn't look at the Django admin interface since we are finishing the new teacher interface and that's the one we are focusing right now.

We'll try to reproduce the bug but it's kind of weird because in a regular Django changeform, the ManyToMany widget' items are pre selected with the old value. In this case, the students should be selected when the form is rendered. Unless this selecion is done with Javascript and you press the save button before the Javascript gets executed.

2013/1/19 Javier de la Rosa notifications@github.com

Well, I think I found the reason. It's because this line in teachersadmin: https://github.com/OpenMOOC/moocng/blob/master/moocng/teacheradmin/forms.py#L25So, because you are not excluding 'students', every time you do a change using that form, all 'students' are removed from that course. Hope this can help.

— Reply to this email directly or view it on GitHubhttps://github.com/OpenMOOC/moocng/issues/5#issuecomment-12451475.

versae commented 11 years ago

You can reproduce it easily:

  1. Create a course.
  2. Enrol some students.
  3. Go to /teacheradmin/info/ and change any attribute, like the title.

Then check the students for that course and all of them are removed.

I haven't merged yet last changes (badges, etc --because migrations) into my fork, but I think this bug is still there in your master branch. It may be caused by the teacheradmin form you build by hand in the teacheradmin/info.html template, so the field students always goes empty through the POST every time you update course info. But it is easy to fix, just adding students to the exclude list in teacheradmin.forms.CourseForm.Meta

pitbulk commented 11 years ago

Thanks for the report. Fixed in 129143017db9585ad1d39257f2a923a89f2466e7