Пример #1
0
 def page(self, course, username, task):
     """ Get all data and display the page """
     data = list(get_database().submissions.find({"username": username, "courseid": course.get_id(), "taskid": task.get_id()}).sort([("submitted_on", pymongo.DESCENDING)]))
     data = [dict(f.items() + [("url", self.submission_url_generator(course, str(f["_id"])))]) for f in data]
     if "csv" in web.input():
         return make_csv(data)
     return renderer.course_admin.student_task(course, username, task, data)
Пример #2
0
 def page(self, course, task):
     """ Get all data and display the page """
     data = list(get_database().user_tasks.find({"courseid": course.get_id(), "taskid": task.get_id(), "username": {"$in": course.get_registered_users()}}))
     data = [dict(f.items() + [("url", self.submission_url_generator(course, task, f))]) for f in data]
     if "csv" in web.input():
         return make_csv(data)
     return renderer.course_admin.task_info(course, task, data)
Пример #3
0
 def page(self, course):
     """ Get all data and display the page """
     data = UserData.get_course_data_for_users(course.get_id(), course.get_registered_users())
     data = [dict(f.items() + [("url", self.submission_url_generator(course, username)), ("username", username)]) for username, f in data.iteritems()]
     if "csv" in web.input():
         return make_csv(data)
     return renderer.course_admin.student_list(course, data)
Пример #4
0
    def page(self, course):
        """ Get all data and display the page """
        data = list(get_database().user_tasks.aggregate(
            [
                {
                    "$match":
                        {
                            "courseid": course.get_id(),
                            "username": {"$in": course.get_registered_users()}
                        }
                },
                {
                    "$group":
                        {
                            "_id": "$taskid",
                            "viewed": {"$sum": 1},
                            "attempted": {"$sum": {"$cond": [{"$ne": ["$tried", 0]}, 1, 0]}},
                            "attempts": {"$sum": "$tried"},
                            "succeeded": {"$sum": {"$cond": ["$succeeded", 1, 0]}}
                        }
                }
            ]))

        # Load tasks and verify exceptions
        files = get_readable_tasks(course.get_id())
        output = {}
        errors = []
        for task in files:
            try:
                output[task] = course.get_task(task)
            except Exception as inst:
                errors.append({"taskid": task, "error": str(inst)})
        tasks = OrderedDict(sorted(output.items(), key=lambda t: t[1].get_order()))

        # Now load additionnal informations
        result = OrderedDict()
        for taskid in tasks:
            result[taskid] = {"name": tasks[taskid].get_name(), "viewed": 0, "attempted": 0, "attempts": 0, "succeeded": 0,
                              "url": self.submission_url_generator(course, taskid)}
        for entry in data:
            if entry["_id"] in result:
                result[entry["_id"]]["viewed"] = entry["viewed"]
                result[entry["_id"]]["attempted"] = entry["attempted"]
                result[entry["_id"]]["attempts"] = entry["attempts"]
                result[entry["_id"]]["succeeded"] = entry["succeeded"]
        if "csv" in web.input():
            return make_csv(result)
        return renderer.course_admin.task_list(course, result, errors)
Пример #5
0
    def page(self, course, error="", post=False):
        """ Get all data and display the page """
        groups = []
        if course.is_group_course():
            groups = get_database().groups.find({"course_id": course.get_id()})
        groups = sorted(groups, key=lambda item: item["description"])

        groups.insert(0, {"_id": 0, "users": course.get_staff(), "description": "Course staff", "tutors": {}})

        user_data = UserData.get_course_data_for_users(course.get_id(), course.get_registered_users())
        for user in user_data.keys():
            user_data[user]["url"] = self.submission_url_generator(course, user)

        users_csv = [dict(f.items() + [("username", username)]) for username, f in user_data.iteritems()]

        if "csv" in web.input():
            return make_csv(users_csv)

        return renderer.course_admin.student_list(course, user_data, groups, error, post)
Пример #6
0
 def page(self, course, username):
     """ Get all data and display the page """
     data = list(get_database().user_tasks.find({"username": username, "courseid": course.get_id()}))
     tasks = course.get_tasks()
     result = OrderedDict()
     for taskid in tasks:
         result[taskid] = {"name": tasks[taskid].get_name(), "submissions": 0, "status": "notviewed", "url": self.submission_url_generator(course, username, taskid)}
     for taskdata in data:
         if taskdata["taskid"] in result:
             result[taskdata["taskid"]]["submissions"] = taskdata["tried"]
             if taskdata["tried"] == 0:
                 result[taskdata["taskid"]]["status"] = "notattempted"
             elif taskdata["succeeded"]:
                 result[taskdata["taskid"]]["status"] = "succeeded"
             else:
                 result[taskdata["taskid"]]["status"] = "failed"
             result[taskdata["taskid"]]["grade"] = taskdata["grade"]
     if "csv" in web.input():
         return make_csv(result)
     return renderer.course_admin.student(course, username, result)
Пример #7
0
    def page(self, course, task):
        """ Get all data and display the page """

        groups = []
        if course.is_group_course():
            groups = get_database().groups.find({"course_id": course.get_id()})
        groups = sorted(groups, key=lambda item: item["description"])

        groups.insert(0, {"_id": 0, "users": course.get_staff(), "description": "Course staff", "tutors": {}})

        results = list(get_database().user_tasks.find({"courseid": course.get_id(), "taskid": task.get_id(),
                                                  "username": {"$in": course.get_registered_users()}}))
        data = {}
        for user in results:
            user["url"] = self.submission_url_generator(course, task, user)
            data[user["username"]] = user

        user_csv = [dict(data[key].items()) for key in data.keys()]
        if "csv" in web.input():
            return make_csv(user_csv)

        return renderer.course_admin.task_info(course, task, data, groups)