This project has moved and is read-only. For the latest updates, please go here.

Getting Package/Learner information

Topics: Developer Forum
May 15, 2007 at 9:41 PM
Hi, all... I'm writing a webpart to integrate with the SLK and seeking some help with a task:

My goal is to determine, for a given package in a document library that I'm iterating through):

a) Whether that package is registered as an assignment and if so,

b) Whether the current logged in user has started that assignment or not

From reading through the SDK documentation, it appears that I can accomplish b) using the GetLearnerAssignmentProperties(LearnerAssignmentId, SLKRole) method of the learning store.

However, how do I determine that LearnerAssignmentId given the current user logged in and a location to the package? Is this an advisable approch?

Thanks in advance,
May 17, 2007 at 12:59 PM
Hi Mike,

Not sure what the exact end goal is, but if your requirement is just to display the list of packages from the document library that the current user has not started (or started), you can do so by adding a simple query, as follows, to the Assignment List Web Part (query sets for ALWP are defined in SlkSettings.xml)

<Query Name="NotStartedLearner" Title="NotStarted" ViewName="LearnerAssignmentListForLearners" CountViewColumnName="IsFinal">
  <Column Title="Site" RenderAs="SPWebName" ViewColumnName="AssignmentSPWebGuid" ViewColumnName2="AssignmentSPSiteGuid" /> 
  <Column Title="Assignment" RenderAs="Link" ViewColumnName="AssignmentTitle" ViewColumnName2="LearnerAssignmentId" NullDisplayString="Untitled" /> 
  <Column Title="Due" RenderAs="UtcAsLocalDateTime" ViewColumnName="AssignmentDueDate" CellFormat="d" NullDisplayString="--" ToolTipFormat="Due: {0:D}, {0:t}" Wrap="false" /> 
  <Column Title="Status" RenderAs="LearnerAssignmentStatus" ViewColumnName="LearnerAssignmentState" Wrap="false" /> 
  <Column Title="Score" RenderAs="ScoreAndPossible" ViewColumnName="FinalPoints" ViewColumnName2="AssignmentPointsPossible" ToolTipFormat="Score: {0}" Wrap="false" /> 
  <Condition ViewColumnName="AssignmentSPWebGuid" Operator="Equal" MacroName="SPWebScope" NoConditionOnNull="true" /> 
  <Condition ViewColumnName="IsFinal" Operator="NotEqual" Value="1" /> 
  <Condition ViewColumnName="LearnerAssignmentState" Operator="LessThan" Value="1" /> 
  <Sort ViewColumnName="AssignmentDueDate" Ascending="true" /> 
  <Sort ViewColumnName="LearnerAssignmentState" Ascending="true" /> 

This is the easiest approach which does not require any programming at all!

If this doesn't suit what you are trying to achieve, I guess you will need to use the LearningStore object to query the database for the list of learner assignments for the current user. Check out the SLK sample, ReportPages, which does a simple query using the LearningStore object. Do remember to take advantage of the convenient LearnerAssignmentListForLearners sql view for your query.
May 17, 2007 at 2:43 PM
Thanks, Vandana... This will point me in the right direction I'm sure.

Here's what I'm trying to do: we have a list of packages that represent individual lessons. This lessons need to be grouped into units and displayed as such. For the "Unit" page, I want to list all the lessons available in that unit to the student. However, I want to provide a link for them to self-assign the lesson, to resume the lesson or review the lesson depending on their status.

I've added a field to the document library containing the packages called Unit so I can query all the packages corresponding to a given unit. I'm then trying to iterate through each package, decide whether the student has started it or not, then display the link appropriately.

Hopefully that makes sense... If you happen to have any feedback / suggestions on the approach, it would be appreciated.