Skip to content

Commit

Permalink
SAK-33470 remove entries from schema (sakaiproject#5299)
Browse files Browse the repository at this point in the history
* Remove unused code and cleanup other compiler warnings

* Add rebel.xml to gitignore so that JRebel project config is not committed

* SAK-33469 add entries to grading schema

* SAK-33470 add button to remove an entry from the course grade schema
  • Loading branch information
steveswinsburg authored Feb 12, 2018
1 parent 28a0e35 commit 5a6d5d2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ <h3 class="panel-title">
<tr wicket:id="schemaView">
<td><input wicket:id="grade" type="text" size="10" class="form-control" /></td>
<td><input wicket:id="minPercent" type="text" size="10" class="form-control" /></td>
<td><button wicket:id="remove" class="btn btn-default"><wicket:message key="button.remove" /></button></td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnLoadHeaderItem;
Expand Down Expand Up @@ -227,6 +228,27 @@ protected void populateItem(final ListItem<GbGradingSchemaEntry> item) {
minPercent.add(new GradingSchemaChangeBehaviour(GradingSchemaChangeBehaviour.ONCHANGE));
grade.add(new GradingSchemaChangeBehaviour(GradingSchemaChangeBehaviour.ONCHANGE));

// remove button
final AjaxButton remove = new AjaxButton("remove") {
private static final long serialVersionUID = 1L;

@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {

// remove this entry from the model data
final GbGradingSchemaEntry current = item.getModelObject();
SettingsGradingSchemaPanel.this.model.getObject().getGradingSchemaEntries().remove(current);

// repaint table
target.add(SettingsGradingSchemaPanel.this.schemaWrap);

// repaint chart
refreshCourseGradeChart(target);
}

};
remove.setDefaultFormProcessing(false);
item.add(remove);
}
};
this.schemaView.setOutputMarkupId(true);
Expand Down Expand Up @@ -643,7 +665,7 @@ public GradingSchemaChangeBehaviour(final String event) {
protected void onUpdate(final AjaxRequestTarget t) {
this.target = t;
refreshGradingSchemaTable();
refreshCourseGradeChart();
refreshCourseGradeChart(this.target);
refreshMessages();
}

Expand All @@ -660,25 +682,6 @@ private void refreshGradingSchemaTable() {
this.target.add(SettingsGradingSchemaPanel.this.schemaWrap);
}

/**
* Refresh the course grade chart
*
* @param target
*/
private void refreshCourseGradeChart() {
// we need the current data from model (sorted) but in JSON form
final List<GbGradingSchemaEntry> schemaList = getGradingSchemaList();

Map<String, Double> schemaMap = asMap(schemaList);
schemaMap = GradeMappingDefinition.sortGradeMapping(schemaMap);
final Gson gson = new GsonBuilder().create();
final String schemaJson = gson.toJson(schemaMap);

final String siteId = SettingsGradingSchemaPanel.this.businessService.getCurrentSiteId();

// TODO this could be a wicket component instead of Javascript
this.target.appendJavaScript("renderChart('" + siteId + "', '" + FormatHelper.encode(schemaJson) + "')");
}

/**
* Refresh messages
Expand Down Expand Up @@ -715,4 +718,24 @@ private GbGradingSchemaEntry stubGradingSchemaMapping() {
return entry;
}

/**
* Refresh the course grade chart
*
* @param target
*/
public void refreshCourseGradeChart(final AjaxRequestTarget target) {
// we need the current data from model (sorted) but in JSON form
final List<GbGradingSchemaEntry> schemaList = getGradingSchemaList();

Map<String, Double> schemaMap = asMap(schemaList);
schemaMap = GradeMappingDefinition.sortGradeMapping(schemaMap);
final Gson gson = new GsonBuilder().create();
final String schemaJson = gson.toJson(schemaMap);

final String siteId = SettingsGradingSchemaPanel.this.businessService.getCurrentSiteId();

// TODO this could be a wicket component instead of Javascript
target.appendJavaScript("renderChart('" + siteId + "', '" + FormatHelper.encode(schemaJson) + "')");
}

}
2 changes: 1 addition & 1 deletion library/src/webapp/content/myworkspace_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<body>
<div class="portletBody">
<h3> Welcome to your personal workspace.</h3>
<p>In Sakai each user has an individual worksite called "Home".
<p>In Sakai each user has his or her own individual worksite called "Home".
Home is a place where you can keep personal documents, create new sites, maintain a
schedule, store resources, and much more.</p>
<p class="instruction">The default information displayed here for a new user can be modified by the Sakai
Expand Down

0 comments on commit 5a6d5d2

Please sign in to comment.