autolab / Autolab

Course management service that enables auto-graded programming assignments.
http://www.autolabproject.com/
Apache License 2.0
769 stars 220 forks source link

Moss Cheat Checker page crashes if there are no assessments in the database #1861

Closed umar221b closed 1 year ago

umar221b commented 1 year ago

Your environment I am using the latest Docker image.

Steps To Reproduce

  1. Create a new Autolab instance or delete all the assessments on your current instance.
  2. Go to "Manage Course" on any course.
  3. Click on "Run Moss cheat checker".

Current behavior Page crashes with a 500 error inside views/courses/moss.html.erb at <div id='<%= a.id %>OptionsDiv' style="margin-right: 10px;" >

Expected behavior Page does not crash.

Screenshots

Screenshot 2023-03-30 at 2 10 50 AM

The reason of the crash is that the variable a is used in a couple of locations outside the loop that defines it. Not quite sure these parts it is used in should be in the loop or the usages should be removed (I believe the latter), but if the usages are not needed we could just remove them from the ids of the divs. Happy to submit a PR that removes the usages of a outside the loop, and maybe displays a message "to add assessments to get started with plagiarism checking"?

Let me know what you think.

damianhxy commented 1 year ago

Hi @umar221b, thanks for bringing this to our attention. Indeed, it appears that the four uses of id='<%= a.id %>OptionsDiv' (including one in the loop) are unnecessary and MOSS works even without them.

If you'd like, feel free to submit a PR removing the mentioned uses of a.id. As for the warning message, I would suggest using materialize's collections to style it and/or linking to the course's install_assessment page (i.e. by linking to install_assessment_course_assessments_path(@course))

I would be happy to assist as well!

umar221b commented 1 year ago

Yes, I will do the fix. Regarding linking to the install_assessment page, are you visualizing something with a list of the courses and links to each one of them? I was thinking about displaying an empty page with a message that the user should add assessments first to access this page. Displaying the list of course links will grow ugly if there are many courses. What do you think?

damianhxy commented 1 year ago

What I had in mind was a clickable link to the install assessment page for the current course (since MOSS is run within the context of a course).

e.g. a message like "There are currently no assessments to run MOSS on, add an assessment to this course to get started" -- where the bolded text will be the link.

umar221b commented 1 year ago

Got it, I will work on something. 👍