update lect set ,sdate =#sdate#,edate=#edate# where lectno=#lectno# and status = 1 update lect set ,status=#status#,oktime=case when oktime is null and #status# = 4 and status<>4 then now() else oktime end where lectno=#lectno# and status in (3,4,5); update pay a inner join lect b on b.lectno=#lectno# and b.payno=a.payno and b.status in (4,5) set a.pstatus=case when b.status = 4 then 21 else 52 end where a.pstatus=51; update payitem a inner join lect b on b.lectno=#lectno# and b.pino=a.pino and b.status in (4,5) set a.pstatus=case when b.status=4 then 21 else 52 end where a.pstatus=51 update lect set ,status=#status#,oktime=case when oktime is null and #status# = 4 and status=6 then now() else oktime end where lectno=#lectno# and status in (4,5,6); update pay a inner join lect b on b.lectno=#lectno# and b.payno=a.payno and b.status in (4,5) set a.pstatus=case when b.status = 4 then 21 else 52 end where a.pstatus=55; update payitem a inner join lect b on b.lectno=#lectno# and b.pino=a.pino and b.status in (4,5) set a.pstatus=case when b.status=4 then 21 else 52 end where a.pstatus=55 update lect set ,status = #status# ,oktime = now() where lectno in ($lectnos$) and status in (4,5,6); update pay a inner join lect b on b.lectno in ($lectnos$) and b.payno=a.payno and b.status in (4,5,6) set a.pstatus=case when b.status = 6 then 55 when b.status = 4 then 21 else 52 end where a.pstatus in (55, 21, 52); update payitem a inner join lect b on b.lectno in ($lectnos$) and b.pino=a.pino and b.status in (4,5,6) set a.pstatus=case when b.status = 6 then 55 when b.status = 4 then 21 else 52 end where a.pstatus in (55, 21, 52) update lect set ,ischanged=1 where lectno=#lectno#; insert into lect (cmno,payno,pino,userno,status,iscomplete,orgcmno,attrate,isrebate,ispc,isjoin,fgno,ischanged,) select #cmno#,payno,pino,userno,status,null,cmno,0,isrebate,ispc,isjoin,fgno,0, from lect a where a.lectno=#lectno# insert into scdlectlog (userno,scdno,dday,dtime,istalk,isemail,issms,isuse,) select #uno#,scdno,dday,dtime,istalk,isemail,issms,isuse, from scdlect; update scdlect a inner join ( select #Ds[].scdno# scdno,#Ds[].dday# dday,#Ds[].dtime# dtime,#Ds[].istalk# istalk,#Ds[].isemail# isemail,#Ds[].issms# issms,#Ds[].isuse# isuse ) b on b.scdno=a.scdno set a.dday=b.dday,a.dtime=b.dtime,a.istalk=b.istalk,a.isemail=b.isemail,a.issms=b.issms,a.isuse=b.isuse,a.udt=,a.uno=#uno#,a.uip=#uip#; insert into scdlect (scdno,dday,dtime,istalk,isemail,issms,isuse,) select a.scdno,a.dday,a.dtime,a.istalk,a.isemail,a.issms,a.isuse, from ( select #Ds[].scdno# scdno,#Ds[].dday# dday,#Ds[].dtime# dtime,#Ds[].istalk# istalk,#Ds[].isemail# isemail,#Ds[].issms# issms,#Ds[].isuse# isuse ) a left outer join scdlect b on b.scdno=a.scdno where b.scdno is null select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.cmno cmexno,b.cname,null stime ,null etime,null studyplace,null days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) mobile from scdlect a inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0 inner join lect c on c.cmno=b.cmno and c.attrate < 80 and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') inner join users d on d.userno=c.userno and d.status=1 where a.scdno < 3 and a.isuse=1 and a.dtime=#dtime# union all select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.cmno cmexno,b.cname,null stime ,null etime,null studyplace,null days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) mobile from scdlect a inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0 inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') inner join users d on d.userno=c.userno and d.status=1 inner join cmex e on e.cmno=c.cmno and e.extype=case when a.scdno=3 then 0 else 1 end and e.isdel=0 left outer join lectex f on f.lectno=c.lectno and f.exno=e.exno where a.scdno > 2 and a.scdno < 5 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null union all select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.cmno cmexno,b.cname,null stime ,null etime,null studyplace,null days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) mobile from scdlect a inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0 inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') inner join users d on d.userno=c.userno and d.status=1 inner join cmsd e on e.cmno=c.cmno and e.sdtype=0 and e.isdel=0 left outer join lectsd f on f.lectno=c.lectno and f.sdno=e.sdno where a.scdno=5 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null union all select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.cmno cmexno,b.cname,null stime ,null etime,null studyplace,null days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) mobile from scdlect a inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0 inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') inner join users d on d.userno=c.userno and d.status=1 inner join cmsd e on e.cmno=c.cmno and e.sdtype=1 and e.isdel=0 left outer join lectsd f on f.lectno=c.lectno and f.sdno=e.sdno where a.scdno=6 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null union all select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.cmno cmexno,b.cname,null stime ,null etime,null studyplace,null days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char) email,CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) mobile from scdlect a inner join cm b on b.ismaster=0 and b.cshape in (0,1,2) and b.isuse=1 and b.isdel=0 inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.edate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') inner join users d on d.userno=c.userno and d.status=1 inner join cmrs e on e.cmno=c.cmno and e.rstype=0 and e.isdel=0 left outer join lectrs f on f.lectno=c.lectno and f.rsno=e.rsno where a.scdno=7 and a.isuse=1 and a.dtime=#dtime# and f.lectno is null union all select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.cmno cmexno,b.cname,c.sdate stime ,c.edate etime,e.cname studyplace,b.studytime days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char),CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) from scdlect a inner join cm b on b.ismaster=0 and b.cshape =1 and b.isuse=1 and b.isdel=0 inner join lect c on c.cmno=b.cmno and c.status=1 and c.ischanged=0 and date_format(c.sdate,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') inner join users d on d.userno=c.userno and d.status=1 left outer join comcode e on e.ccode = b.studyplace where a.scdno=8 and a.isuse=1 and a.dtime=#dtime# union all select a.scdno,a.dday,a.istalk,a.isemail,a.issms ,d.userno,d.username ,b.exno cmexno,b.exname cname,b.estime stime ,null etime,null studyplace,null days ,CAST(AES_DECRYPT(UNHEX(d.email), ) AS char),CAST(AES_DECRYPT(UNHEX(d.mobile), ) AS char) from scdlect a inner join exam b on date_format(b.estime,'%Y%m%d')=date_format(date_add(now(), interval a.dday day), '%Y%m%d') and b.isopen=1 inner join examuser c on c.exno=b.exno and c.status=1 and c.pstatus=1 inner join users d on d.userno=c.userno and d.status=1 where a.scdno=9 and a.isuse=1 and a.dtime=#dtime# insert into lectexrelog(lectno,exno,estart,eend,eip,) select a.lectno lectno,a.exno exno,a.estart estart,a.eend eend,a.eip eip, from lectex a where a.lectno=#lectno# and a.exno=#exno#; update lectex set estart=null,eend=null,eip=null,tpoint=0,recount=recount+1,entercount=0,cblock=0,isbyadmin=0 where lectno=#lectno# and exno=#exno#; update lectexq a inner join cmex b on b.exno=a.exno set a.atext=null,a.qinos=null,a.cpoint=0,a.iscorrect=null where a.lectno=#lectno# and a.exno=#exno#; update lect a inner join lectex le on a.lectno = le.lectno inner join cmex ce on a.cmno = ce.cmno and ce.isdel = 0 inner join cmev cv on a.cmno = cv.cmno set a.udt=,a.uno=#uno#,a.uip=#uip# ,a.fpoint = 0 ,a.exfpoint = null where ce.extype = 1 and a.lectno=#lectno# and le.exno = #exno#; update lect a inner join lectex le on a.lectno = le.lectno inner join cmex ce on a.cmno = ce.cmno and ce.isdel = 0 inner join cmev cv on a.cmno = cv.cmno set a.udt=,a.uno=#uno#,a.uip=#uip# ,a.mpoint = 0 ,a.exmpoint = null where ce.extype = 0 and a.lectno=#lectno# and le.exno = #exno#; update cmexlayer set qcount=#qcount# where exno=#exno# and qdiff=#qdiff#; lectno not in ( select le.lectno from lectexq le inner join lect l on le.lectno = l.lectno inner join users u on l.userno = u.userno where le.exno = #exno# group by le.lectno, u.userid ) delete from lectexq where lectno=#lectno# and exno=#exno# and eqno in ( select a.eqno from ( select b.eqno from cmex a inner join lectexq b on b.lectno=#lectno# and b.exno=a.exno where a.exno=#exno# and a.eqtype=1 ) a ); insert into lectexq (lectno,exno,eqno,cpoint,dpoint,qseq,) select a.lectno,a.exno,a.eqno,0,a.rpoint,row_number() over(order by case when a.israndq=0 then a.qseq else rand() end), from ( select a.* from ( select a.lectno,a.exno,d.eqno,c.israndq,el.qcount,d.rpoint,d.qseq,rank() over(partition by el.qdiff,el.cc1,el.cc2,el.cc3,el.cc4,el.cc5 order by rand()) rank from (select #lectno# lectno, #exno# exno) a left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno inner join cmex c on c.exno=a.exno and c.eqtype=1 inner join cmexlayer el on el.exno=c.exno and el.qcount > 0 inner join cmexq d on d.exno=el.exno inner join question e on e.qno=d.qno and e.qdiff=case when el.qdiff=0 then e.qdiff else el.qdiff end and e.cc1=case when el.cc1=0 then e.cc1 else el.cc1 end and e.cc2=case when el.cc2=0 then e.cc2 else el.cc2 end and e.cc3=case when el.cc3=0 then e.cc3 else el.cc3 end and e.cc4=case when el.cc4=0 then e.cc4 else el.cc4 end and e.cc5=case when el.cc5=0 then e.cc5 else el.cc5 end ) a where a.rank <= a.qcount ) a order by rand() insert into lectexq (lectno,exno,eqno,cpoint,dpoint,qseq,) select a.lectno,a.exno,d.eqno,0,d.rpoint,row_number() over(order by case when c.israndq=0 then d.qseq else rand() * d.qseq end), from (select #lectno# lectno, #exno# exno) a inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno# left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno inner join cmex c on c.exno=a.exno and c.eqtype=0 inner join cmexq d on d.exno=c.exno inner join ( select count(b.lectno) exq from (select 1 col1) a left outer join lectexq b on b.lectno=#lectno# and b.exno=#exno# ) z on z.exq < 1 where b.lectno is null order by rand(); insert into lectexq (lectno,exno,eqno,cpoint,dpoint,qseq,) select a.lectno,a.exno,a.eqno,0,a.rpoint,row_number() over(order by case when a.israndq=0 then a.qseq else rand() end), from ( select a.lectno,a.exno,d.eqno,d.rpoint,el.qcount,c.israndq,d.qseq,rank() over(partition by el.qdiff, el.cc1, el.cc2, el.cc3, el.cc4, el.cc5 order by rand()) rank from (select #lectno# lectno, #exno# exno) a inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno# left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno inner join cmex c on c.exno=a.exno and c.eqtype=1 inner join cmexlayer el on el.exno=c.exno and el.qcount > 0 inner join cmexq d on d.exno=el.exno inner join question e on e.qno=d.qno and e.qdiff=case when el.qdiff=0 then e.qdiff else el.qdiff end and e.cc1=case when el.cc1=0 then e.cc1 else el.cc1 end and e.cc2=case when el.cc2=0 then e.cc2 else el.cc2 end and e.cc3=case when el.cc3=0 then e.cc3 else el.cc3 end and e.cc4=case when el.cc4=0 then e.cc4 else el.cc4 end and e.cc5=case when el.cc5=0 then e.cc5 else el.cc5 end where b.lectno is null ) a inner join ( select count(b.lectno) exq from (select 1 col1) a left outer join lectexq b on b.lectno=#lectno# and b.exno=#exno# ) z on z.exq < 1 where a.rank <= a.qcount order by rand(); insert into lectex (lectno,exno,tpoint,recount,cblock,) select a.lectno,a.exno,0,0,0, from (select #lectno# lectno, #exno# exno) a inner join lect a2 on a2.lectno=a.lectno and a2.userno=#userno# left outer join lectex b on b.lectno=a.lectno and b.exno=a.exno where b.lectno is null; update lectexq set ,rechecktime= ,cpoint=#cpoint# ,iscorrect = #iscorrect# where lectno=#lectno# and exno=#exno# and eqno=#eqno#; update lectex a inner join ( select lectno, sum(cpoint) tpoint from lectexq where lectno=#lectno# and exno=#exno# group by lectno ) b on b.lectno=a.lectno set a.udt=,a.uno=#uno#,a.uip=#uip# ,a.tpoint=b.tpoint ,a.rechecktime= where a.lectno=#lectno# and a.exno=#exno#; update lect l inner join ( select l.lectno, round(avg(le.tpoint),1) as avgtpoint, sum(le.tpoint) sumpoint, ce.tpoint from lect l inner join cmex ce on l.cmno = ce.cmno and ce.extype = #extype# and ce.isdel = 0 left outer join lectex le on l.lectno = le.lectno and ce.exno = le.exno where l.status = 1 and l.lectno = #lectno# group by l.lectno )t on l.lectno = t.lectno inner join cmev cv on l.cmno = cv.cmno set l.exfpoint = t.avgtpoint , l.fpoint = round((t.avgtpoint / t.tpoint * 100) * cv.final / 100,1) , l.udt = now() , l.uno = #uno# , l.uip=#uip# where l.lectno = #lectno#; update lectsd set ,iscopy=#iscopy#,cpoint=#cpoint# ,feedb=#feedb# ,memo=#memo# ,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end ,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end ,fgno=#fgno# where lectno=#lectno# and sdno=#sdno#; insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,memo,submittime,submitip,checktime,checkip,) select #lectno#,#sdno#,null,#fgno#,null,#iscopy#,#cpoint#,#feedb#,#memo#,null,null ,case when #cpoint# is not null or #feedb# is not null then now() else null end ,case when #cpoint# is not null or #feedb# is not null then #uip# else null end , from (select 1 col1) a left outer join lectsd b on b.lectno=#lectno# and b.sdno=#sdno# where b.lectno is null update lectsd set ,iscopy=#iscopy#,cpoint=#cpoint# ,feedb=#feedb# ,memo=#memo# ,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end ,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end ,submittime=case when #zstring0# = 'T' then now() else submittime end ,submitip=case when #zstring0# = 'T' then #uip# else submitip end ,fgno=#fgno# where lectno=#lectno# and sdno=#sdno#; insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,memo,submittime,submitip,checktime,checkip,) select #lectno#,#sdno#,null,#fgno#,null,#iscopy#,#cpoint#,#feedb#,#memo# ,case when #zstring0# = 'T' then now() else null end ,case when #zstring0# = 'T' then #uip# else null end ,case when #cpoint# is not null or #feedb# is not null then now() else null end ,case when #cpoint# is not null or #feedb# is not null then #uip# else null end , from (select 1 col1) a left outer join lectsd b on b.lectno=#lectno# and b.sdno=#sdno# where b.lectno is null; update lect l inner join ( select l.lectno, round(avg(ifnull(ls.cpoint,0)),1) as avgtpoint, round(((round(avg(ifnull(ls.cpoint,0)),1) * ce.subject / 100) ),1) spoint from lect l inner join cmsd cs on l.cmno = cs.cmno and cs.sdtype = 0 and cs.isdel = 0 left outer join lectsd ls on l.lectno = ls.lectno and cs.sdno = ls.sdno and ls.sdno=#sdno# inner join cmev ce on l.cmno = ce.cmno where l.status = 1 and l.lectno = #lectno# group by l.lectno )t on l.lectno = t.lectno set l.spoint = t.spoint , l.subjectpoint = t.avgtpoint , l.udt = now() , l.uno = #uno# , l.uip=#uip# where l.status = 1 and l.lectno = #lectno#; update lect l inner join ( select l.lectno, round(avg(ifnull(ls.cpoint,0)),1) as avgtpoint, round(((round(avg(ifnull(ls.cpoint,0)),1) * ce.discuss / 100)),1) dpoint from lect l inner join cmsd cs on l.cmno = cs.cmno and cs.sdtype = 1 and cs.isdel = 0 left outer join lectsd ls on l.lectno = ls.lectno and cs.sdno = ls.sdno and ls.sdno=#sdno# inner join cmev ce on l.cmno = ce.cmno where l.status = 1 and l.lectno = #lectno# group by l.lectno )t on l.lectno = t.lectno set l.dpoint = t.dpoint , l.discusspoint = t.avgtpoint , l.udt = now() , l.uno = #uno# , l.uip=#uip# where l.status = 1 and l.lectno = #lectno#; update lectsd set ,iscopy=#iscopy#,cpoint=#cpoint#,feedb=#feedb# ,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end ,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end where lectno in ($lectnos$) and sdno=#sdno#; insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,submittime,submitip,checktime,checkip,) select a.lectno,#sdno#,null,null,null,#iscopy#,#cpoint#,#feedb#,null,null ,case when #cpoint# is not null or #feedb# is not null then now() else null end ,case when #cpoint# is not null or #feedb# is not null then #uip# else null end , from lect a left outer join lectsd b on b.lectno=a.lectno and b.sdno=#sdno# where a.lectno in ($lectnos$) and a.status=1 and a.ischanged=0 and b.lectno is null update lectsd set ,cpoint=#cpoint#,feedb=#feedb# ,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end ,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end where lectno=#lectno# and sdno=#sdno#; insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,submittime,submitip,checktime,checkip,) select #lectno#,#sdno#,null,null,null,0,#cpoint#,#feedb#,null,null ,case when #cpoint# is not null or #feedb# is not null then now() else null end ,case when #cpoint# is not null or #feedb# is not null then #uip# else null end , from (select 1 col1) a left outer join lectsd b on b.lectno=#lectno# and b.sdno=#sdno# where b.lectno is null update lectsd set ,cpoint=#cpoint#,feedb=#feedb# ,checktime=case when #cpoint# is not null or #feedb# is not null then now() else checktime end ,checkip=case when #cpoint# is not null or #feedb# is not null then #uip# else checkip end where lectno in ($lectnos$) and sdno=#sdno#; insert into lectsd (lectno,sdno,atext,fgno,copyrate,iscopy,cpoint,feedb,submittime,submitip,checktime,checkip,) select a.lectno,#sdno#,null,null,null,0,#cpoint#,#feedb#,null,null ,case when #cpoint# is not null or #feedb# is not null then checktime else null end ,case when #cpoint# is not null or #feedb# is not null then #uip# else null end , from lect a left outer join lectsd b on b.lectno=a.lectno and b.sdno=#sdno# where a.lectno in ($lectnos$) and a.status=1 and a.ischanged=0 and b.lectno is null insert into edub2b (etype,userno,edate,esubject,etarget,ecount,eplace,ecomment,compname,ceoname,brno,addr,btype,bkind,manname,email,telno,fgno,) values (#etype#,#userno#,#edate#,#esubject#,#etarget#,#ecount#,#eplace#,#ecomment#,#compname#,#ceoname#,#brno#,#addr#,#btype#,#bkind#,#manname#,HEX(AES_ENCRYPT(#email#, )),HEX(AES_ENCRYPT(#telno#, )),#fgno#,) update alarms set isdel=1 where alno=#alno# and userno=#userno# update lect set ,completetime=#completetime# where lectno=#lectno# and iscomplete=1; update pay a inner join lect b on b.payno = a.payno and b.cmno = #cmno# and b.ischanged=0 and ifnull(b.isready,0) = 1 and b.status = 4 and DATE_ADD(b.oktime, INTERVAL 2 DAY) < set a.pstatus = 52, a.udt = now(), a.uno = #uno#, a.uip = #uip#; update payitem a inner join pay b on b.payno = a.payno and b.pstatus = 52 inner join lect c on c.payno = b.payno and c.cmno = #cmno# and c.ischanged=0 and ifnull(c.isready,0) = 1 and c.status = 4 and DATE_ADD(c.oktime, INTERVAL 2 DAY) < set a.pstatus = b.pstatus, a.udt = now(), a.uno = #uno#, a.uip = #uip#; update lect set status = 5, oktime = now(), udt = now(), uno = #uno#, uip = #uip# where cmno = #cmno# and ifnull(isready,0) = 1 and ischanged=0 and status = 4 and DATE_ADD(oktime, INTERVAL 2 DAY) < update lect set isattcheck = 1, lakey = #lakey#, latime = now() where lectno = #lectno# update lectinning a inner join lect b on b.lectno=a.lectno and b.userno=#userno# set a.isattcheck = #isattcheck#,a.udt=now(),a.uno=#uno#,a.uip=#uip# where a.lectno=#lectno# and a.cmino=#cmino#; insert into lectinning (lectno,cmino,totstudy,stime,etime,istatus,finishtime,sip,eip,ispcs,ispce,pseq,psec,isattcheck,) select #lectno#,a.cmino,0,now(),now(),case when a.atime=0 then 2 else 0 end,case when a.atime=0 then now() else null end,#uip#,#uip#,1,null,ctp.pseq,0,#isattcheck#, from cminning a inner join ctpage ctp on ctp.ctno=a.ctno and ctp.isdel=0 and ctp.pseq=1 left outer join lectinning b on b.lectno=#lectno# and b.cmino=#cmino# where a.cmino=#cmino# and b.lectno is null; update lect set cmisno = #cmisno# where lectno = #lectno#; update pplog a left outer join ( select a.lectno,a.payno,b.pplno,a.cmisno from lect a inner join pay b on b.payno = a.payno where a.lectno = #lectno# ) b on b.pplno = a.pplno set a.cmisno = b.cmisno where b.lectno = #lectno#; update lect a left outer join cminningscd b on b.cmisno = a.cmisno left outer join cm c on a.cmno = c.cmno set a.edate = (case when b.eend is not null then date_format(b.eend,'%Y-%m-%d 23:59:59') else a.edate end) ,a.sdate = (case when b.estart is not null then date_format(b.estart,'%Y-%m-%d 00:00:00') else a.sdate end) where a.lectno = #lectno# and c.cshape = 1; update lect a left outer join cminningscd b on b.cmisno = a.cmisno left outer join cm c on a.cmno = c.cmno set a.edate = case when b.eend is not null then date_format(b.eend,'%Y-%m-%d 23:59:59') else a.edate end where a.lectno = #lectno# and c.cshape <> 1; update lectsd set ,submittime=null ,submitip=null ,fgno=null where lectno=#lectno# and sdno=#sdno#; update lectex set ,tpoint=#tpoint# ,isbyadmin=1 where lectno=#lectno# and exno=#exno#; update lect l inner join ( select l.lectno, round(avg(le.tpoint),1) as avgtpoint, sum(le.tpoint) sumpoint, ce.tpoint from lect l inner join cmex ce on l.cmno = ce.cmno and ce.extype = 1 and ce.isdel = 0 left outer join lectex le on l.lectno = le.lectno and ce.exno = le.exno where l.status = 1 and l.lectno = #lectno# group by l.lectno )t on l.lectno = t.lectno inner join cmev cv on l.cmno = cv.cmno set l.exfpoint = t.avgtpoint , l.fpoint = round((t.avgtpoint / t.tpoint * 100) * cv.final / 100,1) , l.udt = now() , l.uno = #uno# , l.uip=#uip# where l.lectno = #lectno#;