My Documents Now Localised in German

September 5th, 2009 Richard No comments

I actually released a German version of My Documents a while back after a customer request. I just spent some time with them debugging an issue where files and folders weren’t getting saved. I tracked the issue down to a date time localisation issue. To check if the file/folder is present I’m using File.GetCreationTime because when impersonating a user File.Exists always returned true. GetCreationTime returns a "zero" date time if the file doesn’t exist, however it returns it in local time so when I was comparing against a manually created DateTime object it was always greater than it. Once I realised what was wrong it was easy to check properly.

Now that I’ve localised the web part once, all I need for other locales is a translation of the messages within the application, which makes it easy to get ready for other locales.

Categories: Uncategorized Tags:

Roy Osherove’s TDD Masterclass

August 24th, 2009 Richard No comments

I’m a big user of Test Driven Development (TDD) using it in most of my projects. One of the leading proponents of TDD, Roy Osherove, is running a masterclass on TDD in London in September. It would be well worth going if you are interested in starting TDD and can persuade the budget holder to pay.

Quoting from the bbits blog:

Roy Osherove is giving an hands-on TDD Masterclass in the UK, September 21-25. Roy is author of "The Art of Unit Testing" (http://www.artofunittesting.com/), a leading tdd & unit testing book; he maintains a blog at http://iserializable.com (which amoung other things has critiqued tests written by Microsoft for asp.net MVC – check out the testreviews category) and has recently been on the Scott Hanselman podcast (http://bit.ly/psgYO) where he educated Scott on best practices in Unit Testing techniques. For a further insight into Roy’s style, be sure to also check out Roy’s talk at the recent Norwegian Developer’s Conference (http://bit.ly/NuJVa). 

Full Details here: http://bbits.co.uk/tddmasterclass

bbits are holding a raffle for a free ticket for the event. To be eligible to win the ticket (worth £2395!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on September 1st and the winner informed by email and on bbits.co.uk/blog

Categories: Uncategorized Tags:

Back from Annual Leave

August 23rd, 2009 Richard No comments

If anyone has been wondering why I’ve been quieter than usual it’s been because I’ve been on annual leave. I’m now back and looking forward to the new school term, although before it starts I’ve got several installations to do.

While I’ve been away ITWorx and Microsoft have finally released SLK 1.4. Once I’ve got the booked in installs done, and any support the start of term starts, I’ll be properly integrating releasing it and integrating it into the source code repository.

Categories: Uncategorized Tags:

Interesting Active Directory Groups

July 30th, 2009 Richard No comments

I’ve just completed a Salamander Active Directory installation. The school wanted quite a few different types of groups, some of which are very interesting.

Firstly some standard ones:

  • All Students
  • All Staff
  • Students by Year
  • Tutor groups (including the teacher)
  • Classes

Fairly standard stuff here, however all the groups were complicated by the fact that the school, and hence AD, was split into two, the sixth form and the rest of the school. So the structure was duplicated and groups went in different places depending on whether they were sixth form or not.

Now onto the more interesting groups:

Year x Tutors – All staff who take a registration group in year x.

Under 15 Students and Over 15 Students – The school has a content based media server and they wanted to target some of their content based on age.

An email group for each pupil containing all teachers who teach that pupil – That’s a lot of groups, but staff were beginning to get annoyed with bulk emails with subject "FAO teachers of x". It will be interesting to see how this one plays out, whether it has real value or whether it just clutters up the address lists.

I was pleased with how Salamander Active Directory could handle all of these just with configuration changes. I didn’t need to make any changes to the core engine, it just handled it beautifully.

Categories: Uncategorized Tags:

Learning Gateway Conference Slide Decks

July 29th, 2009 Richard No comments
Categories: Uncategorized Tags:

Learning Gateway Conference – My Slides

July 21st, 2009 Richard No comments

Thanks to everyone who attended my sessions at the conference, and for putting up with my technical difficulties.

My first session was The Use of SLK as an E-Learning tool. I has a few technical difficulties with this one as the display size changed after I plugged into the projector, so had to skip the demos.

My second session was My Sites – How to use or not. This one was inspired by the talk given by Mark Eichenberger at the SharePoint Best Practices conference in April.

Learning Gateway Conference – Thanks to Everyone

July 21st, 2009 Richard 2 comments

Alex and I would like to say thanks to everyone involved in the first Learning Gateway Conference, whether you were a speaker, attendee or helper. You all helped to make it a great day.

LGC-Logo

Extra special thanks to the speakers, without whom the day wouldn’t have been as good as it was.

We hope that you all enjoyed it and took some great information and tips away with you.

It’s now been a few days since the event and I’m catching up on the day job’s work! The effort required is beginning to fade, so were already starting to think about planning another one!

Microsoft Learning Gateway Templates

June 30th, 2009 Richard 1 comment

The Microsoft Learning Gateway on CodePlex is a collection of site definitions/templates and web parts designed to kick start a school or district portal. In fact the documentation tells you to set up your school as though you are a district even if being installed in a single school.

My recommendation is NOT to use the site definitions, even though I am the project co-ordinator.  Firstly, let me say that I think that the web parts in the project are useful and have value, so it’s just the definitions I have an issue with.

Why is this?

There’s 2 reasons: actual problems and their lack of value.

The problems

1.    Complex Site Definition

The school site definition is complex. It builds a hierarchy of about 6 sites with each site having 1 to 3 pages. The problem with this is maintainability. There is a growing consensus that site definitions should be as minimal as possible, with most of the work done by features and custom provisioning code if there is a need for an automated build.

The problems with site definitions is that there is no guarantee that they will work when upgrading SharePoint and you can’t modify them once they are deployed.

Problems with upgrading could happen with a service pack or especially a new version – SharePoint 2010 is almost here. Microsoft is pretty much going to guarantee that sites based on the built in definitions upgrade and they will be working hard to minimize problems with custom definitions. However there’s no way they can catch all problems in templates they’ve never even seen. And the more complex the template, the more likely that there will be problems.

For a more in depth treatment see Do you Really Need to Create Custom Site Definitions? by Joel Oleson and You don’t need to create site definitions by Andrew Connell.

Strictly speaking this isn’t a current problem, but could be a huge problem for you when you upgrade if your entire site is based on a definition which doesn’t upgrade well. Whether this is an acceptable risk is then down to the value the definitions provide.

Having said that the 1.1 release modifies the existing templates to support the latest version of SLK and by doing this, it puts the templates in a unsupported state (in Microsoft terms).

2.    Publishing Pages or Not!

The second problem, and this is a real existing problem, is with the pages on the sites. The sites are publishing sites, will all the associated publishing functionality including the Pages library to store the site pages. And this is where the MLG pages are stored. The problem is that the MLG pages are not actually publishing pages.

Publishing pages are special pages which inherit from a specific class and are basically a combination of a page layout from the page layout gallery, and the values of field controls. The MLG pages are just standard web part pages. You can see this by clicking on View All Content and then selecting Pages under Document Libraries. You will see that the Page Layout column is blank. If you try creating a page in the Pages library, the first thing it does is ask you what page layout you want to use.

How is this a problem, they pages all seem to work? Well SharePoint treats the Pages library in a special manner, but it does accept having the web part pages in their with no problem except for one thing. When you come to Edit the page and save it, you get an error about the page being updated in the meantime. You can then save again and all is well. I accept that this seems fairly minor, especially as there is a workaround. But it does confuse people, who question why it happens, and it certainly isn’t going to help with the uptake of your Gateway if there’s obvious errors in it.

3.    Site Collections

Finally, the last major problem is that the school sites are all created in the same site collection. Although this seems to be a good idea on first look, making it easy to share and collaborate, further down the line it start becoming a problem. Having schools in separate site collections is much easier to maintain and backup. You can set quotas on the site collections and move them between databases if they become too big. It’s easier to maintain users and groups as they are scoped at the site collection level and there are many other advantages. There also isn’t really a problem in collaboration between site collections.

The lack of value

What value do the MLG site definitions give? They allow the quick creation of a school gateway by someone with limited SharePoint knowledge. However, it is a bare-bones start. No-one is going to use it just as it’s created. Before it’s used, at a minimum the following needs to happen:
1.  Brand the site. One of the most complex and difficult parts of SharePoint to get right.
2.  Add useful content.
3.  Add more sites to make it usable. For example in the default layout you need to add your class sites. You may want to add departmental sites for your staff to add content to.
4.  Add all your users.

By themselves, none of these are particularly difficult, except the branding. However, the fact that they still need to get done, negates the usefulness of a speedy school creation.

It is also easy to create the layout manually instead of using the site definition. I would recommend a school to do this. Not only will it allow you to get the site layout exactly as works for your school, but you will then be completely familiar with how it is set up. And if you don’t know much about SharePoint, the mere fact you site up the site from scratch means that you will understand it and SharePoint much better. If you already know SharePoint well, the time taken will only be marginally greater than using the site definition. This way you not only get a site better suited to you, you get more experience of SharePoint and don’t have any of the problems detailed above as you will be basing it on an out of the box template. In a later post I will describe how to replicate the school site manually.

The one case where having a site definition is useful is if you are hosting many school sites. And by many I’m talking over 50 if not hundreds of sites. In this case hand building each school does become an issue. However, if you are hosting that many then you really ought to be investing in getting your own templates created, targeted at your and your schools’ needs and branding and not using a generic, brand less, minimal functionality one which at the end of the day are what the MLG definitions are.

Categories: Microsoft Learning Gateway 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: