找回密码
 立即注册
收起左侧

一些固定试题内容,如何随机生成不同试题顺序的试卷

3
回复
7518
查看
[复制链接]
累计签到:110 天
连续签到:1 天
来源: 2015-12-10 14:58:57 显示全部楼层 |阅读模式
5Qter豆
exquerandum *dataer::usenumgetexquer(QString str)//获取每道试题信息{    exquerandum *exquer;    exquer = new exquerandum;    ss="SELECT * from question where ID = "+str;    queryS.exec(ss);    queryS.next();    exquer->bed=false;    exquer->bes=queryS.value(9).toInt();//多选标识    exquer->brw=false;    exquer->strsas="";    exquer->straas="";    exquer->color[0]=0;    exquer->color[1]=0;    exquer->color[2]=0;    exquer->color[3]=0;    exquer->color[4]=0;    exquer->color[5]=0;    exquer->color[6]=0;    exquer->bshow=false;    exquer->bmark=false;    exquer->iid=queryS.value(0).toInt();    exquer->iqid=str.toInt();//考试选中题序号    exquer->stra=queryS.value(3).toString();//A选项内容    exquer->strb=queryS.value(4).toString();//B选项内容    exquer->strc=queryS.value(5).toString();    exquer->strd=queryS.value(6).toString();    exquer->stre=queryS.value(18).toString();    exquer->strf=queryS.value(19).toString();    exquer->strquestion=queryS.value(2).toString();    exquer->bsas[0]=exquer->bsas[1]=exquer->bsas[2]=exquer->bsas[3]=exquer->bsas[4]=exquer->bsas[5]=0;//学生作答内容初始化为空    if(queryS.value(14).toInt()==1)//A正确    {        exquer->baas[0]=true;//A正确标识    }    if(queryS.value(15).toBool())//B正确    {        exquer->baas[1]=true;////B正确标识    }    if(queryS.value(16).toBool())    {        exquer->baas[2]=true;    }    if(queryS.value(17).toBool())    {        exquer->baas[3]=true;    }    exquer->straas=queryS.value(22).toString();    return exquer;}



void MainWindow::btnMake1(examrandum *examr)//创建考试题号按钮{
    llayout->addWidget(wdtSBack,0,0,((examr->snum/10)+1),11);//添加试题菜单界面    QToolButton *button[examr->snum];    for(int i=0;i<examr->snum;i++)    {        button[i]=datar->makebtn1(i+1);        buttonGroup->addButton(button[i],i);        llayout->addWidget(button[i],i/10,i-(i/10)*10);        QObject::connect( buttonGroup, SIGNAL(buttonClicked (int)), this, SLOT(btnClicked(int)),Qt::UniqueConnection);    }}
我的试题存在数据库里是
105;108;115;118;119;125;127;128;134;136;139;140;
这样的,目前是按从小到大的顺序生成试题按钮(1-12。。),点击每小题按钮出现每小题内容及答案等,我想让固定试题随机生成(1-12)个小按钮试题,也就是随机出题(1-12对应的题目有变化,不一样),而不是像之前这样生成从1到12的固定试题,该怎么办

最佳答案

查看完整内容

自己参考下别人的 http://blog.chinaunix.net/uid-7769108-id-213764.html
回复

使用道具 举报

累计签到:410 天
连续签到:1 天
2015-12-10 14:58:58 显示全部楼层
回复

使用道具 举报

累计签到:410 天
连续签到:1 天
2015-12-11 08:55:30 显示全部楼层
随机函数你会使用吧

点评

不是很清楚,如果我有一串数stringlist1,比如2 4 7 9 12 23 27 28 29 33 36 39 47 48 52,怎么将其打乱顺序,重新排列后生成另一串数stringlist2,求具体详细一点的代码,本人基础不好,没有代码理解起来比较难  详情 回复 发表于 2015-12-15 15:32
回复

使用道具 举报

累计签到:110 天
连续签到:1 天
2015-12-15 15:32:43 显示全部楼层
a408815041 发表于 2015-12-11 08:55
随机函数你会使用吧

不是很清楚,如果我有一串数stringlist1,比如2 4 7 9 12 23 27 28 29 33 36 39 47 48 52,怎么将其打乱顺序,重新排列后生成另一串数stringlist2,求具体详细一点的代码,本人基础不好,没有代码理解起来比较难
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了