Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. DROP PROCEDURE IF EXISTS `sp_content_results_b`;;
  2. CREATE DEFINER=`clofquist`@`localhost` PROCEDURE `sp_content_results_b`(iqmnum int)
  3. BEGIN
  4.  
  5. select contentID, section_name, ordernum, content_text,fileId, orientation,`show`, googleId, group_concat(slide_number) slidenum
  6.  
  7. from (
  8. SELECT distinct ioc.id contentID, ios.section_name, ios.ordernum, ioc.content_text, ioc.fileId, ios.orientation, ios.`show`, googleId,
  9. cl.slide_number,
  10. group_concat(Uanswers.q_value_id) userAnswers,group_concat(cl.question_value_id) requiredAnswers -- group_concat(concat(cl.question_value_id,cl.group_type))
  11.  
  12. -- select *
  13. from
  14.  
  15.  
  16. (select * from iqm_output_content where statusId=1) ioc
  17. join (select * from iqm_output_section where statusId=1 and typeId=30) ios on ioc.section_id=ios.id
  18.  
  19.  
  20.  
  21.  
  22. left join (select cl1.content_id,question_value_id,content_logic_id,'' group_type,cl1.slide_number
  23.  
  24. from iqm_question_values_content iqvc
  25. join iqm_content_logic cl1 on cl1.id=iqvc.content_logic_id
  26. where cl1.parent_id is null
  27.  
  28. union select cl2.content_id,question_value_id,content_logic_id,cl2.group_type,cl2.slide_number
  29. from iqm_question_values_content iqvc
  30. join iqm_content_logic cl2 on cl2.id=iqvc.content_logic_id
  31. join iqm_content_logic cl1 on cl1.id=cl2.parent_id
  32. where cl1.parent_id is null
  33.  
  34. union select cl3.content_id,question_value_id,content_logic_id,cl3.group_type,cl3.slide_number
  35. from iqm_question_values_content iqvc
  36. join iqm_content_logic cl3 on cl3.id=iqvc.content_logic_id
  37. join iqm_content_logic cl2 on cl2.id=cl3.parent_id
  38. join iqm_content_logic cl1 on cl1.id=cl2.parent_id
  39.  
  40. where cl1.parent_id is null
  41. order by content_id,slide_number,group_type,question_value_id) cl on cl.content_id=ioc.id -- =iqvc.question_value_id -- cl.slide_number=Uanswers.slide_number
  42. --
  43.  
  44. left join (select distinct iqv.id q_value_id -- iqvc.slide_number, iqvc.question_value_id
  45.  
  46. -- select *, locate(iqv.value, A.answer )
  47. from iqm_questions Q
  48. join (SELECT iqmid,questionid, answer,replace(concat('''',answer,''''),', ',''',''') answers
  49. FROM iqm_answers WHERE iqm_answers.iqmid = iqmnum) A on A.questionid=Q.id
  50.  
  51. join iqm_question_values iqv on A.questionid=iqv.question_id -- and iqv.value=A.answer
  52. -- join iqm_question_values_content iqvc on iqv.id=iqvc.question_value_id
  53. -- WHERE A.iqmid = 1444
  54. where locate(iqv.value, A.answer )>0) Uanswers on cl.question_value_id=Uanswers.q_value_id
  55. -- gonogo='go' and
  56.  
  57.  
  58. group by ioc.id, ios.section_name, ios.ordernum, ioc.content_text, ioc.fileId, ios.orientation, ios.`show`, googleId,cl.slide_number
  59.  
  60. having userAnswers=requiredAnswers
  61.  
  62. order by googleId,slide_number) MatchedSlides
  63.  
  64. group by contentID, section_name, ordernum, content_text,fileId, orientation,`show`, googleId
  65. order by ordernum;
  66.  
  67. END;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement