// update all the current quiz results for the score/maxscore etc
  protected void upgradeV54() {
    DbHelper db = DbHelper.getInstance(ctx);
    ArrayList<QuizAttempt> quizAttempts = db.getAllQuizAttempts();
    long userId = db.getUserId(SessionManager.getUsername(ctx));

    ArrayList<Course> courses = db.getAllCourses();
    ArrayList<v54UpgradeQuizObj> quizzes = new ArrayList<>();

    for (Course c : courses) {
      try {
        CourseXMLReader cxr = new CourseXMLReader(c.getCourseXMLLocation(), c.getCourseId(), ctx);

        ArrayList<Activity> baseActs = cxr.getBaselineActivities();
        for (Activity a : baseActs) {
          if (a.getActType().equalsIgnoreCase("quiz")) {
            String quizContent = a.getContents("en");
            try {
              JSONObject quizJson = new JSONObject(quizContent);
              v54UpgradeQuizObj q = new v54UpgradeQuizObj();
              q.id = quizJson.getInt("id");
              q.digest = quizJson.getJSONObject("props").getString("digest");
              q.threshold = quizJson.getJSONObject("props").getInt("passthreshold");
              quizzes.add(q);
            } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }

        // now add the standard activities
        ArrayList<Activity> acts = cxr.getActivities(c.getCourseId());
        for (Activity a : acts) {
          if (a.getActType().equalsIgnoreCase("quiz")) {
            String quizContent = a.getContents("en");
            try {
              JSONObject quizJson = new JSONObject(quizContent);
              v54UpgradeQuizObj q = new v54UpgradeQuizObj();
              q.id = quizJson.getInt("id");
              q.digest = quizJson.getJSONObject("props").getString("digest");
              q.threshold = quizJson.getJSONObject("props").getInt("passthreshold");
              quizzes.add(q);
            } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      } catch (InvalidXMLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    for (QuizAttempt qa : quizAttempts) {
      // data back to json obj
      try {
        JSONObject jsonData = new JSONObject(qa.getData());
        qa.setMaxscore((float) jsonData.getDouble("maxscore"));
        qa.setScore((float) jsonData.getDouble("score"));

        int quizId = jsonData.getInt("quiz_id");

        v54UpgradeQuizObj currentQuiz = null;

        // find the relevant quiz in quizzes
        for (v54UpgradeQuizObj tmpQuiz : quizzes) {
          if (tmpQuiz.id == quizId) {
            currentQuiz = tmpQuiz;
            break;
          }
        }

        if (currentQuiz == null) {
          Log.d(TAG, "not found");
        } else {
          Log.d(TAG, "Found");
          qa.setActivityDigest(currentQuiz.digest);
          if (qa.getScoreAsPercent() >= currentQuiz.threshold) {
            qa.setPassed(true);
          } else {
            qa.setPassed(false);
          }
        }

        // make the actual updates
        qa.setUserId(userId);
        db.updateQuizAttempt(qa);

      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    ArrayList<QuizAttempt> checkQuizAttempts = db.getAllQuizAttempts();
    for (QuizAttempt qa : checkQuizAttempts) {
      // display current data
      Log.d(TAG, "data: " + qa.getData());
      Log.d(TAG, "digest: " + qa.getActivityDigest());
      Log.d(TAG, "userid: " + qa.getUserId());
      Log.d(TAG, "courseid: " + qa.getCourseId());
      Log.d(TAG, "score: " + qa.getScore());
      Log.d(TAG, "maxscore: " + qa.getMaxscore());
      Log.d(TAG, "passed: " + qa.isPassed());
    }
  }