Archive

Archive for the ‘SLK’ Category

SharePoint Learning Kit 1.4 Released

January 11th, 2010 Richard 2 comments

I’ve finally released SLK 1.4 to Beta. Sorry about the delay, but in the end I’ve rewritten the drop box functionality to hopefully work seamlessly within SharePoint. To do this I knew I needed to make changes to how the drop box library was created which would be incompatible and so decided to hold back on officially releasing it.

You can download from the release page on CodePlex.

It is not backwards compatible with the version uploaded to the patches folder, so any documents returned by that will not be available via this version. The documents will still be present though.

The major changes compared to the version in the patches folder are:

  1. Students can open office documents and save them straight back to SharePoint without having to save to disk first.
  2. Teachers can open and comment on office documents without having to save to disk first.
  3. The drop box library is created as required. You do not have to enable the SLK feature on the site to create it.
  4. Although folders are still used as containers to hold student’s work (as the document names are likely to be the same), they are not used to navigate the assignments. You either use the default view which is grouped by assignment or use assignment specific views which are created when an assignment is created.
  5. You can use the drop box in a locale which doesn’t use US style dates.
  6. I’ve currently removed the download all and upload all files options for teachers so that I can get the release out. I just haven’t had time to complete this.
  7. I’ve removed Course Manager from the install. This will again be available as a separate release. The reason is that the quality is still not there for it to be bundled.

I will consider this version to be in beta until 24 Jan at the latest. At which point there will be another beta version with at a minimum the download all and upload all functionality in, or a final release. Please download and report any bugs, which I will attempt to resolve quickly. I am keen to get 1.4 RTM so we can move on to the next version and get the project moving again.

Note, I still need to update the documentation to cover this release, this may take some time. If anyone would like to volunteer to do this it would be really helpful. I’m also considering moving it to the wiki pages on CodePlex rather than just having the getting started pdf as it will be easier to maintain and distribute. Does anyone have any thoughts on this?

Categories: SLK Tags: ,

SharePoint bug in SPWeb.AllRolesForCurrentUser

June 29th, 2009 Richard 2 comments

I’ve finally tracked down the bug in SPWeb.AllRolesForCurrentUser. This has been mysteriously failing for some users in some set ups when using the SharePoint Learning Kit as discussed on the CodePlex forums.

When this happened to a customer, I was able to debug it and found out the problem. I can now re-produce it at will and it’s definitely a bug in SharePoint.

The problem occurs when the user is a member of a large number of SharePoint groups. To retrieve all the roles, SharePoint makes a call to the database. In normal circumstances this call is along the lines of

SELECT DISTINCT ra.RoleId FROM RoleAssignment AS ra
WHERE ra.ScopeId = '67FD4879-2097-4B98-9771-5A6E9D11F0E9' AND ra.PrincipalId IN (3,1 )

where 3 and 1 are the IDs of the groups and the guid (67FD4879-2097-4B98-9771-5A6E9D11F0E9) is the ID of the site. This call is retrieving all the role assignments on this site for all the groups that the user is a member of.

Now when the user is a member of a large number of groups the SQL generated is:

