Skip to content

Instantly share code, notes, and snippets.

View mikebuchanon's full-sized avatar

Mike Buchanon mikebuchanon

View GitHub Profile
@mikebuchanon
mikebuchanon / disable_gradebook_override.sql
Created May 13, 2013 21:17
Turn off gradebook override for one user for one assignment in one course.
UPDATE mdl_grade_grades AS mgg
SET overridden=0
FROM mdl_grade_items mgi,
mdl_user mu,
mdl_course mc
WHERE mgi.id=mgg.itemid
AND mu.id=mgg.userid
AND mc.id=mgi.courseid
AND mgg.overridden != 0
AND mc.shortname='mdc03'
@mikebuchanon
mikebuchanon / gist:5782830
Created June 14, 2013 15:40
Find Moodle quiz questions and answer texts that contain the word 'angel'
--find all moodle questions that have the term ANGEL in their text
SELECT t.shortname,
t.quiz_name,
mques.name "question_name",
replace(replace(mques.questiontext,'<','&lt'),'>','&gt') "question_text"
FROM
(SELECT mc.shortname,
mq.name "quiz_name",
regexp_split_to_table(mq.questions,',')::integer "question_id"
FROM mdl_course mc
@mikebuchanon
mikebuchanon / gist:5867967
Created June 26, 2013 14:47
Queries to find and to update all assessments that need to have their warning time updated from 2 minutes to 10 minutes
--find all assessments in courseids that are visible by students and need to have their TimeWarning time updated
select lo2.title [folder_name],lo.TITLE [assessment_name], le.course_id, qcs.TimeLimit, qcs.TimeWarning
from QuestionContainerSettings qcs
join qti_question_containers qqc (nolock) on qqc.settings_id=qcs.ID
join LSN_ENTRIES le (nolock) on qqc.entry_ID=le.ENTRY_ID
join LSN_OBJECTS lo (nolock) on lo.OBJECT_ID=le.OBJECT_ID
join LSN_ENTRIES le2 (nolock) on le2.ENTRY_ID=le.PARENT_ID
join LSN_OBJECTS lo2 (nolock) on lo2.OBJECT_ID=le2.OBJECT_ID
where le.COURSE_ID like 'course_ids%'
and lo.OBJECT_TYPE='assessment'
@mikebuchanon
mikebuchanon / gist:5912160
Created July 2, 2013 19:10
Enable Static File Compression on IIS6
REM Enable Statis File Compression on IIS6 Web Server
REM Requires that adsutil.vbs be installed in c:\inetpub\adminscripts
REM Enable Static File Compression
cscript.exe c:\inetpub\adminscripts\adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
REM Tell server to only use 1G of Space
cscript.exe c:\inetpub\adminscripts\adsutil.vbs set w3svc/filters/compression/parameters/HcDoDiskSpaceLimiting true
cscript.exe c:\inetpub\adminscripts\adsutil.vbs set w3svc/filters/compression/parameters/HcMaxDiskSpaceUsage 1073741824
REM Support got GZIP and DEFLATE for the files with the following extensions
@mikebuchanon
mikebuchanon / sqlvar_example.sql
Created July 4, 2013 15:42
An example of using SQL Variables in ANGEL's SQL Query Manager
-- This script finds a specific user in a specific course
SQLVAR: $COURSE_ID$ = [?Enter a course id]
SQLVAR: $USER_ID$ = [?Enter a user id]
--Execute the script
SELECT * FROM dbo.COURSE_ROSTER WHERE COURSE_ID LIKE $COURSE_ID$ AND USER_ID LIKE $USER_ID$
@mikebuchanon
mikebuchanon / student_lsn_logs_report.sql
Created July 4, 2013 15:55
Another example of using SQL Variables in the ANGEL SQL Query Manager
SQLVAR: $course_id$ = [?Enter the Course ID in question]
SQLVAR: $login_name$ = [?Enter the loginname of the student in question]
SQLVAR: $filter$ = [?Enter a filter %quiz 02%, %02%, etc or % for all]
select ll.course_id, a.loginname, lo.TITLE, lo.OBJECT_TYPE, ll.access_date
from LSN_LOGS ll (nolock)
join LSN_OBJECTS lo (nolock) on lo.OBJECT_ID=ll.OBJECT_ID
join ACCOUNTS a on ll.USER_ID=a.USERNAME
where ll.COURSE_ID = $course_id$
and a.LoginName = $login_name$
and lo.TITLE like $filter$
@mikebuchanon
mikebuchanon / findwhodeletedforumpost.sql
Created July 24, 2013 20:57
Find who deleted a forum post in ANGEL based on course_id
select dl.coursecontext [course_id],
a.LoginName [user_who_deleted_post],
dl.actiondate [date_post_deleted],
a2.loginname [user_who_made_post],
dp.PostDate [date_posted],
dp.Subject [post subject],
dp.Body [post]
from DiscussionLog dl (nolock)
join ACCOUNTS a (nolock) on a.USERNAME=dl.UserId
join DiscussionPost dp (nolock) on dp.PostId=dl.PostId
@mikebuchanon
mikebuchanon / badges-issued.sql
Created July 29, 2013 19:23
Find all badges issued for users in Moodle25
select mb.name as badgename,
mu.username,
to_timestamp(mbi.dateissued) as dateissued
from mdl_badge_issued mbi
join mdl_badge mb on mbi.badgeid=mb.id
join mdl_user mu on mu.id=mbi.userid
order by to_timestamp(mbi.dateissued);
@mikebuchanon
mikebuchanon / example.js
Created August 8, 2013 21:55
Example of how to shove link into Moodle breadcrumbs via HTML/JavaScript...can be used with an 'invisible' HTML block
<script type="text/javascript">// <![CDATA[
var breadcrumb = document.getElementsByClassName('breadcrumb');
var li = document.createElement('li');
var a = document.createElement('a');
var linkText = document.createTextNode("my title text");
var sep = document.createElement('span');
var septext = document.createTextNode("/");
sep.appendChild(septext);
sep.className = "divider";
@mikebuchanon
mikebuchanon / gist:7945431
Created December 13, 2013 14:53
Find ANGEL courses with deleted forum posts based on semester
SELECT c.COURSE_ID,
lo2.TITLE [folder], lo.TITLE [forum_name],
dp.AuthorDisplayName,
dp.Subject,
CASE
WHEN dp.PostLevel = 0 THEN 'Post'
ELSE 'Reply'
END [post_type]
FROM DiscussionPost dp (nolock)
JOIN DiscussionForum df (nolock) ON df.ForumId=dp.ForumId