Permalink
Browse files

添加成绩修改

  • Loading branch information...
1 parent 8f7d003 commit 7245500058f07d8dfb86ad43c850be7176f4e3d1 @mouse-lin committed Mar 23, 2012
Showing with 59 additions and 5 deletions.
  1. +1 −1 Gemfile
  2. +21 −0 Gemfile.lock
  3. +10 −0 app/controllers/students_controller.rb
  4. +1 −0 app/models/student.rb
  5. +1 −0 config/routes.rb
  6. +25 −4 public/javascripts/PF/pages/settings_index.js
View
@@ -25,7 +25,7 @@ gem 'roo', '1.3.11'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
-# gem 'ruby-debug19'
+ gem 'ruby-debug19'
# Bundle the extra gems:
# gem 'bj'
View
@@ -31,10 +31,12 @@ GEM
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
+ archive-tar-minitar (0.5.2)
arel (2.0.10)
bcrypt-ruby (2.1.4)
builder (2.1.2)
cocaine (0.2.1)
+ columnize (0.3.2)
daemons (1.0.10)
devise (1.3.4)
bcrypt-ruby (~> 2.1.2)
@@ -49,6 +51,8 @@ GEM
i18n (0.6.0)
kindeditor (0.0.3)
libxml-ruby (2.0.9)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -88,6 +92,7 @@ GEM
rd_searchlogic (3.0.1)
activerecord (>= 3.0.0)
rmagick (2.13.1)
+<<<<<<< HEAD
roo (1.3.11)
GData (>= 0.0.4)
hpricot (>= 0.6)
@@ -98,6 +103,18 @@ GEM
rubyzip (0.9.4)
spreadsheet (0.6.5.7)
ruby-ole (>= 1.0)
+=======
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+>>>>>>> 添加成绩修改
thor (0.14.6)
treetop (1.4.10)
polyglot
@@ -119,4 +136,8 @@ DEPENDENCIES
rake (= 0.8.7)
rd_searchlogic (= 3.0.1)
rmagick
+<<<<<<< HEAD
roo (= 1.3.11)
+=======
+ ruby-debug19
+>>>>>>> 添加成绩修改
@@ -42,6 +42,16 @@ def update_student
render_error e.message,'text/html'
end
+ def update_score
+ params[:jsonData].each do |j|
+ j.delete("course/name")
+ end
+ Student.find(params[:studentId]).update_attributes({ :course_scores_attributes => params[:jsonData]})
+ render_json "success"
+ rescue => e
+ render_error e.message
+ end
+
def print
@student = Student.find(params[:id])
end
View
@@ -3,6 +3,7 @@
class Student < Person
belongs_to :classes
has_many :course_scores
+ accepts_nested_attributes_for :course_scores, :allow_destroy => true
def total_score_by_grade
gc = course_scores.group_by { |o| o.grade }
View
@@ -27,6 +27,7 @@
get "print"
post "destroy_student"
post "update_student"
+ post "update_score"
end
member do
post "update_student_comment"
@@ -67,10 +67,11 @@ Pf.settings.homeIndex = {
new Ext.grid.RowNumberer(),
{ header: '学期', sortable: true, dataIndex: 'grade'},
{ header: '科目', sortable: true, dataIndex: 'course/name'},
- { header: '成绩', sortable: true, dataIndex: 'score'},
+ { header: '成绩', sortable: true, dataIndex: 'score',editor:new Ext.form.NumberField() },
{ header: '备注', width: 150,sortable: true, dataIndex: 'remark'},
]);
- var grid_name = new Ext.grid.EditorGridPanel({
+ var grid = new Ext.grid.EditorGridPanel({
+ id: "studentCourseScore",
store: studentScoreStore,
loadMask: true,
cm: cm,
@@ -79,11 +80,31 @@ Pf.settings.homeIndex = {
tbar: [{
iconCls:"add", text:"成绩录入",handler: function(){ alert("niaho") }
},{
- iconCls:"table_edit", text:"成绩更新",handler: function(){ alert("niaho") }
+ iconCls:"table_edit", text:"成绩更新",handler: function(){
+ var jsonData = Ext.getCmp("studentCourseScore").store.getModifiedRecords();
+ if(!jsonData[0]){ Ext.Msg.alert("提示","没有需要更新的数据"); }
+ else{
+ var jsonObject = [];
+ Ext.each(jsonData,function(data){
+ jsonObject.push(data.data);
+ });
+ Ext.Ajax.request({
+ url: "/students/update_score.json",
+ method: "POST",
+ jsonData: { jsonData: jsonObject, studentId: Ext.getCmp("studentShowGrid").getSelectionModel().getSelected().data.id } ,
+ success: function(response, opts){
+ Ext.Msg.alert("提示","保存成功");
+ },
+ failure: function(response, opts){
+ Ext.Msg.alert("提示","保存失败");
+ }
+ })
+ }
+ }
}],
bbar : new Pf.util.Bbar({ store : studentScoreStore }),
});
- return grid_name;
+ return grid;
},
createStudentDetail: function(){

0 comments on commit 7245500

Please sign in to comment.