Set submission whose id is `submissionid` to selected grading submission for the given course/task.
            Returns a boolean indicating whether the operation was successful or not.

def set_selected_submission(self, course, task, submissionid):
        """ Set submission whose id is `submissionid` to selected grading submission for the given course/task.
            Returns a boolean indicating whether the operation was successful or not.
        """

        submission = self.submission_manager.get_submission(submissionid)

        # Do not continue if submission does not exist or is not owned by current user
        if not submission:
            return False

        # Check if the submission if from this task/course!
        if submission["taskid"] != task.get_id() or submission["courseid"] != course.get_id():
            return False

        is_staff = self.user_manager.has_staff_rights_on_course(course, self.user_manager.session_username())

        # Do not enable submission selection after deadline
        if not task.get_accessible_time().is_open() and not is_staff:
            return False

        # Only allow to set submission if the student must choose their best submission themselves
        if task.get_evaluate() != 'student' and not is_staff:
            return False

        # Check if task is done per group/team
        if task.is_group_task() and not is_staff:
            group = self.database.aggregations.find_one(
                {"courseid": task.get_course_id(), "groups.students": self.user_manager.session_username()},
                {"groups": {"$elemMatch": {"students": self.user_manager.session_username()}}})
            students = group["groups"][0]["students"]
        else:
            students = [self.user_manager.session_username()]

        # Check if group/team is the same
        if students == submission["username"]:
            self.database.user_tasks.update_many(
                {"courseid": task.get_course_id(), "taskid": task.get_id(), "username": {"$in": students}},
                {"$set": {"submissionid": submission['_id'],
                          "grade": submission['grade'],
                          "succeeded": submission["result"] == "success"}})
            return True
        else:
            return False