Exemplo n.º 1
0
def get_ask_explain(ask_id, paper_id):
    """
    :param ask_id: 
    :param paper_id: 
    :return: 
    """
    sql = """
    select a.subject a_subject, a.content a_content, a.image_url a_image_url, 
    q.subject q_subject, q.content q_content, q.image_url q_image_url
    from sx2_question_ask a, sx2_question q
    where a.id = %s and a.question_id = q.id
    """ % ask_id
    row = db.ziyuan_slave.fetchone_dict(sql)
    if not row:
        return []
    paper_number = get_paper_number(paper_id)
    out = Struct()
    num = paper_number.get(ask_id) if paper_number else ""
    out.q_num = num.q_num if num else ''
    out.a_num = num.a_num if num else ''
    out.big_subject = parse_subject(
        row.q_subject) if row.q_subject else parse_new_subject(
            row.q_content, row.q_image)
    out.small_subject = parse_subject(
        row.a_subject) if row.a_subject else parse_new_subject(
            row.a_content, row.a_image)
    out.ask_id = ask_id
    return out
Exemplo n.º 2
0
def base_option(options):
    """
    选项基础数据
    :param options:
    :return: 
    """
    if not options:
        return []
    option = []
    for i in options:
        d = Struct()
        d.id = i.id
        d.content = i.content
        d.image = get_absurl(i.image)
        d.is_right = i.is_right
        d.option = i.option
        d.ask_id = i.question_id
        d.link_id = i.link_id
        option.append(d)
    return option
Exemplo n.º 3
0
def check_wrong_info(task_id, stu_ids, question_ids):
    """
    作业错误率以小题为主
    :param task_id: 作业id 
    :param stu_ids: 学生id 
    :param question_ids: 题目id list 
    :return: 
    """
    stu_test = db.tbkt_yuwen.yw_test_detail_new.select(
        "user_id", "text").filter(task_id=task_id,
                                  user_id__in=stu_ids,
                                  status=1)[:]
    total = len(stu_test)
    wrong_ask = []
    for i in stu_test:
        txt = json.loads(i.text)
        for t in txt:
            if t["result"] == 0:
                wrong_ask.append(t["ask_id"])
    result_map = Counter(wrong_ask)
    asks = db.tbkt_yw.yw_question_ask.select(
        "id", "question_id").filter(question_id__in=question_ids)

    q_map = OrderedDict()
    for i in asks:
        q_map.setdefault(i.question_id, []).append(i.id)
    wrong_info = []
    for i, qid in enumerate(q_map, start=1):
        asks = q_map.get(qid)
        for j, ask_id in enumerate(asks, start=1):
            d = Struct()
            d.no = i if len(asks) == 1 else "%s(%s)" % (i, j)
            d.rate = result_map.get(ask_id, 0) / total * 100 if total else 0
            d.ask_id = ask_id
            wrong_info.append(d)
    return wrong_info