/usr/bin/mysql -uroot -prootpw << EOF use moodle23; update mdl_course_sections set sequence=@cmod where course="$id" and section='0' AND sequence=”; EOF
mdl_course_sections, section='0' 中的 sequence,記錄各活動的 id。必須將原活動在 mdl_course_modules 上的 id,重新加入 sequence 中,且清除 mdl_course 中的 cache 欄位 sectioncache=” and modinfo=”,才會生效。
/usr/bin/mysql -uroot -prootpw << EOF use moodle23; update mdl_course set sectioncache=” and modinfo=” where id="$id"; EOF
/usr/bin/mysql -uroot -prootpw << EOF use moodle23; update mdl_course_sections set sequence=@cmod where course="$id" and section='0' AND sequence=”; EOF
/usr/bin/mysql -uroot -prootpw << EOF
use moodle23;
set @att=(select id from mdl_attforblock where course="$id"
and name=%*"預設點名"*) and grade=100);
INSERT INTO mdl_attendance_sessions (attendanceid,sessdate,
duration,timemodified,descriptionformat)
SELECT @att,"${st}","$duration","$timecreated",'1' FROM DUAL
WHERE @att IS NOT NULL AND NOT EXISTS
(SELECT id FROM mdl_attendance_sessions
WHERE attendanceid=@att and sessdate="${st}") LIMIT 1;
EOF
/usr/bin/mysql -uroot -prootpw << EOF use moodle23; set @att=(select id from mdl_attforblock where course="$id" and name=%*"預設點名"*) and grade=100); delete FROM mdl_attendance_sessions WHERE attendanceid=@att and sessdate NOT IN ($atime) AND lasttaken IS NULL; EOF