SELECT DISTINCT ra.RoleId FROM RoleAssignment AS ra
WHERE ra.ScopeId = '67FD4879-2097-4B98-9771-5A6E9D11F0E9' AND ra.PrincipalId
IN (SELECT DISTINCT ra.RoleId FROM RoleAssignment AS ra WHERE ra.ScopeId = '67FD4879-2097-4B98-9771-5A6E9D11F0E9' AND ra.PrincipalId IN (839,1840,1841,.......,2611,2612,1 ) 

The …….. is where I’ve removed about 740 group IDs.

I’m not sure what’s happening here in the SQL generation, but the "SELECT .. FROM .. WHERE .. IN(" bit is repeated twice leading to invalid SQL. Apart from being a nonsense statement there are 2 opening braces and only 1 closing brace. The code is obviously getting confused by so many groups. My initial thought was that it allocated a buffer for the string generation, but it wasn’t big enough, but that doesn’t explain the 2 sets of SELECT … .

This is easy to reproduce. All you need to do is create a large number of groups with the current user in, and then call AllRolesForCurrentUser, not forgetting to delete them all afterwards or you’ll quickly clutter up your server. I found 800 is enough to make it fail for me, different environment may need more. A sample test class is shown at then end.

In normal use, no user is going to be a member of this many groups – for a start membership of this many is going to need to be automated. However, the best use of SLK requires a site per class and in a reasonably sized Secondary school, this can easily be over 1000 members. Then it’s generally only the administrator who is affected if his account has been used to create the sites, and only if you have a group per site for membership purposes.

I don’t normally create groups for class sites anyway. The maintenance screens for groups are just not very user friendly – you have to manually page through the lists to find a group – and it makes the year roll-over a pain. My preference is to give the users explicit permissions on the class sites rather than through groups, something I’ve discussed before.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Microsoft.SharePoint; 

namespace SharePointTest
{
  public class AllRolesTest
  {
    public static void Main()
    {
      //Url to a SharePoint site. Any site but don't do it on a live server. 
      string url = "http://salamanderdemo/sites/mis";
      //The username of the user you are running as. I could have programmatically found this out, but it
      //wouldn't have added anything to the example 
      string userName = "DEMO\\Administrator"; 

      try
      {
        using (SPSite site = new SPSite(url))
        {
          using (SPWeb web = site.OpenWeb())
          {
            SPUser user = web.SiteUsers[userName]; 

            // This call should succeed 
            SPRoleDefinitionBindingCollection allRoles = web.AllRolesForCurrentUser;
            Console.WriteLine("First AllRolesForCurrentUser worked."); 

            List<string> names = new List<string>();
            try
            {
              //Create all the groups 
              for (int i = 0; i < 800; i++)
              {
                if (i%100 == 0)
                {
                  Console.WriteLine("Added {0} groups.", i);
                }
                string name = Guid.NewGuid().ToString();
                names.Add(name);
                web.SiteGroups.Add(name, user, user, name);
              } 

              try
              {
                // This call should fail 
                allRoles = web.AllRolesForCurrentUser;
                Console.WriteLine("AllRolesForCurrentUser succeeded, try adding more groups.");
              }
              catch (SPException e)
              {
                Console.WriteLine("AllRolesForCurrentUser failed.");
                Console.WriteLine(e.Message);
              }
            }
            finally
            {
              int i=0;
              foreach (string name in names)
              {
                if (i%100 == 0)
                {
                  Console.WriteLine("Deleted {0} groups.", i);
                }
                i++;
                web.SiteGroups.Remove(name);
              }
            }
          }
        }
      }
      catch (Exception e)
      {
        Console.WriteLine(e);
      }
    }
  }
}

Categories: SLK Tags:

SharePoint Learning Kit : Limit Assignments Shown to This Year’s Assignments

June 15th, 2009 Richard No comments

By default the SLK Assignment List Web Part shows all assignments ever associated with a learner or instructor. Now that schools are starting to get to the point where they will have been using it for more than one academic year, they do not want the previous year’s assignments showing.

Fortunately there is a built in way in SLK to handle this. The items shown in the web part are completely configurable and are described in the SlkSettings.xml file associated with a site collection.

As an example let’s view the web part for a test instructor.

slkDateBefore

As you can see he has 8 active assignments. Now we decide that we want to only display assignments which have a start date greater than 01 June 2009.

So first of all we download the SlkSettings.xml through the "Configure SharePoint Learning Kit" page in central administration, change it and then upload it again (click for a larger view).

configureSlk

The change you need to make is to add the following line to the ActiveInstructor query.

<Condition ViewColumnName="AssignmentStartDate" Operator="GreaterThan" Value="2009-06-01" />

The image shows where it should go (click for a larger view).

slkDateSettings

What this does is add a new condition to the query so that it only brings back assignments whose start date is greater than the Value. You need to use the start date rather than the due date because I haven’t found a way to bring back assignments with due dates greater than the value, and ones without a due date. If I add a condition for due date in, none of the assignments without a due date are returned. As the start date is a mandatory field this is not a problem.

Once you’ve made the change and uploaded the new settings file back up, this is what the web part looks like.

slkDateAfter

As you can see the four assignments whose start date were less than 02 June 2009 are not returned. They are still present in the other queries though as so far we have only altered the active query for instructors. To complete the job you will need to add the condition to all the queries for instructors, learners and observers.

Finally, if you would like to display assignments outside of those dates somewhere in your portal, you can have different instances of the web part display different queries by defining custom query sets in the settings file. I’ll leave that until another time if there’s a demand for it though.

Categories: SLK Tags:

Hiding Disabled Users in Active Directory Groups on the SLK Assignment Properties Page

May 29th, 2009 RichardWillis No comments

I’ve just finished updating SLK for a UK school who had problems with learners disabled in Active Directory showing when they were assigning work through SLK. Firstly, I must say that this is a solution for a particular problem that they had and isn’t really a general purpose solution. If a learner is disabled, you should really be displaying them so you can assign then work. They may only be disabled temporarily, e.g. as puishment for computer misuse, but will still need to do the work when they are re-enabled.

The situation this school was in, is that they are running the Sims Learning Gateway (SLG). Part of how that works is that there is a component to create AD users and class groups based on the data in Sims. However, the users created by SLG are then ‘consolidated’ with the ‘real’ AD users, so these can then use the Sims web parts. As part of the consolidation process, the SLG users are disabled and the real users are added to the class groups, however the disabled SLG users are not removed from the AD groups.

Now the school were using these AD groups to assign SLK Learner permisssion to in order to assign work. So when the teachers came to assign work and selected their class group, each pupil was represented twice in the list which was a bit confusing.

The solution was to update the SLK code so that there is now a setting to hide disabled users. This will mean that when SLK goes to get the list of all Learners on a site it will ignore users in Active Directory groups who are disabled.

To get this set up you will first of all need to download and upgrade to the version with the setting in on the 1.3.2 build page . Then set the setting by:

  1. Go to the Configure SharePoint Learning Kit page in SharePoint Central Administration.
  2. Make sure that the correct site collection is selected and then click ‘Click here to download the current SLK Settings file’ near the bottom of the page.
  3. This will open up the SlkSettings.xml file in a new browser window. Save this to disk.
  4. Open the saved file in a text editor e.g. notepad (do not use Word or similar)
  5. Add the attribute HideDisabledUsers=”true” to the file as indicated in the screen-shot

6.  Then upload the modified SlkSettings.xml file by adding it the page to “New SlkSettings  file:” and clicking OK.

This will work for schools using Sims Learning Gateway with the same issues, but I wouldn’t necessarily recommend it for anyone else. My personal preference is to give the individual users the appropriate permissions on the class sites rather than using groups. Groups will always cause issues when it comes to rollover and I just think it’s cleaner and more intuitive to have the direct permissions. I would also have removed the disabled users from the groups. Of course I’ve got the toolset to do all of this easily.

Categories: SLG, SLK, Sims Tags:

Getting SPControls.DateTimeControl to display the local date format

May 29th, 2009 RichardWillis No comments

One of the minor problems with SLK was that on the Assignment Properties page the Start and Due dates were always being shown in US format, no matter what the regional setting were. There was a really simple fix, you just need to set the LocaleId of the DateTimeControl and then it will display the date in the regional format of the site.

                spDateTimeStart.LocaleId = SPWeb.Locale.LCID;
                spDateTimeDue.LocaleId = SPWeb.Locale.LCID;

A version with this fix in is now available on the 1.3.2 build page.

Categories: Development, SLK Tags:

How is e-Learning Content sent to the user in SLK

May 28th, 2009 RichardWillis No comments

When an e-Learning package is accessed for the first time, SLK will cache the package on the web front end file system. Caching consists of unpacking the zip file and storing it on the file system. Subsequent requests will use the cached package, as long as they are not outside the cache expiration period. This will speed up subsequent showings of the package. Large packages are going to have a delay the first time someone accesses them after a cache expiration as they are unpacked.

Once the package is read from the cache then SLK will read the manifest to determine the navigation of the content and generate the table of contents for the frameset. Once this is generated the frameset is shown to the user who can then use the table of contents to navigate around the content depending on the sequencing rules of the package.

How the content is then sent to the user depends on how the content has been written. Typically each navigation node will be a separate item in the zip file, which will be downloaded when the user navigates to it. This will lead to a slight delay every time the user navigates between activities, the length of which will depend on the size of that activity and the network connection between the browser and SharePoint – just like any other web content being downloaded. I can also imagine that there are some packages which initially download all the content of all the activities. This will lead to longer start up times again depending on the size of the content, but quicker navigation within the package.

Cache Settings

The default cache settings are to use a cache on the individual SharePoint server and to keep it for 3 days. After this it will be removed. In a server farm this means that each web front-end server will maintain it’s own cache, leading to several initial requests as the load balancing passes requests to different servers. The cache location can be set in the SlkSettings file allowing the farm servers to share a cache. This should allow more hits on the cache and hence less unpacking.

Cache settings are set in the SlkSettings file and hence are on a per site collection basis, allowing you to have different settings for different site collections. The 2 settings are PackageCacheExpirationMinutes and PackageCacheLocation.

Categories: SLK Tags:

First thoughts on Course Manager code

March 30th, 2009 RichardWillis 4 comments

Now I’ve updated Course Manager to reference SLK 1.3.1, had a dig around the code and fixed some issues reported by the community it’s time to discuss my first thoughts on it.

Firstly this is about the Course Manger source code and not its functionality. Andrew Woodward has done a great review of that on his blog.

First thing to realize is that Course Manager is basically 3 web parts:

  1. Course Manager Pages : 2 links to pages with the other web parts on
  2. Plan & Assign : Where you create the courses and assign them to students
  3. Monitor & Assess : Where you grade the assignments

To implement these Course Manager consists of 5 dlls. Yes that’s right, 5 dlls for 3 web parts, 1 of which is just 2 html links with no business logic in it. Looking closer the 5 dlls are

  1. Axelerate.DataAccessApplicationBlock.dll
  2. Axelerate.BusinessLayerFrameWork.dll
  3. Axelerate.BusinessLayerUITools.dll
  4. Axelerate.SharedBusinessLogic.dll
  5. Axelerate.SlkCourseManagerLogicalLayer.dll

Looking at the code only the last one, SlkCourseManagerLogicalLayer actually contains any SLK/Course Manager functionality, the rest are all plumbing. In fact the first 2 projects are written in VB.net while the rest are in C#. It’s fairly obvious that the first 4 components are are supposed to be a generic framework, which has been used to build the course manager and contains a lot of code which isn’t used by Course Manager – more on this later. Digging deeper on the framework and googling Axelerate leads to aXelerate Solutions, who Microsoft must have commissioned to create the Course Manager. My guess is, and it is a guess as the Course Manager code is way before my time as project co-ordinator, is that aXelerate created Course Manager the way they create all their applications, using their custom framework. Whether or not they realized that they were going to have to release the framework code as open source is another matter. I suspect not as that sort of thing tends to be considered a commercial advantage and secret. Fact is Course Manager is unusable without it, and couldn’t be considered open source without it. Trawling around I have found out that the framework has itself been released as open source at http://www.codeplex.com/AxelerateLibraries with a press release (dated 15 Oct 2007 but released 30 Oct 2008) and an overview.

Now the point of a good framework is that it should enable you to add more functionality easily and maintain it. I’m actually finding that it’s getting in the way and causing more work. For example I’ve spent several hours figuring out why Course Manager just wasn’t working and giving the informative error “No data found”. I eventually tracked it down to mismatched versions of AzMan. The first problem with that is that the error handling was atrocious, it threw away the original error and just displayed a generic error, which it displays if any of the data access had failed. There was no way of finding out what the problem was without modifying the code to not catch the error, this is not maintainable is anything but a development environment. Secondly, as far as I can make out AzMan is not even used in the Course Manager web parts. AzMan is a role-based access control framework from Microsoft which uses an MMC snap-in to manage security. Course Manager just relies on the SharePoint security model, so the AzMan access checking, which is embedded all through the code is superfluous. However, the fact that Course Manager breaks without the correct version is really annoyying. The worst part is that the installation routine checks for the correct version of SLK and .Net, before letting you install, and those checks were broken so no one could install. Please, either check for all requirements, or none, not just a couple that you feel like checking for, It’s either a fully robust installation, or a requirement for the installer to manually check for everything first.

I’m not convinced that anyone apart from the authors of the framework is going to be able to add easily any functionality to Course Manager using the framework, or maintain what is there. Why couldn’t they have used a mature, robust, full featured framework like NHibernate is beyond me. Granted NHibernate doesn’t handle the UI stuff, but thousands of successful projects use it rather than just one.

Finally the two biggest problems of the framework are:

  1. Many, many warning on building the projects. There should be 0.
  2. There are many places where all exceptions are caught and ignored. This is fundamentally wrong.

Categories: SLK Tags:

Finding out if SharePoint Objects are Disposed Correctly

February 27th, 2009 RichardWillis No comments

Everyone should know by now that certain SharePoint objects, including SPSite and SPWeb need to be disposed of when you have finished with them or you will get a memory leak. If you want to refresh your memory have a look at the MSDN white papers Best Practices: Using Disposable Windows SharePoint Services Objects on MSDN and Best Practices: Common Coding Issues When using the SharePoint object model.

What you may not know is that there are a couple of tools/techniques which can help you find areas in your code where you are not disposing of objects correctly.

  1. SPDisposeCheck. This is a tool which will analyze your assemblies to search for coding patterns which lead to objects not being disposed correctly. It’s a great tool and worth running regularly on your assemblies.
  2. SPRequestStackTrace registry value. Creating the registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings
SPRequestStackTrace: DWORD = 1

Will cause the SharePoint runtime to log a stack trace everytime a SPRequest object is not disposed of correctly. This will actually pick up all the types of objects not being disposed of as internally the problem with not disposing of them is that they contain a reference to SPRequest.

At this point I have to say thank you to Jared Kahlil who pointed out a memory leak in the SLK by using the second method above and started my research into both of these methods. Unfortunately we can’t use SPDisposeCheck on SLK as it checks to see if the file name begins with Microsoft and if there are any namespaces beginning with Microsoft, and if so ignores the assembly.

Categories: Development, SLK, SharePoint Tags:

SharePoint Learning Kit 1.3.1 support for Microsoft Learning Gateway

February 26th, 2009 RichardWillis No comments

I’ve updated the components of the MLG which depend on SLK to use the latest version (1.3.1). You can download these from the MLG 1.1 release page. This had been one of the biggest bugbears of the SLK & MLG projects, the fact that they were not in sync. Not that there’s convergence again we should be able to keep them in sync.

Please let me know if there work for you.

Categories: Microsoft Learning Gateway, SLK Tags:

slkadm for SharePoint Learning Kit

February 26th, 2009 RichardWillis 2 comments

slkadm is a tool which ships with the SharePoint Learning Kit and is analogous to stsadm for SharePoint itself, in that it’s used the administratively configure SLK, in particular the SLK mappings.

What is an SLK mapping?

An SLK mapping is the link between a site collection and the SLK data. For each site collection you want to use SLK with you must create a mapping. You would normally do this through SharePoint Central Administration | Application Management | SharePoint Learning Kit.

A mapping consists of:

  • The GUID of the site collection – this uniquely identifies the site collection
  • The database connection details
  • The names of the SLK permissions
  • The SlkSettings file used to define the queries used in the Assignment List Web Part and elsewhere.

To re-iterate, if a site collection does not have an SLK mapping associated with it, you will not be able to use SLK on that site. A common problem is not setting the correct site collection on the Configure SharePoint Learning Kit page. It’s actually not that obvious which site collection the page is going to update, even though it’s the first control on the page.

What can slkadm do?

slkadm is a command line tool and can perform 4 tasks:

  • Configure a site collection / mapping. Either one which hasn’t been configured before, or update an existing mapping.
  • Show the existing mapping for a site collection.
  • Show all mappings on the server
  • Delete a mapping

Configure a site collection

The command for this is

slkadm.exe -o configuresite -url http://server/site -databaseserver myDbServer -databasename myDatabase -createdatabase -instructorPermission “SLK Instructor” -learnerPermission “SLK Learner” -observerPermission “SLK Observer” -createPermissions -uploadSlkSettings “file name of slksettings.xml” -defaultSettings

The arguments for these are fairly self explanatory Some notes are:

  • createdatabase. If this is present then the database is created
  • createPermissions – Create the permission levels
  • defaultSettings – Use the default slksettings.xml. Cannot be used with uploadSlkSettings

Show the existing mapping for a site collection

The command for this is

slkadm.exe -o getsiteconfiguration -url http://server/site

and an example output is

Notice that slkadm has “found” the SLK configuration and then listed what is configured. The output could be clearer though, here’s one for a site collection which has not been configured:

Although it does state that “no SLK configuration found”, it then goes on to list the default settings, so at first glance it could be configured.

Show all mappings on the server

The command for this is simply

slkadm.exe -o enummappings

with an example output as

You will get one line per site collection configured, with some minimal information – the site url, GUID and database details. In the example here I’ve got 2 site collections configured for slk.

Delete a mapping

The command for this is

slkadm.exe -o deletemapping -guid 1234abcd-1234-abcd-1234-abcd1234abcd

where the GUID is replaced by the GUID of the site collection. The easiest way to get the GUID is by running the enummappings or getsiteconfiguration commands.

This will delete the mapping, and disable SLK on the site collection, but it will not remove the database or the Assignment List Web Parts from any pages in the site collection.

List the commands

As is standard with any command line tool you can view the commands by running

slkadm.exe /?

Categories: SLK Tags: