如何在Moodle中获得测验问题的正确答案/答案数量?

时间:2015-01-31 08:54:06

标签: php mysql moodle

我对Moodle完全不熟悉。我一直想知道问答分析的目的。

我怎样才能得到号码。正确答复或错误答复,以及负责这些答案的人员的user_id。是否有任何表格已存储?

2 个答案:

答案 0 :(得分:0)

我有同样的任务,最后我解决了。我发现这些问题在名为mdl_question_attempt_steps的表格中进行了分级,我将其与moodle问题一起加入并按问题分组,并计算了正确和错误的答案。

经过8个多小时的搜索和阅读非常复杂的moodle代码后,这就是查询。

SELECT questionid, 
COUNT( CASE WHEN state =  "gradedright" THEN 1  END ) AS rightanswer,
COUNT( CASE WHEN state =  "gradedwrong" THEN 1  END ) AS wronganswer
FROM  `mdl_question_attempt_steps` 
JOIN mdl_question_attempts ON (  `questionattemptid` = mdl_question_attempts.id ) 
JOIN mdl_question ON (  `questionid` = mdl_question.id ) 
GROUP BY questionid
祝你好运!

答案 1 :(得分:-1)

https://docs.moodle.org/dev/Quiz_database_structurehttps://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine#Detailed_data_about_an_attempt

涵盖了用于测验的数据库表格

这不适合胆小的人,因为第二个链接上提供的示例查询是:

SELECT
    quiza.userid,
    quiza.quiz,
    quiza.id AS quizattemptid,
    quiza.attempt,
    quiza.sumgrades,
    qu.preferredbehaviour,
    qa.slot,
    qa.behaviour,
    qa.questionid,
    qa.maxmark,
    qa.minfraction,
    qa.flagged,
    qas.sequencenumber,
    qas.state,
    qas.fraction,
    timestamptz 'epoch' + qas.timecreated * INTERVAL '1 second',  // OR FROM_UNIXTIME(qas.timecreated) IF you are ON MySQL.
    qas.userid,
    qasd.name,
    qasd.VALUE,
    qa.questionsummary,
    qa.rightanswer,
    qa.responsesummary

FROM mdl_quiz_attempts quiza
JOIN mdl_question_usages qu ON qu.id = quiza.uniqueid
JOIN mdl_question_attempts qa ON qa.questionusageid = qu.id
JOIN mdl_question_attempt_steps qas ON qas.questionattemptid = qa.id
LEFT JOIN mdl_question_attempt_step_data qasd ON qasd.attemptstepid = qas.id

WHERE quiza.id = 675767

ORDER BY quiza.userid, quiza.attempt, qa.slot, qas.sequencenumber, qasd.name