dodona-edu / dodona

🧑‍💻 Learn to code for secondary and higher education
https://dodona.be
MIT License
67 stars 22 forks source link

exercise URLs without trailing slash cause spinner of death #309

Closed bmesuere closed 5 years ago

bmesuere commented 5 years ago

If an exercise URL has no trailing slash, the submissions tab doesn't get updated correctly after submitting. This is because the url for fetching the submissions is based on the page URL.

(On such page, the images also won't load #4)

All links generated by the application contain a trailing slash, but a user (or browser) can of course accidentally remove it.

Original issue by @bmesuere on Fri Nov 04 2016 at 16:55. Closed by @bmesuere on Sun Nov 06 2016 at 12:24.

bmesuere commented 5 years ago

proposed fix:

Add this to the application controller:

private
  def ensure_trailing_slash
    redirect_to url_for(params.merge(:trailing_slash => true)), :status => 301 unless trailing_slash?
  end

  def trailing_slash?
    request.env['REQUEST_URI'].match(/[^\?]+/).to_s.last == '/'
  end
end

and add it as a before filter in the show action of the exercises controller:

before_filter :ensure_trailing_slash, :only => :show

@ninewise does this seem an ok solution?

Original comment by @bmesuere on Fri Nov 04 2016 at 16:58.

ninewise commented 5 years ago

Seems strange such a long workaround is required, but I can't think of anything shorter.

Original comment by @ninewise on Sat Nov 05 2016 at 10:21.

pdawyndt commented 5 years ago

@bmesuere Will this one be deployed before the evalution sessions of Bart Dhoedt? This seems like an import improvement, and may be the reason why many students had the feeling that Dodona was slow/unresponsive.

Original comment by @pdawyndt on Sun Nov 06 2016 at 13:08.

bmesuere commented 5 years ago

It already is...

Original comment by @bmesuere on Sun Nov 06 2016 at 14:27.