Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reload on connect in quizsummarypage; avoid possible error w/ missing… #12554

Open
wants to merge 4 commits into
base: release-v0.17.x
Choose a base branch
from

Conversation

nucleogenesis
Copy link
Member

@nucleogenesis nucleogenesis commented Aug 12, 2024

Summary

Closes #12388

I was only able to replicate the error described there by @AlexVelezLl when I forced specifically a 502 error within the size endpoint's handler. I don't know any way that a 502 would come through unless the server is disconnected somehow during the page load.

I could not replicate it naturally, however, so I cannot be 100% this addresses the issue at hand here.

But, ultimately, what it came down to was that if the page got a 502 error, it would show the proper "disconnected" snackbar & backdrop. In this case, the value used this.quizId was not yet initialized.

The change here ensures that when the user regains connection to the server, their page will reload, hopefully successfully.


One thing of concern is that if there is a way in which we could end up getting some kind of unjustified 502, then this could just result in an infinite loop of failing to connect and reloading.

The only way that I can think of that the size endpoint's handler would cause a 502 is if it's crashing the server. I've made some large quizzes during development on EQM and I've not had any issues with it and trying it didn't help replicate the issue.

Without some kind of stack trace for the error from a naturally occurring replication of the error this will be hard to debug, as there are several calls within that could cause the failure:

    @action(detail=False)
    def size(self, request, **kwargs):
        exams, draft_exams = self.filter_querysets(
            self.get_queryset(), self.get_draft_queryset()
        )
        exams_sizes_set = []
        for exam in list(exams) + list(draft_exams):
            quiz_size = {}

            quiz_nodes = ContentNode.objects.filter(
                id__in=[question["exercise_id"] for question in exam.get_questions()]
            )

            quiz_size[exam.id] = total_file_size(quiz_nodes)
            exams_sizes_set.append(quiz_size)

        return Response(exams_sizes_set)

Also worth noting that my first thought was to force an error within the function there, but that just resulted in the expected 400 Bad request rather than the 502 that is the direct cause of this issue.

Reviewer guidance

Code review

  • Is there any kind of additional handing I should add in the size handler?
  • Any thoughts on how to better replicate this particular issue -- are there any quirks to our disconnection handling that might come into play here?

QA

Path 1: Fake replication

  • With Network Throttling enabled, click to view a Quiz's details (click it's name link on the quiz list page). Throttling will help buy you time to kill your server in the next step :)
  • Then, quickly kill your server kolibri stop, causing the backend to no longer be available
  • Restart the Kolibri server, click to reconnect on the snackbar message in your browser, and the page should reload when you reconnect successfully
  • Now you should be able to delete the quiz without issue

Path 2: Possibly replicate it naturally

  • Maybe try once more with a very large quiz w/ lots of exercises in it that would have a large size
  • Don't do the "kill your server" thing manually and see if you can get it to naturally occur that you get a 502 somehow?

@github-actions github-actions bot added APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: frontend labels Aug 12, 2024
@pcenov
Copy link
Member

pcenov commented Aug 13, 2024

Hi @nucleogenesis, following the directions in 'Path 1: Fake replication' I managed to actually replicate the original issue that is - I can see the quiz details page with "Resource not found on device" shown and I can't delete the quiz after having successfully restarted the server. Only if I manually refresh the entire page, then I can delete it.
So if we consider that a valid testing scenario, then we've not fixed the original issue since from the perspective of a normal user of Kolibri we are still getting in the edge-case scenario where we can't delete the quiz with missing resources for no obvious reason. Here's a video of what I am observing:

2024-08-13_15-25-09.mp4

Logs: logs.zip

… data

I could not replicate the issue described in learningequality#12388 but this seems like
it ought to avoid the possibility altogether as it only seems to occur
when there is a 502 during the page load.
@nucleogenesis nucleogenesis force-pushed the fix--delete-quiz-missing-content branch from 9054f85 to 278cd17 Compare August 26, 2024 20:55
@nucleogenesis
Copy link
Member Author

@pcenov I've updated the PR so that the deletion modal uses the always present quizId value from the URL itself. This ensures that the modal being submitted will always work.

@rtibbles @AlexVelezLl -- I've updated the QuizSummaryPage a bit here. We were duplicating the fetch from the backend to get data we already had available by way of the classSummary store. So the component got the same data two different ways and used them differently.

My changes consolidate them into one exam property derived from classSummary/examMap, then uses the exam utils fetchExamWithContent function to be sure we're getting the content in the right shape. I think that we could probably just derive this from the classSummary/contentNodeMap but I figured I'd get feedback on this first as I think the changes here should sufficiently resolve the issue this PR targets.

@pcenov
Copy link
Member

pcenov commented Sep 4, 2024

Hi @nucleogenesis - I confirm that now it's possible to delete a quiz while the 'Resource not found on device' message is displayed:

delete.mp4

I can also see the missing resources loaded correctly when I manually refresh the page after the successful server restart:

reload.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants