GET request

def GET(self, courseid, taskid, isLTI):
        """ GET request """
        username = self.user_manager.session_username()

        # Fetch the course
        try:
            course = self.course_factory.get_course(courseid)
        except exceptions.CourseNotFoundException as ex:
            raise web.notfound(str(ex))

        if isLTI and not self.user_manager.course_is_user_registered(course):
            self.user_manager.course_register_user(course, force=True)

        if not self.user_manager.course_is_open_to_user(course, username, isLTI):
            return self.template_helper.get_renderer().course_unavailable()

        # Fetch the task
        try:
            tasks = OrderedDict((tid, t) for tid, t in course.get_tasks().items() if self.user_manager.task_is_visible_by_user(t, username, isLTI))
            task = tasks[taskid]
        except exceptions.TaskNotFoundException as ex:
            raise web.notfound(str(ex))

        if not self.user_manager.task_is_visible_by_user(task, username, isLTI):
            return self.template_helper.get_renderer().task_unavailable()

        # Compute previous and next taskid
        keys = list(tasks.keys())
        index = keys.index(taskid)
        previous_taskid = keys[index - 1] if index > 0 else None
        next_taskid = keys[index + 1] if index < len(keys) - 1 else None

        self.user_manager.user_saw_task(username, courseid, taskid)

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

        userinput = web.input()
        if "submissionid" in userinput and "questionid" in userinput:
            # Download a previously submitted file
            submission = self.submission_manager.get_submission(userinput["submissionid"], user_check=not is_staff)
            if submission is None:
                raise web.notfound()
            sinput = self.submission_manager.get_input_from_submission(submission, True)
            if userinput["questionid"] not in sinput:
                raise web.notfound()

            if isinstance(sinput[userinput["questionid"]], dict):
                # File uploaded previously
                mimetypes.init()
                mime_type = mimetypes.guess_type(urllib.request.pathname2url(sinput[userinput["questionid"]]['filename']))
                web.header('Content-Type', mime_type[0])
                return sinput[userinput["questionid"]]['value']
            else:
                # Other file, download it as text
                web.header('Content-Type', 'text/plain')
                return sinput[userinput["questionid"]]
        else:
            # Generate random inputs and save it into db
            random.seed(str(username if username is not None else "") + taskid + courseid + str(
                time.time() if task.regenerate_input_random() else ""))
            random_input_list = [random.random() for i in range(task.get_number_input_random())]

            user_task = self.database.user_tasks.find_one_and_update(
                {
                    "courseid": task.get_course_id(),
                    "taskid": task.get_id(),
                    "username": self.user_manager.session_username()
                },
                {
                    "$set": {"random": random_input_list}
                },
                return_document=ReturnDocument.AFTER
            )

            submissionid = user_task.get('submissionid', None)
            eval_submission = self.database.submissions.find_one({'_id': ObjectId(submissionid)}) if submissionid else None

            students = [self.user_manager.session_username()]
            if task.is_group_task() and not self.user_manager.has_admin_rights_on_course(course, username):
                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()}}})
                if group is not None and len(group["groups"]) > 0:
                    students = group["groups"][0]["students"]
                # we don't care for the other case, as the student won't be able to submit.

            submissions = self.submission_manager.get_user_submissions(task) if self.user_manager.session_logged_in() else []
            user_info = self.database.users.find_one({"username": username})

            # Display the task itself
            return self.template_helper.get_renderer().task(user_info, course, task, submissions,
                                                            students, eval_submission, user_task, previous_taskid, next_taskid, self.webterm_link, random_input_list)