models.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:research-eGrader 作者: openstax 项目源码 文件源码
def get_next_response(user_id, exercise_id):
    """
    Get a random ungraded response or throw an exception

    Parameters
    ----------
    user_id : int
    exercise_id: int

    Returns
    -------
    response
        The response object from a list of responses

    """
    response = Response.get_random_ungraded_response(user_id, exercise_id,
                                                     active=True)
    grades = ResponseGrade.get_grades(user_id, exercise_id, active=True)
    labels = [int(grade[1]) if grade[1] else grade[1] for grade in grades]
    labels_array = np.array(labels, dtype=float)
    unique, counts = np.unique(labels_array[~np.isnan(labels_array)], return_counts=True)

    stats = dict(zip(unique, counts))
    stats['Total:'] = len(labels)

    log.info(stats)

    if response:
        return response
    else:
        raise ResponsesNotFound()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号