jiaweiqi před 3 roky
rodič
revize
bddca72c3f

+ 2 - 3
apps/examination/exampaper/models.py

@@ -131,10 +131,9 @@ class ExamPaper(models.Model):
         )
         questions_count = questions.count()
         if questions_count < count:
-            raise CustomError(u'[%s][%s]数量不足!' % (ExamQuestion.DIFFICULTY_CHOICES[difficulty-1][1], ExamQuestion.TYPE_JSON[type-1][1]))
+            raise CustomError(u'[%s][%s]数量不足!' % (ExamQuestion.DIFFICULTY_CHOICES[difficulty-1][1], ExamQuestion.TYPE_CHOICES[type-1][1]))
         question_ids = questions.values_list('id', flat=True)
-
-        rows = random.sample(question_ids, count)
+        rows = random.sample(list(question_ids), count)
         random.shuffle(rows)
 
         data = []

+ 2 - 0
apps/examination/exampaper/serializers.py

@@ -6,6 +6,8 @@ from utils.exceptions import CustomError
 
 class ExamPaperSerializer(serializers.ModelSerializer):
     subject_name = serializers.CharField(source='subject.name', read_only=True)
+    type_text = serializers.CharField(source='get_type_display', read_only=True)
+    create_user_text = serializers.CharField(source='create_user.username', read_only=True)
 
     class Meta:
         model = ExamPaper

+ 13 - 26
uis/admin/exampaper/edit.html

@@ -46,7 +46,7 @@
                     <div class="layui-inline">
                         <label class="layui-form-label"><font color='red' size="4">*</font>及格线:</label>
                         <div class="layui-input-inline">
-                            <input type="text" name="scores" lay-verify="intGeZ" class="layui-input">
+                            <input type="text" name="passline" lay-verify="intGeZ" class="layui-input">
                         </div>
                     </div>
                 </div>
@@ -272,34 +272,21 @@
 
         form.render(null, 'component-form-element');
 
-        var url = id ? '/admin/examquestion/' + id + "/" : '/admin/examquestion/',
+        var url = id ? '/admin/exampaper/' + id + "/" : '/admin/exampaper/',
             method = id ? 'put' : 'post'
 
-        form.on('submit(component-form-element)', function (data) {
+        form.on('submit(component-form-element)', function(data){
 
-            admin.req({
-                url: url
-                , data: data.field
-                , type: method
-                , done: function (res) {
-                    if (res.code != 0) {
-                        layer.msg(res.msg);
-                    } else {
-                        layer.open({
-                            type: 1
-                            , content: '<div style="padding: 20px 100px;">保存成功</div>'
-                            , btn: '关闭'
-                            , btnAlign: 'c' //按钮居中
-                            , shade: 0 //不显示遮罩
-                            , yes: function () {
-                                parent.layer.closeAll('iframe');
-                                parent.layui.table.reload('exam_question_datagrid', {});
-                            }
-                        });
-                    }
-                }
-            });
-            return false;
+          admin.req({
+            url: url
+            , data: data.field
+            , type: method
+            ,done: function(res){
+                parent.layui.onSubmitChild(res.data);
+            }
+          });
+
+          return false;
         });
 
         parent.layui.submitChild = function () {

+ 2 - 2
uis/admin/exampaper/index.html

@@ -133,12 +133,12 @@
 
         table.render({
             elem: '#exam_question_datagrid'
-            , url: '/admin/examquestion/'
+            , url: '/admin/exampaper/'
             , cols: [[
                 {title: '编号', type: 'numbers'}
                 , {field: 'name', title: '名称', width: 200}
                 , {field: 'type_text', title: '类型', width: 80}
-                , {field: 'subject_text', title: '科目', width: 120}
+                , {field: 'subject_name', title: '科目', width: 120}
                 , {field: 'question_total_scores', title: '总分', width: 80}
                 , {field: 'passline', title: '及格线', width: 80}
                 , {field: 'create_user_text', title: '添加人', width: 100}