online-judge icon indicating copy to clipboard operation
online-judge copied to clipboard

loading a different page of problems does not persist default "hide solved problems" setting

Open xiaowuc1 opened this issue 6 years ago • 1 comments

Start by setting the Hide solved problems setting to be on.

Reproduction steps:

  1. Open https://dmoj.ca/problems/ and confirm that the setting is checked by default, and that the URL has not mutated to include a hide_solved param.
  2. Go to https://dmoj.ca/problems/?page=2

Expected behavior: The hide solved problems setting is applied, and solved problems do not appear on page 2.

Actual behavior: The hide solved problems setting is not applied, and solved problems do appear on page 2.

There is an easy and known workaround, which is that https://dmoj.ca/problems/?hide_solved=1&page=2 does the right thing, but nonetheless the behavior is nonintuitive and defeats the purpose of saving that as a default.

xiaowuc1 avatar Aug 24 '18 19:08 xiaowuc1

The paginator is created in templates/list-pages.html, and the links are created by using page_prefix and first_page_href. These 2 variables were added to the context here: https://github.com/DMOJ/online-judge/blob/97f2c450e88814012d19cbcfbec3ae74d14415cb/judge/views/problem.py#L426

get_sort_paginate_context does not consider the settings that were saved in the session. (GET_with_session is relevant here)

One approach is to override get_sort_paginate_context. Another approach is to keep get_sort_paginate_context but make it (somehow) know the saved settings.

int-y1 avatar Dec 10 '22 20:12 int-y1