Skip to content

Commit

Permalink
More work on the next step of the import process
Browse files Browse the repository at this point in the history
  • Loading branch information
maurercw authored and Chris Maurer committed Feb 12, 2015
1 parent f462f74 commit 4745741
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ label.addgradeitem.release = Release this item to students?
label.addgradeitem.include = Include this item in course grade calculations?

importExport.page.description = If you would like to edit grades for your course using a spreadsheet application on your computer \
(e.g. Wxcel, Numbers), you may download a Gradebook template that you may later re-upload and import into the Gradebook. \
(e.g. Excel, Numbers), you may download a Gradebook template that you may later re-upload and import into the Gradebook. \
Upon uploading, you may choose to import either specific items, or the entire spreadsheet.

importExport.step1.heading = Step 1 - Download Template
Expand All @@ -49,8 +49,21 @@ importExport.step3.heading = Step 3 - Upload and Import
importExport.step3.description = Select Browse to upload your updated template, then select Continue. On the following \
screen, you may choose the content that you would like to import.


importExport.confirmation.heading = Grade Item Import Selection
importExport.confirmation.description = The system has analyzed the contents of your file upload and has identified new/updated \
importExport.selection.heading = Grade Item Import Selection
importExport.selection.description = The system has analyzed the contents of your file upload and has identified new/updated \
information where applicable. Please select from the desired items below.
importExport.confirmation.note = Note: Selecting "Update" items will override existing scores for that item.
importExport.selection.note = Note: Selecting "Update" items will override existing scores for that item.

importExport.selection.details = If selecting new items, you will be asked to confirm their Settings on the following screen(s).


importExport.confirmation.heading = Confirmation
importExport.confirmation.update.description = This is to confirm that you will be updating the following Gradebook items:
importExport.confirmation.create.description = You will also be creating {0} ({1}) new Gradebook items:


#ProcessedGradeItem status map
importExport.status.0 = Update
importExport.status.1 = NEW
importExport.status.2 = N/A
importExport.status.3 = Unknown
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
<wicket:panel xmlns:wicket="http://wicket.apache.org">

<div><wicket:message key="importExport.confirmation.heading" /></div>
<div><wicket:message key="importExport.confirmation.description" /></div>
<div><wicket:message key="importExport.confirmation.note" /></div>
<div><wicket:message key="importExport.confirmation.update.description" /></div>

<!--<form wicket:id="form">-->
<!--<span wicket:id="group">-->
<!--<input type="checkbox" wicket:id="groupselector">check/uncheck all</input>-->
<!--<tr wicket:id="grades">-->
<!--<td><input type="checkbox" wicket:id="checkbox"/></td>-->
<!--<td><span wicket:id="studentId">[this is where name will be]</span></td>-->
<!--<td><span wicket:id="studentName">[this is where lastname will be]</span></td>-->
<!--</tr>-->
<!--</span>-->
<!--</form>-->
<table cellspacing="0" cellpadding="2">
<tr wicket:id="grades_update">
<td><span wicket:id="itemTitle">[this is where itemTitle will be]</span></td>
</tr>
</table>

<div><wicket:message key="importExport.confirmation.create.description" /></div>

<table cellspacing="0" cellpadding="2">
<tr wicket:id="grades_create">
<td><span wicket:id="itemTitle">[this is where itemTitle will be]</span></td>
</tr>
</table>

<form wicket:id="form">
<span wicket:id="group">
<table style="border: 2px dotted #fc0; width: 400px; padding: 5px;">
<tr>
<td valign="top">Select grades</td>
<td>
<input type="checkbox" wicket:id="groupselector">check/uncheck all</input><br/>
<table cellspacing="0" cellpadding="2">
<tr>
<td><b>Select</b></td>
<td><b>Title</b></td>
<td><b>Point Value</b></td>
<td><b>Status</b></td>
</tr>
<tr wicket:id="grades">
<td><input type="checkbox" wicket:id="checkbox"/></td>
<td><span wicket:id="itemTitle">[this is where itemTitle will be]</span></td>
<td><span wicket:id="itemPointValue">[this is where itemPointValue will be]</span></td>
<td><span wicket:id="status">[this is where status will be]</span></td>
</tr>
</table>
<span valign="top">
</span>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="submit" />
</td>
</tr>
</table>
</span>
<input type="submit" value="submit" />
</form>

