Tuesday, December 17, 2013

Moodle how to bypass sso default login

To bypass a sso default login and just want to use the manual user login, you type


Monday, September 16, 2013

Reset identity on a column of table

To reset the identity value of a table

DBCC CHECKIDENT ('database.tablename', RESEED, 0);

How to view table size

    t.NAME AS TableName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB,
    SUM(a.used_pages) * 8 AS UsedSpaceKB,
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
    sys.tables t
    sys.indexes i ON t.OBJECT_ID = i.object_id
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
    sys.allocation_units a ON p.partition_id = a.container_id
    t.NAME NOT LIKE 'dt%'
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255
    t.Name, p.Rows

Monday, August 19, 2013

Error while installing bb collaborate

When trying to install bbcollaborate, the error is

"An error occurred communicating with the SAS server. Please contact your administrator."

This is happening because there are orphaned recording that has no audio as shown in this FAQ


If you try to delete a recording that has no audio, the error message "An error occurred communicating with the SAS server. Please contact your administrator." appears.

The solution is to check the table mdl_elluminate_recordings and mdl_elluminate_recording_files and troubleshoot from there. 

Wednesday, August 14, 2013

How to fix the book module upgrade error

When upgrading from Moodle 2.2 to 2.4 sometimes it errors out with
Debug info: SELECT id,course FROM
[array (
Error code: invalidrecord
Stack trace:
line 1335 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
line 1311 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 6644 of /lib/accesslib.php: call to moodle_database->get_record()
line 117 of /mod/book/db/upgradelib.php: call to context_module::instance()
line 169 of /mod/book/db/upgrade.php: call to mod_book_migrate_all_areas()
line 627 of /lib/upgradelib.php: call to xmldb_book_upgrade()
line 358 of /lib/upgradelib.php: call to upgrade_plugins_modules()
line 1524 of /lib/upgradelib.php: call to upgrade_plugins()
line 329 of /admin/index.php: call to upgrade_noncore()

To bypass this orphaned error issue, you need to edit the moodle/mod/book/db/upgradelib.php and insert on line 117

$cm = get_coursemodule_from_instance('book', $book->id);
if (empty($cm) || empty($cm->id))
{ continue; }

$context = context_module::instance($cm->id);

This would not fix the orphans, but the upgrade would at least continue properly

Thursday, July 25, 2013

Fix Microsoft SQL missing login name after db copy/move

To fix the missing login name, just execute this

EXEC sp_change_users_login 'UPDATE_ONE','Annie','Annie'

replace Annie with the name of the user

To find out the list of broken / orphaned users, you can execute this

EXEC sp_change_users_login 'REPORT'

On SQL 2005 and above, this is the query to fix

use dbname;
EXEC sp_change_users_login 'Auto_Fix', 'username', null, 'password'

Monday, July 1, 2013

Trace running php script

To see more details on running php script, you can just use
strace -p pid

Wednesday, June 5, 2013

Login using manual user to Moodle with Cas authentication


Change the moodleurlhere with your domain name

Monday, March 4, 2013

Find largest file in moodledata

SELECT DISTINCT filename, filepath, FORMAT( (filesize /1024 /1024), 1 ) AS filesize_MB, contenthash, component
FROM `mdl_files`
ORDER BY filesize DESC
LIMIT 0 , 30