Skip to content

Commit

Permalink
SAK-20092 add ta's to section export
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/sections/trunk@93243 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
axxter99 committed May 25, 2011
1 parent afcdc19 commit d025277
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions sections/sections-app-util/src/bundle/sections.properties
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ student_view_sections=Sections
student_view_all=All
edit_student_update=Assign students
roster_table_header_id=Student ID
roster_table_header_ta=Teaching Assistants
overview_link_sep_char=|
edit_manager_successful=Teaching Assistants for {0} were updated successfully\!
roster_search_button=Find
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ public List getFilterItems() {
public void export(ActionEvent event){
log.debug("export(");
List<List<Object>> spreadsheetData = new ArrayList<List<Object>>();

Map<String, String> sectionTutors = new HashMap<String, String>();
// Get the section enrollments
Set<String> studentUids = new HashSet<String>();
for(Iterator iter = siteStudents.iterator(); iter.hasNext();) {
Expand All @@ -319,12 +321,14 @@ public void export(ActionEvent event){
List<Object> header = new ArrayList<Object>();
header.add(JsfUtil.getLocalizedMessage("roster_table_header_name"));
header.add(JsfUtil.getLocalizedMessage("roster_table_header_id"));


for (Iterator iter = getUsedCategories().iterator(); iter.hasNext();){
for (Iterator<String> iter = getUsedCategories().iterator(); iter.hasNext();){
String category = (String)iter.next();
String categoryName = getCategoryName(category);
header.add(categoryName);
}
header.add(JsfUtil.getLocalizedMessage("roster_table_header_ta"));
spreadsheetData.add(header);
for(Iterator enrollmentIter = siteStudents.iterator(); enrollmentIter.hasNext();) {
//EnrollmentDecorator enrollment = enrollmentIter.next();
Expand All @@ -339,9 +343,18 @@ public void export(ActionEvent event){
CourseSection section = sectionEnrollments.getSection(record.getUser().getUserUid(), category);

if(section!=null){
row.add(section.getTitle());
row.add(section.getTitle());
//SAK-20092 add the TA's
if (sectionTutors.get(section.getUuid()) != null) {
row.add(sectionTutors.get(section.getUuid()));
} else {
String ta = getSectionTutorsAsString(section.getUuid());
row.add(ta);
sectionTutors.put(section.getUuid(), ta);
}
}else{
row.add("");
row.add("");
}
}
spreadsheetData.add(row);
Expand All @@ -351,6 +364,21 @@ public void export(ActionEvent event){

}

private String getSectionTutorsAsString(String section) {
List<ParticipationRecord> tas = getSectionManager().getSectionTeachingAssistants(section);
StringBuilder sb = new StringBuilder();
for (int i =0; i < tas.size(); i++) {
ParticipationRecord participant = tas.get(i);
if (i > 0) {
sb.append(", ");
}
sb.append(participant.getUser().getDisplayName());
}

return sb.toString();
}


protected String getDownloadFileName(String rawString) {
String dateString = DateFormat.getDateInstance(DateFormat.SHORT).format(new Date());
return rawString.replaceAll("\\W","_")+ "_"+dateString;
Expand Down

0 comments on commit d025277

Please sign in to comment.