</wicket:panel>
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,90 @@

import org.apache.log4j.Logger;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Check;
import org.apache.wicket.markup.html.form.CheckGroup;
import org.apache.wicket.markup.html.form.CheckGroupSelector;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;
import org.sakaiproject.gradebookng.business.model.ImportedGrade;
import org.sakaiproject.gradebookng.business.model.ProcessedGradeItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Created by chmaurer on 1/22/15.
* Created by chmaurer on 2/10/15.
*/
public class GradeImportConfirmationStep extends Panel {

private static final Logger log = Logger.getLogger(GradeImportConfirmationStep.class);
private static final Logger log = Logger.getLogger(GradeItemImportSelectionStep.class);

private String panelId;

public GradeImportConfirmationStep(String id, List<ProcessedGradeItem> processedGradeItems) {
super(id);
this.panelId = id;

final CheckGroup<ImportedGrade> group = new CheckGroup<ImportedGrade>("group", new ArrayList<ImportedGrade>());
// final CheckGroup<ImportedGrade> group = new CheckGroup<ImportedGrade>("group", new ArrayList<ImportedGrade>());

Form<?> form = new Form("form")
{
@Override
protected void onSubmit()
{
info("selected grade(s): " + group.getDefaultModelObjectAsString());
// info("selected grade(s): " + form.getDefaultModelObjectAsString());

}
};
add(form);
form.add(group);
group.add(new CheckGroupSelector("groupselector"));
ListView<ProcessedGradeItem> gradeList = new ListView<ProcessedGradeItem>("grades",
processedGradeItems)
// form.add(group);
// group.add(new CheckGroupSelector("groupselector"));


List<ProcessedGradeItem> itemsToUpdate = filterListByStatus(processedGradeItems,
Arrays.asList(new Integer[] {ProcessedGradeItem.STATUS_UPDATE, ProcessedGradeItem.STATUS_NA}));
List<ProcessedGradeItem> itemsToCreate = filterListByStatus(processedGradeItems,
Arrays.asList(new Integer[] {ProcessedGradeItem.STATUS_NEW}));

ListView<ProcessedGradeItem> updateList = new ListView<ProcessedGradeItem>("grades_update", itemsToUpdate)
{
/**
* @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
*/
@Override
protected void populateItem(ListItem<ProcessedGradeItem> item)
{
item.add(new Check<ProcessedGradeItem>("checkbox", item.getModel()));
item.add(new Label("itemTitle",
new PropertyModel<String>(item.getDefaultModel(), "itemTitle")));
item.add(new Label("itemPointValue", new PropertyModel<String>(item.getDefaultModel(),
"itemPointValue")));
item.add(new Label("status", new PropertyModel<String>(item.getDefaultModel(),
"status")));
item.add(new Label("itemTitle", new PropertyModel<String>(item.getDefaultModel(), "itemTitle")));
}
};

updateList.setReuseItems(true);
add(updateList);

ListView<ProcessedGradeItem> createList = new ListView<ProcessedGradeItem>("grades_create", itemsToCreate)
{
/**
* @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
*/
@Override
protected void populateItem(ListItem<ProcessedGradeItem> item)
{
item.add(new Label("itemTitle", new PropertyModel<String>(item.getDefaultModel(), "itemTitle")));
}
};

gradeList.setReuseItems(true);
group.add(gradeList);
createList.setReuseItems(true);
add(createList);

}

private List<ProcessedGradeItem> filterListByStatus(List<ProcessedGradeItem> gradeList, List<Integer> statuses) {
List<ProcessedGradeItem> filteredList = new ArrayList<ProcessedGradeItem>();
for (ProcessedGradeItem gradeItem : gradeList) {
if (statuses.contains(gradeItem.getStatus()))
filteredList.add(gradeItem);
}
return filteredList;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void onSubmit() {
log.debug(processedGradeItems.size());

//repaint panel
Component newPanel = new GradeImportConfirmationStep(panelId, processedGradeItems);
Component newPanel = new GradeItemImportSelectionStep(panelId, processedGradeItems);
newPanel.setOutputMarkupId(true);
GradeImportUploadStep.this.replaceWith(newPanel);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<wicket:panel xmlns:wicket="http://wicket.apache.org">

<div><wicket:message key="importExport.selection.heading" /></div>
<div><wicket:message key="importExport.selection.description" /></div>
<div><wicket:message key="importExport.selection.note" /></div>

<form wicket:id="form">
<span wicket:id="group">
<table style="border: 2px dotted #fc0; width: 400px; padding: 5px;">
<tr>
<td valign="top">Select grades</td>
<td>
<input type="checkbox" wicket:id="groupselector">check/uncheck all</input><br/>
<table cellspacing="0" cellpadding="2">
<tr>
<td><b>Select</b></td>
<td><b>Title</b></td>
<td><b>Point Value</b></td>
<td><b>Status</b></td>
</tr>
<tr wicket:id="grades">
<td><input type="checkbox" wicket:id="checkbox"/></td>
<td><span wicket:id="itemTitle">[this is where itemTitle will be]</span></td>
<td><span wicket:id="itemPointValue">[this is where itemPointValue will be]</span></td>
<td><span wicket:id="status">[this is where status will be]</span></td>
</tr>
</table>
<span valign="top">
</span>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="submit" />
</td>
</tr>
</table>
</span>
</form>

<div><wicket:message key="importExport.selection.details" /></div>

</wicket:panel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.sakaiproject.gradebookng.tool.panels;

import org.apache.log4j.Logger;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Check;
import org.apache.wicket.markup.html.form.CheckGroup;
import org.apache.wicket.markup.html.form.CheckGroupSelector;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;
import org.sakaiproject.gradebookng.business.model.ImportedGrade;
import org.sakaiproject.gradebookng.business.model.ProcessedGradeItem;

import java.util.ArrayList;
import java.util.List;

/**
* Created by chmaurer on 1/22/15.
*/
public class GradeItemImportSelectionStep extends Panel {

private static final Logger log = Logger.getLogger(GradeItemImportSelectionStep.class);

private String panelId;

public GradeItemImportSelectionStep(String id, List<ProcessedGradeItem> processedGradeItems) {
super(id);
this.panelId = id;

final CheckGroup<ImportedGrade> group = new CheckGroup<ImportedGrade>("group", new ArrayList<ImportedGrade>());

Form<?> form = new Form("form")
{
@Override
protected void onSubmit()
{
info("selected grade(s): " + group.getDefaultModelObjectAsString());

//repaint panel
Component newPanel = new GradeImportConfirmationStep(panelId, (List<ProcessedGradeItem>)group.getDefaultModelObject());
newPanel.setOutputMarkupId(true);
GradeItemImportSelectionStep.this.replaceWith(newPanel);

}
};
add(form);
form.add(group);
group.add(new CheckGroupSelector("groupselector"));
ListView<ProcessedGradeItem> gradeList = new ListView<ProcessedGradeItem>("grades",
processedGradeItems)
{
/**
* @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
*/
@Override
protected void populateItem(ListItem<ProcessedGradeItem> item)
{

item.add(new Check<ProcessedGradeItem>("checkbox", item.getModel()));
item.add(new Label("itemTitle",
new PropertyModel<String>(item.getDefaultModel(), "itemTitle")));
item.add(new Label("itemPointValue", new PropertyModel<String>(item.getDefaultModel(),
"itemPointValue")));

//Use the status code to look up the text representation
PropertyModel<Integer> statusProp = new PropertyModel<Integer>(item.getDefaultModel(), "status");
Integer status = statusProp.getObject();
String statusValue = getString("importExport.status." + status);
item.add(new Label("status", statusValue));
}

};

gradeList.setReuseItems(true);
group.add(gradeList);

}

}

0 comments on commit 4745741

Please sign in to comment.