Drupal 7 Quiz Questions Export with Quiz title, multichoice and answer


 

To get such output, just run the code in your phpmyadmin below:


Select
QUIZ.parent_nid,
EXAM.title,
SU.name AS SUBJECT,
ND.NID,
ND.title,
FVB.Body_value,
GROUP_CONCAT(MCA.answer, ' ; ') AS OPTIONS,
ANS.field_answer_value AS ANSWER
from `node` as ND
Inner join `quiz_multichoice_answers` as MCA
on MCA.Question_NID = ND.NID AND
MCA.question_vid = ND.VID

Inner join `field_revision_body` as FVB
on FVB.entity_ID = ND.NID AND
FVB.revision_id = ND.VID AND
FVB.Entity_type = "Node"

Inner join `field_data_field_subject` AS SUB
on SUB.entity_id = ND.NID AND
SUB.revision_id = ND.VID

Inner join `taxonomy_term_data` AS SU
on SU.tid = SUB.field_subject_tid

Inner join `field_data_field_answer` AS ANS
on ANS.entity_id = ND.NID AND
ANS.revision_id = ND.VID

Inner join `quiz_node_relationship` AS QUIZ
on QUIZ.child_nid = MCA.Question_NID

Inner join `node` AS EXAM
on EXAM.nid = QUIZ.parent_nid

GROUP BY ND.NID
Now with another field attached
SELECT
QUIZ.parent_nid,
EXAM.title,
SU.name AS SUBJECT,
TERM.name,
ND.NID,
ND.title,
FVB.Body_value,
GROUP_CONCAT(MCA.answer, ' ; ') AS OPTIONS,
ANS.field_answer_value AS ANSWER
from `node` as ND
Inner join `quiz_multichoice_answers` as MCA
on MCA.Question_NID = ND.NID AND
MCA.question_vid = ND.VID

Inner join `field_revision_body` as FVB
on FVB.entity_ID = ND.NID AND
FVB.revision_id = ND.VID AND
FVB.Entity_type = "Node"

Inner join `field_data_field_subject` AS SUB
on SUB.entity_id = ND.NID AND
SUB.revision_id = ND.VID

Inner join `taxonomy_term_data` AS SU
on SU.tid = SUB.field_subject_tid

Inner join `field_data_field_answer` AS ANS
on ANS.entity_id = ND.NID AND
ANS.revision_id = ND.VID

Inner join `quiz_node_relationship` AS QUIZ
on QUIZ.child_nid = MCA.Question_NID

Inner join `node` AS EXAM
on EXAM.nid = QUIZ.parent_nid

Inner join `field_data_field_bangladesh` AS BD
on BD.entity_id = ND.NID AND
BD.revision_id = ND.VID

Inner join `taxonomy_term_data` AS TERM
on TERM.tid = BD.field_bangladesh_tid

GROUP BY QUIZ.parent_nid

#Exclude Exam Relation

SELECT SU.name AS SUBJECT, TERM.name, ND.NID, ND.title, FVB.Body_value, GROUP_CONCAT(MCA.answer, ' ; ') AS OPTIONS, ANS.field_answer_value AS ANSWER from `node` as ND Inner join `quiz_multichoice_answers` as MCA on MCA.Question_NID = ND.NID AND MCA.question_vid = ND.VID Inner join `field_revision_body` as FVB on FVB.entity_ID = ND.NID AND FVB.revision_id = ND.VID AND FVB.Entity_type = "Node" Inner join `field_data_field_subject` AS SUB on SUB.entity_id = ND.NID AND SUB.revision_id = ND.VID Inner join `taxonomy_term_data` AS SU on SU.tid = SUB.field_subject_tid Inner join `field_data_field_answer` AS ANS on ANS.entity_id = ND.NID AND ANS.revision_id = ND.VID Inner join `field_data_field_math` AS math on math.entity_id = ND.NID AND math.revision_id = ND.VID Inner join `taxonomy_term_data` AS TERM on TERM.tid = math.field_math_tid GROUP BY ND.nid


SELECT SU.name AS SUBJECT, TERM.name, ND.NID, ND.title, FVB.Body_value, GROUP_CONCAT(MCA.answer, ' ; ') AS OPTIONS, ANS.field_answer_value AS ANSWER from `node` as ND Inner join `quiz_multichoice_answers` as MCA on MCA.Question_NID = ND.NID AND MCA.question_vid = ND.VID Inner join `field_revision_body` as FVB on FVB.entity_ID = ND.NID AND FVB.revision_id = ND.VID AND FVB.Entity_type = "Node" Inner join `field_data_field_subject` AS SUB on SUB.entity_id = ND.NID AND SUB.revision_id = ND.VID Inner join `taxonomy_term_data` AS SU on SU.tid = SUB.field_subject_tid Inner join `field_data_field_answer` AS ANS on ANS.entity_id = ND.NID AND ANS.revision_id = ND.VID Inner join `field_data_field_bangla` AS SC on SC.entity_id = ND.NID AND SC.revision_id = ND.VID Inner join `taxonomy_term_data` AS TERM on TERM.tid = SC.field_bangla_tid GROUP BY ND.nid

Comments

Popular posts from this blog

Enable Theme Debug in Drupal 9

Remove drupal 9 extensions from database

PHP redirect from http to https and www to non-www in Drupal 9