如何从总问题中找到错误的答案 [英] how to find wrong answer out of total question

查看:64
本文介绍了如何从总问题中找到错误的答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子:



 1.  ChapterQuest 列(Id(int),QuestionId (int),Question(varchar(max),OptionA(varchar(100)),
OptionB(varchar(100)),OptionC(varchar(100)),Answer(varchar(10),Ismultiple(bit)) )

2. ChapterQuestAnswer 列(Id(int),ChapterQuestionID(int),OptionSelect(varchar(10))

数据在ChapterQuest中:

Id QuestionId问题OptionA OptionB OptionC答案Ismultiple
1 1测试T1 T2 T3 A,B True

2 2 Test1 TT1 TT2 TT3 A,C True

3 3测试2 TTT1 TTT2 TTT3 A错误

ChapterQuestAnswer中的数据是:

Id ChapterQuestionId OptionSelect
1 1 A,B

2 2 C,A

3 3 B



我如何尝试,错误答案,未尝试





Plz给出解决问题的逻辑..

提前谢谢

解决方案





如果你的答案字段和option中插入了值,并且在答案和评分之间没有任何空格,这将为你提供所需的结果用逗号。



正确答案



从ChapterQuestAnswer中选择*加入ChapterQuest q on t.questionid = q.chapterquestionid和t.answer = q.optionselect



错误答案

从ChapterQuestAnswer中选择*加入关于t.questionid = q.chapterquestionid和t.answer<>的ChapterQuest q q.optionselect



或者你可以查看questionid(未尝试)在你的章节中没有这样的话



选择*形式ChapterQuest其中QuestionId不在(从ChapterQuestAnswer选择不同的ChapterQuestionId)



问候,

Mubin

I have two tables:

1.ChapterQuest columns(Id(int),QuestionId(int),Question(varchar(max),OptionA(varchar(100)),
OptionB(varchar(100)),OptionC(varchar(100)),Answer(varchar(10),Ismultiple(bit))

2.ChapterQuestAnswer columns(Id(int),ChapterQuestionID(int),OptionSelect(varchar(10))

Data In ChapterQuest is:

Id  QuestionId  Question  OptionA  OptionB  OptionC  Answer  Ismultiple
1     1         Test       T1       T2        T3       A,B     True

2     2         Test1      TT1      TT2       TT3       A,C       True

3     3         Test2      TTT1      TTT2       TTT3       A       FALSE

Data in ChapterQuestAnswer is:

Id  ChapterQuestionId  OptionSelect
1         1                A,B

2         2                C,A

3         3                 B


How i get Attempted,Wrong Answer,UnAttempted


Plz give some logic for solve my problem ..
Thanks in advance

解决方案

Hi ,

This will give you your desired result if values inserted in your answer field and optionselect without any space in between the answer and sperated by comma.

For Right answer

select * from ChapterQuestAnswer t join ChapterQuest q on t.questionid= q.chapterquestionid and t.answer=q.optionselect

For Wrong Answer
select * from ChapterQuestAnswer t join ChapterQuest q on t.questionid= q.chapterquestionid and t.answer <> q.optionselect

or you can view questionid( not attempted) not there in your chapteranswer like this

select * form ChapterQuest where QuestionId not in ( select distinct ChapterQuestionId from ChapterQuestAnswer )

Regards,
Mubin


这篇关于如何从总问题中找到错误的答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