aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2014-07-30 01:28:50 +0200
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2016-01-27 01:51:20 +0100
commit1d294571a89a20f005ae6b8e1f9697db5017412e (patch)
tree542595f47d557d7902908d905446617e43b88900
parentc1dc11fa754458d5b49efad0203be0a96a1cbc63 (diff)
downloadecs2-1d294571a89a20f005ae6b8e1f9697db5017412e.tar.gz
ecs2-1d294571a89a20f005ae6b8e1f9697db5017412e.zip
New numlab exercises filter.
Exercises Filter-Plugin. This filter masquerades the response of an request to /numlab/exercises/<id>. With a query string the request only contain toplevel properties with simple string type. For now these toplevel properties are: * postTime * identifier * comment * name * description * environment The querystring parameter is known as: properties. You're allowed to note multiple toplevel properties, spaced by comma. Please be patient not to include any spaces in the list. Working ressource notations are: http://ecs.uni-stuttgart.de/numlab/exercises/27?properties=name http://ecs.uni-stuttgart.de/numlab/exercises/27?properties=name,description http://ecs.uni-stuttgart.de/numlab/exercises/27?properties=name,description,comment,identifier Problematic/forbidden notations are: http://ecs.uni-stuttgart.de/numlab/exercises/27?properties= name http://ecs.uni-stuttgart.de/numlab/exercises/27?properties=name ,description http://ecs.uni-stuttgart.de/numlab/exercises/27?properties =name,description,comment , identifier
-rw-r--r--filter/numlab/exercises/show/extract_properties/filter.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/filter/numlab/exercises/show/extract_properties/filter.rb b/filter/numlab/exercises/show/extract_properties/filter.rb
new file mode 100644
index 0000000..d2a767a
--- /dev/null
+++ b/filter/numlab/exercises/show/extract_properties/filter.rb
@@ -0,0 +1,25 @@
+module Filter
+ def self.start
+ properties=FILTER_API.params[:properties]
+ return if properties.nil?
+ properties= properties.split(",")
+ properties_length= properties.length
+ obj= JSON.parse(FILTER_API.record.body)
+ i=0
+ body= ERB.new <<-'EOF',0,">"
+{ "Exercise" :
+ {
+<% properties.each do |e| %>
+<% i += 1 %>
+ "<%= e %>" : "<%= obj["Exercise"][e] %>"<% if i!=properties_length %>,
+<% end %>
+<% end %>
+
+ }
+}
+EOF
+
+ FILTER_API.record.body= body.result(binding)
+ #Message.destroy_msg(FILTER_API.record)
+ end
+end