From 9ae5046f6d98f6dc16f2fe81b020a2b514200021 Mon Sep 17 00:00:00 2001 From: baizel Date: Sun, 14 Apr 2019 22:58:20 +0100 Subject: [PATCH] Bug fixes --- Viz/static/js/ClientAnimation.js | 7 ++++++- Viz/utils/QuizEngine.py | 3 ++- Viz/views/views.py | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Viz/static/js/ClientAnimation.js b/Viz/static/js/ClientAnimation.js index bb9c32b..e256e03 100644 --- a/Viz/static/js/ClientAnimation.js +++ b/Viz/static/js/ClientAnimation.js @@ -388,7 +388,12 @@ function graphApiCall(url) { ////////////////////////////////////////////////////// Init //////////////////////////////////////////////////// $(document).ready(function () { - graphApiCall("/api/graph/random"); + const urlParams = new URLSearchParams(window.location.search); + const gId = urlParams.get('graphId'); + if (gId === null) + graphApiCall("/api/graph/random"); + else + graphApiCall("/api/graph/"+gId); $(".pause-btn").hide(); for (i = 0; i < algo["lines"].length; i++) { diff --git a/Viz/utils/QuizEngine.py b/Viz/utils/QuizEngine.py index 3cb56b7..5874f11 100644 --- a/Viz/utils/QuizEngine.py +++ b/Viz/utils/QuizEngine.py @@ -98,8 +98,9 @@ def generateNeighbourQuestions(self): def generateDistanceOfRandomNodeQuestion(self): iteration = random.randint(1, self.__maxNodes - 1) randomNode = random.randint(1, self.__maxNodes) - question = "On the {} iteration of the while Loop in the Dijkstra Algorithm (Line 14-24), whats the distance for node {}?".format(ordinal(iteration), randomNode) + question = "On the {} iteration of the while Loop in the Dijkstra Algorithm @ Line 15, whats the distance for node {}?".format(ordinal(iteration), randomNode) ans = self.__getNodeDistanceAtState(self.__distanceState, iteration)[randomNode] + print(self.__distanceState) options = [str(random.randint(0, 50)) for _ in range(4)] options.append(str(ans)) if str(ans) != self.INF_OPTIONS: diff --git a/Viz/views/views.py b/Viz/views/views.py index 0b9e23a..307208d 100644 --- a/Viz/views/views.py +++ b/Viz/views/views.py @@ -161,6 +161,8 @@ def get_context_data(self, **kwargs): recentAtemptedAns.append({"attemptedAns": a.attempted_answers, "question": i.getSummaryContext()}) except AttemptedQuestion.DoesNotExist: pass + except AttemptedQuestion.MultipleObjectsReturned: + pass data = {"wrong": totalPossibleScore - totalScoreAchieved, "right": totalScoreAchieved, "stats": stats, "quiz": recentAtemptedAns, "timeChartData": timeChartData} data = dict(**data, **exData, **res) return data