org.activemath.webapp.user
Class User

java.lang.Object
  extended by org.activemath.webapp.user.User
Direct Known Subclasses:
AnonUser

public class User
extends Object

Represents an ActiveMath user. Facade to many user centric functions.

View Documentation

The User is tied to the request scope and available as $user in the view.
VariableDescription
$user.Id Unique user id
$user.Name Informal name of this user.
$user.Group Current group context of this user, see UserGroup).
$user.isInGroup(groupId) Say if this user is member of UserGroup groupId.
$user.PotentialGroups List of groups this user is allowed to join, see UserGroup).
$user.PotentialGroupIds List of group ids this user is allowed to join, see UserGroup).
$user.Skin Name of Skin to use for this user (may depend on group). Empty if no skin.
User Roles
$user.isAnon() Say if this is an anonymous user (AnonUser).
$user.isVisitor() Say if this is user has UserRole visitor.
$user.isLearner() Say if this is user has UserRole learner (default role if logged in).
$user.isAuthor() Say if this is user has UserRole author .
$user.isTutor() Say if this is user has UserRole tutor .
$user.isAdmin() Say if this is user has UserRole admin .
$user.Roles Complete UserRoleSet of this user.
Access to data objects
$user.Books List of personal books (UserBooks) attached to this user.
$user.getBook(bookId Returns a (possible personalized) instance of a book (UserBook or RecBook) for this user. Beware: this bypasses group config.
$user.ExperimentalProgress see ExperimentalProgress
$user.LearnerModelName Name of the current LearnerModelInterface.
$user.PendingTests List of compulsory tests this user has not completed yet (test ids).
$user.hasPendingTests True of there are pending tests.
$user.UserData Complete UserData. For direct access to properties, see below.
Access to user data
$user.CompetencyLevel CompetencyLevel of this user.
$user.Country
$user.Email
$user.Field Field of this user.
$user.FullName Full name of this user.
$user.Language Language of this user.
$user.LearningContext LearningContext of this user.
$user.MediaCompetency
$user.Name Informal name of this user.
$user.OutputFormat Preferred output format ("html", "mathml"). See AppContext.getAvailableFormats(), Formatter.
$user.ReadingSkill
$user.isFeedbackOn() Say if content feedback is enable for this user.
$user.isInputEditorOn() Say if input editor is enable for this user.


Constructor Summary
User()
           
User(String id)
           
 
Method Summary
 void addBook(Book book)
           
 void addBookStat(BookStat stat)
           
 void addBookState(BookState state)
          Add a BookState to a user.
 void addPotentialGroup(String groupId)
           
 void addPotentialGroups(String[] groupIds)
           
 Object attachedObject(String key)
          Retrieve a shared object added with a call to shareObject() or shareObjectPersistent().
 void attachObject(String key, Object o)
          Put an object available for sharing.
 void attachPersistentObject(String key, String value)
          Put a persistent object available for sharing.
 BookStat calculateBookStat(String bookId)
          Calculates the BookStat for that book
 void calculateBookStats()
          Calculates all bookStats for the user
 Object detachObject(String key)
           
 void detachPersistentObject(String key)
           
 Book getBook(String bookId)
           
 List<Bookmark> getBookmarks()
           
 List<Book> getBooks()
           
 BookStat getBookStat(String bookId)
          Returns a book's state.
 BookState getBookState(String bookId)
          Returns a book's state.
 Map<String,BookState> getBookStates()
           
 Map<String,BookStat> getBookStats()
           
 CompetencyLevel getCompetencyLevel(String contentId)
           
 CompetencyLevel getCompetencyLevel(String contentId, Competency competency)
           
 CompetencyLevel getCompetencyLevel(String userId, String contentId)
          Deprecated.  
 CompetencyLevel getCompetencyLevel(String userId, String contentId, Competency competency)
          Deprecated.  
 String getCountry()
           
 String getEducationalLevel()
          Synonym to @see getLearningContext()
 String getEmail()
           
 ExperimentalProgress getExperimentalProgress()
           
 Field getField()
           
 String getFullName()
           
 UserGroup getGroup()
           
 String getGroupId()
           
 String getId()
           
 String getLanguage()
           
 String getLearnerModel()
           
 LearnerModelInterface getLearnerModelInterface()
          Get LearnerModel for this user.
 String getLearnerModelName()
           
 LearningContext getLearningContext()
           
 int[] getMasteries(List itemIds)
           
 int getMastery(String itemId)
          Fetch a mastery value.
 String getMediaCompetency()
           
 String getName()
           
 String getOriginalId()
           
 String getOutputFormat()
           
 List<String> getPendingTests()
           
 SortedSet<String> getPotentialGroupIds()
           
 Set<UserGroup> getPotentialGroups()
          Return the groups this user is allowed to join.
 String getReadingSkill()
           
 UserRoleSet getRoles()
           
 String getSkin()
           
 String getStereotype()
          Deprecated. use getField()
 Collection<String> getTargetCompetencies()
          (for Math-Bridge)
 List<String> getTutorGroups()
           
 UserData getUserData()
           
 boolean hasPendingTests()
           
 boolean isAdmin()
           
 boolean isAnon()
           
 boolean isAuthor()
           
 boolean isFeedbackOn()
           
 boolean isInGroup()
           
 boolean isInputEditorOn()
           
 boolean isLearner()
           
 boolean isSpeechOutputOn()
           
 boolean isTutor()
           
 boolean isVisitor()
           
 boolean mayJoinGroup(String groupId)
          Say if user is allowed to join a group.
 void removeBook(String bookId)
           
 void removeBookStat(String id)
           
 void removeBookState(String bookStateId)
          Remove a BookState from a user.
 void removePotentialGroup(String groupId)
           
 void removePotentialGroups(String[] groupIds)
           
 void resetBookStates()
           
 void resetExperimentalProgress()
           
 void setCountry(String country)
           
 void setEducationalLevel(String value)
          Synonym to @see setLearningContext(String name)
 void setEmail(String email)
           
 void setFeedback(boolean b)
           
 void setField(Field field)
           
 void setField(String name)
           
 void setFullName(String fullName)
           
 void setGroupId(String newGroupId)
           
 void setInputEditor(boolean value)
           
 void setLanguage(String value)
           
 LearnerModelInterface setLearnerModel(LearnerModelInterface newLm)
          Set a learner model by its interface instance.
 void setLearnerModel(String newLmName)
          Set a new learner model by its name.
 void setLearningContext(LearningContext learningContext)
           
 void setLearningContext(String name)
           
 void setMediaCompetency(String mediaCompetency)
           
 void setName(String name)
           
 void setOutputFormat(String value)
           
 void setPotentialGroups(List<String> groupIds)
           
 void setPotentialGroups(Set<String> groupIds)
          Set a new set of potential groups.
 void setReadingSkill(String value)
           
 void setRoles(UserRoleSet userRoles)
           
 void setSkin(String value)
           
 void setSpeechOutput(boolean value)
           
 void setStereotype(String stereotype)
          Deprecated. use setField()
 void setUserData2(UserData userData)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

User

public User()

User

public User(String id)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

setLearnerModel

public void setLearnerModel(String newLmName)
Set a new learner model by its name. LearnerModelProvider will return the interface for the name.

Parameters:
newLmName - -

setLearnerModel

public LearnerModelInterface setLearnerModel(LearnerModelInterface newLm)
Set a learner model by its interface instance.

Returns:
- the learner model that was set previously

getLearnerModelInterface

public LearnerModelInterface getLearnerModelInterface()
Get LearnerModel for this user. If user is member of a group, set user's LM to group's LM first. If unset, initialize to default learner model.


isInGroup

public boolean isInGroup()
Returns:
true if user is member of a group (but not the default group).

getLearnerModel

public String getLearnerModel()
Returns:
Name of learner model from getLearnerModelInterface()

getLearnerModelName

public String getLearnerModelName()

getId

public String getId()

getOriginalId

public String getOriginalId()
Returns:
id this user was created with.

getName

public String getName()

setName

public void setName(String name)

getUserData

public UserData getUserData()

setUserData2

public void setUserData2(UserData userData)

getExperimentalProgress

public ExperimentalProgress getExperimentalProgress()

resetExperimentalProgress

public void resetExperimentalProgress()

getPendingTests

public List<String> getPendingTests()

hasPendingTests

public boolean hasPendingTests()

resetBookStates

public void resetBookStates()

getFullName

public String getFullName()

setFullName

public void setFullName(String fullName)

getEmail

public String getEmail()

setEmail

public void setEmail(String email)

getCountry

public String getCountry()

setCountry

public void setCountry(String country)

getGroupId

public String getGroupId()

getGroup

public UserGroup getGroup()

setGroupId

public void setGroupId(String newGroupId)

getTutorGroups

public List<String> getTutorGroups()

getPotentialGroups

public Set<UserGroup> getPotentialGroups()
Return the groups this user is allowed to join. Result is never null. If result is empty, user may not join any group. To ease migration, the result defaults to the group the user is already a member of.


getPotentialGroupIds

public SortedSet<String> getPotentialGroupIds()

mayJoinGroup

public boolean mayJoinGroup(String groupId)
Say if user is allowed to join a group. Allow access if either: In any case, only groups that are not hidden may be joined.


setPotentialGroups

public void setPotentialGroups(List<String> groupIds)

setPotentialGroups

public void setPotentialGroups(Set<String> groupIds)
Set a new set of potential groups. If the user's current group is revoked, then the UserGroupDefault will be set as current group.


addPotentialGroup

public void addPotentialGroup(String groupId)

addPotentialGroups

public void addPotentialGroups(String[] groupIds)

removePotentialGroup

public void removePotentialGroup(String groupId)

removePotentialGroups

public void removePotentialGroups(String[] groupIds)

getRoles

public UserRoleSet getRoles()

setRoles

public void setRoles(UserRoleSet userRoles)

getStereotype

public String getStereotype()
Deprecated. use getField()


setStereotype

public void setStereotype(String stereotype)
Deprecated. use setField()


getField

public Field getField()
Returns:
Group's field if set, or User's field.

setField

public void setField(Field field)

setField

public void setField(String name)

getEducationalLevel

public String getEducationalLevel()
Synonym to @see getLearningContext()


setEducationalLevel

public void setEducationalLevel(String value)
Synonym to @see setLearningContext(String name)


getLearningContext

public LearningContext getLearningContext()

setLearningContext

public void setLearningContext(LearningContext learningContext)

setLearningContext

public void setLearningContext(String name)

getMediaCompetency

public String getMediaCompetency()

setMediaCompetency

public void setMediaCompetency(String mediaCompetency)

getLanguage

public String getLanguage()

setLanguage

public void setLanguage(String value)

getSkin

public String getSkin()
Returns:

setSkin

public void setSkin(String value)

getOutputFormat

public String getOutputFormat()
Returns:

setOutputFormat

public void setOutputFormat(String value)

getTargetCompetencies

public Collection<String> getTargetCompetencies()
(for Math-Bridge)

Returns:
A collection of target competencies (concept ids)

getBooks

public List<Book> getBooks()

getBook

public Book getBook(String bookId)

removeBook

public void removeBook(String bookId)

addBook

public void addBook(Book book)

addBookState

public void addBookState(BookState state)
Add a BookState to a user. BookState's user id will be set.


getBookState

public BookState getBookState(String bookId)
Returns a book's state. Creates one, if necessary.

Returns:
BookState of bookId, or null if bookId is null.

getBookStates

public Map<String,BookState> getBookStates()

removeBookState

public void removeBookState(String bookStateId)
Remove a BookState from a user. BookState's user id will be set to null.


calculateBookStat

public BookStat calculateBookStat(String bookId)
Calculates the BookStat for that book

Parameters:
bookId -
Returns:
BookStat or null if there is no data available

calculateBookStats

public void calculateBookStats()
Calculates all bookStats for the user


getBookStats

public Map<String,BookStat> getBookStats()

removeBookStat

public void removeBookStat(String id)

addBookStat

public void addBookStat(BookStat stat)

getBookStat

public BookStat getBookStat(String bookId)
Returns a book's state. Creates one, if necessary.

Returns:
BookState of bookId, or null if bookId is null.

getCompetencyLevel

public CompetencyLevel getCompetencyLevel(String userId,
                                          String contentId,
                                          Competency competency)
Deprecated. 


getCompetencyLevel

public CompetencyLevel getCompetencyLevel(String userId,
                                          String contentId)
Deprecated. 


getCompetencyLevel

public CompetencyLevel getCompetencyLevel(String contentId,
                                          Competency competency)

getCompetencyLevel

public CompetencyLevel getCompetencyLevel(String contentId)

getMastery

public int getMastery(String itemId)
Fetch a mastery value.


getMasteries

public int[] getMasteries(List itemIds)

getBookmarks

public List<Bookmark> getBookmarks()

attachObject

public void attachObject(String key,
                         Object o)
Put an object available for sharing.

Parameters:
key - object key
o - object to share (null to unshare object)

detachObject

public Object detachObject(String key)
Parameters:
key -
Returns:
previous value associated with specified key, or null if there was no mapping for key.

attachPersistentObject

public void attachPersistentObject(String key,
                                   String value)
Put a persistent object available for sharing. Objects shared with this methods will be persisted in the UserData.

Parameters:
key - object key
o - object to share (null to unshare object)

detachPersistentObject

public void detachPersistentObject(String key)

attachedObject

public Object attachedObject(String key)
Retrieve a shared object added with a call to shareObject() or shareObjectPersistent().

Returns:
the object, or null if no object is known under this name (this is not an error).

isFeedbackOn

public boolean isFeedbackOn()

setFeedback

public void setFeedback(boolean b)

setSpeechOutput

public void setSpeechOutput(boolean value)

isSpeechOutputOn

public boolean isSpeechOutputOn()

setInputEditor

public void setInputEditor(boolean value)

isInputEditorOn

public boolean isInputEditorOn()

getReadingSkill

public String getReadingSkill()

setReadingSkill

public void setReadingSkill(String value)

isAnon

public boolean isAnon()

isVisitor

public boolean isVisitor()

isLearner

public boolean isLearner()

isAuthor

public boolean isAuthor()

isTutor

public boolean isTutor()

isAdmin

public boolean isAdmin()