Compare commits

...

376 Commits

Author SHA1 Message Date
huang d472eb23cb 迁移加速 2017-10-31 17:01:35 +08:00
huang c2c1795ff3 实训性能的一些优化 2017-10-31 16:54:38 +08:00
huang f90ccb0651 Merge branch 'develop' into dev_lock 2017-10-31 16:08:47 +08:00
huang b0a86061d8 添加迁移 2017-10-31 15:28:39 +08:00
cxt ae5a6e7620 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-31 14:55:04 +08:00
cxt ac1d0e2084 实训作品的删除 2017-10-31 14:54:51 +08:00
cxt 75a8e98e43 试卷选用中有包含以前的问卷数据 2017-10-31 14:22:24 +08:00
huang a814236ddb Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-31 11:25:29 +08:00
huang 106c326401 删除myshixun的时候关联删除分数 2017-10-31 11:24:45 +08:00
cxt f788ab11aa 实训作业的迁移 2017-10-31 11:24:41 +08:00
cxt d57831a8da 实训作业的查看弹框 2017-10-31 10:11:13 +08:00
daiao 449eabe8cb Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-31 09:32:53 +08:00
daiao 9ea90fafca 实训评测端口映射优化 2017-10-31 09:32:40 +08:00
cxt 0caea10421 导出列表的发布时间 2017-10-31 09:28:28 +08:00
cxt 9c826daa5e 实训作业列表的发布时间 2017-10-31 09:25:51 +08:00
huang 1d1311f80a Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 18:15:05 +08:00
huang 27f6132522 Merge branch 'dev_lock' into develop 2017-10-30 18:14:52 +08:00
huang 15a0370314 解决实训被重复开启bug 2017-10-30 18:14:31 +08:00
cxt 0fa3c92971 实训迁移 2017-10-30 17:58:30 +08:00
daiao f869ebec17 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 17:24:59 +08:00
daiao 2d350f171c 实训作业通关样式调整 2017-10-30 17:24:44 +08:00
cxt 3f336f7721 rake迁移失败 2017-10-30 16:40:44 +08:00
cxt 4062c274f0 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 16:35:01 +08:00
cxt b7a626b8cf 实训作业的延时提交重新计算 2017-10-30 16:33:01 +08:00
daiao ba380f88cc 选择题测试集点不开 2017-10-30 16:22:05 +08:00
daiao 3579bb831c 评测通过下一关报错 2017-10-30 16:16:48 +08:00
daiao 8f41e4a7fa 新建实训Java语言修改 2017-10-30 16:10:52 +08:00
daiao ccde58e4b0 选择题通关更新mushixun的status 2017-10-30 16:06:36 +08:00
daiao 70aa99e167 实训作业增加通关数 2017-10-30 14:59:04 +08:00
daiao 598b780536 TPM实践任务的关卡编辑测试集文字“锁定”改为“隐藏” 2017-10-30 14:51:06 +08:00
daiao 78bfbfa6ca Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 14:43:37 +08:00
daiao 50213f880f 课堂实训作业列表增加“通关”人数显示 2017-10-30 14:43:19 +08:00
cxt 6fe67b38cd Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 14:21:03 +08:00
cxt 4ac843010e 实训作业设置的提示 2017-10-30 14:20:49 +08:00
huang 3018e38330 删除myshixun的时候删除对应的gitlab数据 2017-10-30 11:32:18 +08:00
huang ecd551f150 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 11:17:44 +08:00
huang e7d75c2e34 实训添加删除功能 2017-10-30 11:17:19 +08:00
cxt 85a80302f9 课堂助教“新建”试卷,助教报没有权限 2017-10-30 10:56:27 +08:00
XuCheng642 96f4200bf7 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 10:25:11 +08:00
XuCheng642 94faccbb2d 实名认证搜索 2017-10-30 10:24:42 +08:00
caishi 5c4fa0248c Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-30 10:15:10 +08:00
caishi 7ccd9a525a Merge branch 'dev_cs' into develop 2017-10-30 10:14:40 +08:00
caishi e2146c2de7 开始实战没有触发a标签的点击事件 2017-10-30 10:14:11 +08:00
caishi ef1680d39b 平台讨论区的帖子列表时间显示文字错误 2017-10-30 08:59:29 +08:00
daiao d34611fb63 修复缺陷 2017-10-29 17:30:49 +08:00
daiao 6c5e000bea Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-29 17:27:27 +08:00
daiao 5398234df8 textarea以换行开头会被浏览器去除 2017-10-29 17:27:08 +08:00
caishi b0e46ec3a3 试卷页面相关地址栏的显示 2017-10-29 15:53:02 +08:00
caishi 460bb10012 Merge branch 'develop' into dev_cs 2017-10-29 15:06:28 +08:00
caishi 9ffd338c61 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-29 15:05:51 +08:00
caishi 8a92602621 作业问答tip 2017-10-29 15:05:10 +08:00
huang 4c292cfae8 解决更新问题 2017-10-27 22:00:58 +08:00
huang 7fb98696f6 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 21:49:46 +08:00
huang 2f5894c631 修复路径修改问题 2017-10-27 21:49:02 +08:00
caishi 7fd851a0ed Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 21:07:15 +08:00
caishi b0c4f8888b 点赞 2017-10-27 21:06:41 +08:00
huang 47f68922b5 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 20:57:55 +08:00
caishi 2cf6ce877a Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 20:51:05 +08:00
caishi 09305539e6 预期输入 2017-10-27 20:50:32 +08:00
XuCheng642 3adc8ca7b0 Merge branch 'dev_xucheng' into develop 2017-10-27 20:49:16 +08:00
XuCheng642 bde8ba266e Merge branch 'develop' into dev_xucheng 2017-10-27 20:48:13 +08:00
XuCheng642 56c2f6af3d Merge remote-tracking branch 'remotes/origin/dev_cs' into dev_xucheng
Conflicts:
	app/views/users/search_shixuns_or_courses.html.erb
2017-10-27 20:45:43 +08:00
huang 052fbdcb74 修复弹框及空白的问题 2017-10-27 20:39:49 +08:00
huang e1adeb2b19 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 20:22:45 +08:00
huang f89eabff47 解决版本库看不到的问题 2017-10-27 20:22:30 +08:00
caishi 2685375df5 弹框 2017-10-27 20:20:18 +08:00
caishi 4b07507946 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 20:16:43 +08:00
caishi 910cb83a54 测试集更新按钮 2017-10-27 20:16:01 +08:00
huang a811f4466d Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 20:01:44 +08:00
huang c682cd75aa 添加 2017-10-27 20:00:54 +08:00
caishi 83b6cc945e Merge branch 'develop' into dev_cs 2017-10-27 19:52:37 +08:00
caishi 1cdfa6ae77 实训作业设置按钮 2017-10-27 19:52:08 +08:00
caishi ca8e7a5ed7 提示显示 2017-10-27 19:27:01 +08:00
caishi 8e0458c5e1 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 19:10:20 +08:00
huang 4c5c469940 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 19:06:47 +08:00
huang 63ab9a9029 代码不见了的问题 2017-10-27 19:06:35 +08:00
caishi 93337ba6b5 按钮 2017-10-27 19:04:06 +08:00
cxt cd4383b48e 作业设置中的立即截止和立即发布 2017-10-27 18:53:06 +08:00
huang 47695f506a Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 18:35:15 +08:00
huang 097feaa991 实训测试集及测试路径修改更新 2017-10-27 18:35:01 +08:00
daiao 30fe6332cc 文本对比样式调整 2017-10-27 18:30:08 +08:00
daiao 596a030f4c codemirror行号背景颜色调整 2017-10-27 18:25:17 +08:00
huang a63f953fcd Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 17:50:39 +08:00
huang e8cb855556 更新测试用例及评测路径后一些列的操作 2017-10-27 17:50:24 +08:00
cxt 8cb8176381 Merge branch 'dev_cs' into develop 2017-10-27 17:29:24 +08:00
caishi 084315c714 测试集 2017-10-27 17:28:28 +08:00
cxt dd2d4279d5 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 17:27:19 +08:00
cxt b4f253c1ec 题库选用的单选多选答案未导入成功 2017-10-27 17:27:05 +08:00
caishi b930bbbee5 Merge branch 'develop' into dev_cs
Conflicts:
	app/views/student_work/index.html.erb
	public/stylesheets/css/edu-common.css
2017-10-27 17:04:53 +08:00
caishi ee7d95ad6c 测试集更新提示弹框 2017-10-27 17:00:37 +08:00
daiao a161e839fb 文本对比样式调整 2017-10-27 16:48:39 +08:00
daiao a747cf6f62 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 16:08:32 +08:00
daiao a822a4f7ea 评测样式调整 2017-10-27 16:08:07 +08:00
cxt 60c9a5837c Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-27 15:22:13 +08:00
cxt e2c8fe70c4 Merge branch 'dev_cs' into develop 2017-10-27 15:21:22 +08:00
cxt 99323cccc0 Merge branch 'dev_cxt' into develop 2017-10-27 15:20:38 +08:00
daiao b544afbc42 对比文本样式调整 2017-10-27 15:20:27 +08:00
cxt ebab6b4b3a 试卷从题库导入 2017-10-27 15:19:43 +08:00
cxt 66c67f380b 实训统计归到导出成绩中 2017-10-27 14:35:27 +08:00
daiao 0525bdcdb7 评测测试集去除滚轮按钮 2017-10-27 11:06:11 +08:00
cxt cee9c47ebc 已结束的试卷在主观题上对未答的评阅情况显示不统一 2017-10-27 10:22:33 +08:00
caishi 1b95c2fe40 Merge branch 'develop' into dev_cs
Conflicts:
	app/views/games/_game_show.html.erb
2017-10-27 09:20:43 +08:00
cxt 81739f7330 Merge branch 'develop' into dev_cxt 2017-10-27 09:12:58 +08:00
daiao 6e15ff55ea Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-26 21:03:02 +08:00
cxt 1bab4fc5ad 超级管理员在课堂的“实训统计”由全部实训作业导出更换成单个实训作业导出 2017-10-26 21:02:50 +08:00
daiao 2e901e4d0c 测试集乱码的原因 2017-10-26 21:02:32 +08:00
caishi 2a2748827b 更新提示 2017-10-26 20:48:47 +08:00
cxt 59f039c222 Merge branch 'develop' into dev_cxt
Conflicts:
	app/views/exercise/_exercise_setting.html.erb
2017-10-26 19:51:14 +08:00
cxt e4356c9636 试卷中多选题保存后进行编辑,删除已选定的参考答案,保存成功 2017-10-26 19:44:39 +08:00
huang 9f6549c822 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-26 19:40:14 +08:00
huang 3fe24bdb3c 还原 2017-10-26 19:35:10 +08:00
daiao 20708267b0 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-26 19:30:55 +08:00
daiao 26533c84e0 评测时间动态产生 2017-10-26 19:30:12 +08:00
huang c324d68ccc Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-26 19:20:05 +08:00
huang cbb8861668 自动化修复代码重置的问题 2017-10-26 19:19:53 +08:00
daiao 5af4b8fb80 评测时间随机产生 2017-10-26 19:14:17 +08:00
daiao fdf38291ff Merge branch 'dev_daiao' into develop 2017-10-26 18:26:35 +08:00
daiao 54238085d7 评测JS报错 2017-10-26 18:25:36 +08:00
cxt 077eae9b95 实训tpm的按钮tip修改 2017-10-26 17:33:01 +08:00
huang a9bd9554bc Merge branch 'dev_daiao' into develop 2017-10-26 17:32:31 +08:00
daiao 9721857fb2 隐藏测试集不显示的问题 2017-10-26 17:27:29 +08:00
daiao 75d4d795e6 点击测试集报错 2017-10-26 17:20:31 +08:00
cxt 058623a2cc 试卷加入题库 2017-10-26 17:06:01 +08:00
daiao 2804f7648e Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-26 16:24:44 +08:00
daiao a91a3e5b84 测试集加入日志 2017-10-26 16:24:13 +08:00
huang 205c7fed7f Merge branch 'develop' into dev_daiao 2017-10-26 15:56:19 +08:00
daiao 27c4d8f3ac 文本对比缺陷修复 2017-10-26 15:38:26 +08:00
daiao 0284b0659c Merge branch 'dev_codemirror' into dev_daiao 2017-10-26 15:22:42 +08:00
daiao 30828867bd 轮训时间修改为20S 2017-10-26 13:54:39 +08:00
huang 5812178b0e Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-26 09:10:00 +08:00
huang 16abad387e 消息结构一些初始化修改 2017-10-26 09:09:33 +08:00
daiao c32136860c 重新评测的轮训,resubmit值相同 2017-10-26 09:07:03 +08:00
daiao 303e169038 重新评测修改数据库状态 2017-10-25 21:56:58 +08:00
daiao 0aa7434c74 所有页面请增加左侧功能条 2017-10-25 14:41:12 +08:00
caishi dc6fe9aa51 实训tpm的“开始挑战”按钮增加js效果,突出显示 2017-10-25 14:16:01 +08:00
daiao ea5d714a96 codemirror文本对比完整版 2017-10-25 14:04:49 +08:00
XuCheng642 14f961b039 用户搜索 2017-10-25 10:56:37 +08:00
daiao 93c544df2b 评测引入第一次评测参数 2017-10-25 09:36:55 +08:00
caishi 1fed6703a2 查看实战 2017-10-25 09:35:48 +08:00
daiao c9d61584a4 codemirror放入数据 2017-10-25 09:33:57 +08:00
cxt f651dfba29 课堂左侧导航栏的数字为0,不显示 2017-10-25 09:32:11 +08:00
daiao 6d7b26e2e0 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-25 09:18:02 +08:00
daiao dc1eb04517 加入第一次评测参数 2017-10-25 09:17:48 +08:00
daiao d8d15dfbde codemirror完整版 2017-10-24 19:57:08 +08:00
XuCheng642 7a078db79d Merge branch 'develop' into dev_xucheng 2017-10-24 19:39:00 +08:00
XuCheng642 94fea202d8 Merge branch 'dev_xucheng' into develop 2017-10-24 19:37:50 +08:00
XuCheng642 28f842ded1 Merge branch 'develop' into dev_xucheng 2017-10-24 19:37:26 +08:00
XuCheng642 41b0912808 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-24 19:36:01 +08:00
XuCheng642 41d8f5451d Merge branch 'dev_xucheng' into develop 2017-10-24 19:35:30 +08:00
XuCheng642 5a21911eab 超级管理员界面实训成员列表,实训作业,图片删除 2017-10-24 19:33:34 +08:00
caishi 23e6567b31 问题修复弹框 2017-10-24 17:32:57 +08:00
caishi bed258651f code 2017-10-24 17:26:23 +08:00
daiao 854e94aac7 点完继续等待,这个tip还留在页面上了 2017-10-24 15:22:57 +08:00
daiao 835c48e293 测试输入与实际输入之间的文本差异 2017-10-24 14:30:40 +08:00
huang 0a2e0f294a 实训添加Hadoop类型 2017-10-24 14:21:53 +08:00
huang 7dd990dd05 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-24 14:17:35 +08:00
huang cf16b43f5b 问题修复样式更新 2017-10-24 14:17:12 +08:00
caishi 78b0063877 评论 2017-10-24 11:07:05 +08:00
caishi 24284ccf86 倒计时 2017-10-24 10:47:09 +08:00
daiao 2b44349318 评测等待时间修改为: 等待人数 * 10(秒) 2017-10-24 09:06:08 +08:00
daiao 90382794af 评测优化 2017-10-23 20:33:53 +08:00
daiao 01f41526e9 评测进入下一关还原成之间的版本 2017-10-23 17:03:28 +08:00
daiao 12810e2489 评测优化 2017-10-23 17:00:47 +08:00
caishi 9c968a0e03 codemirror 2017-10-23 16:26:23 +08:00
caishi ed2fb29f0f Merge branch 'develop' into dev_codemirror 2017-10-23 16:23:33 +08:00
caishi f201ddf4a1 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop
Conflicts:
	public/stylesheets/css/common.css
2017-10-23 16:22:59 +08:00
caishi 72efe60035 倒计时 2017-10-23 16:20:37 +08:00
cxt 45601cf2c1 作业中,鼠标点击评分框中后回车,会进行一次评分提交 2017-10-23 16:07:14 +08:00
cxt 38a742312a 在线课堂成员列表的“作业成绩”更换成“课堂成绩” 2017-10-23 15:14:25 +08:00
cxt f493c6f42f 课堂作业、试卷列表显示顺序 2017-10-23 14:52:50 +08:00
huang 524225d17e 评测的时候添加can able参数 2017-10-22 15:29:01 +08:00
huang 0f169c5896 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao
Conflicts:
	app/controllers/games_controller.rb
2017-10-22 15:09:33 +08:00
huang 78ea65cc59 评测提交 2017-10-22 15:08:08 +08:00
daiao 376ce4aa20 点击下一关报500 2017-10-21 14:21:44 +08:00
daiao 50ba113a17 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-21 10:24:51 +08:00
daiao 4a66e6fc90 getwaitingtime加入日志 2017-10-21 10:24:39 +08:00
cxt 56cc2beda9 样式合并 2017-10-20 22:51:07 +08:00
cxt a652cd8336 Merge branch 'dev_cxt' into dev_daiao
Conflicts:
	app/views/files/_hidden_file.html.erb
	app/views/shixuns/_form.html.erb
	app/views/shixuns/_settings_edit.html.erb
	public/stylesheets/css/edu-common.css
2017-10-20 22:46:57 +08:00
cxt 8a18d4aee8 适用课程的调整 2017-10-20 22:42:48 +08:00
daiao 6e8d071441 Merge branch 'dev_cs' into dev_daiao
Conflicts:
	app/views/files/_resource_detail.html.erb
2017-10-20 22:36:34 +08:00
caishi f2b0307d2e 实训路径 2017-10-20 22:32:16 +08:00
cxt f1d8419a43 个人成长记录中心的调整 2017-10-20 22:27:30 +08:00
cxt 1df9b12ee9 资源描述 2017-10-20 22:20:17 +08:00
cxt 090e052132 Merge branch 'dev_cxt' into dev_daiao 2017-10-20 21:18:26 +08:00
caishi 6d09021cce mr 2017-10-20 21:17:15 +08:00
caishi 27bf0d93e0 样式修改 2017-10-20 21:09:53 +08:00
caishi 41a036df76 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 21:09:31 +08:00
cxt 68bf4b481b 遮罩层 2017-10-20 21:05:47 +08:00
cxt 95ccd144a7 答题时的图片显示 2017-10-20 20:56:40 +08:00
cxt ca7a6d6238 作业动态页面点击提交作品的人员或更多应该跳转到作品列表而不是作业问答 2017-10-20 20:51:57 +08:00
cxt b90c2b4846 TA人的主页,经验值和金币应该可以点击查看 2017-10-20 20:47:50 +08:00
caishi a68e4a0fc8 资源设置 2017-10-20 20:37:20 +08:00
cxt 9f2c0404d4 课堂试卷、普通作业的选用弹框修正 2017-10-20 20:25:17 +08:00
daiao 7e777b8e60 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 19:47:59 +08:00
daiao 4d2b13d5b7 评测样式缺陷 2017-10-20 19:47:42 +08:00
caishi 0079798e8a 问题修复弹框 2017-10-20 19:45:00 +08:00
caishi 85cae8cd90 Merge branch 'dev_cs' into dev_daiao 2017-10-20 19:25:24 +08:00
huang c95ed6b6e1 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 19:24:05 +08:00
caishi 88cc5720bc 作业设置 2017-10-20 19:24:02 +08:00
huang 51c3206e2e 提示语句修改 2017-10-20 19:23:49 +08:00
daiao ff958807ab Merge branch 'dev_cxt' into dev_daiao
Conflicts:
	app/views/student_work/index.html.erb
2017-10-20 19:07:08 +08:00
caishi 6bfa745f2e Merge branch 'dev_cs' into dev_daiao
Conflicts:
	app/views/games/_shixun_comment_list.html.erb
	app/views/shixuns/_shixun_reply_detail.html.erb
2017-10-20 19:05:06 +08:00
caishi 893f1f852c 评测 输出显示 2017-10-20 19:01:47 +08:00
huang fd76265ddb Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 17:21:39 +08:00
huang 9b67fa123e 修复更新代码的一些问题 2017-10-20 17:21:01 +08:00
daiao 922b79c57e Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 17:04:51 +08:00
daiao 9babd79739 file_update跟新版本库增加日志 2017-10-20 17:04:20 +08:00
caishi bd812e1698 试卷详情页面的地址栏和答题页面的地址栏显示不一致,应该显示数值 2017-10-20 16:43:30 +08:00
huang 8ac9758c69 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 16:39:40 +08:00
huang c791b21566 修复tpi地址不一致问题;问题修复添加异常处理 2017-10-20 16:39:23 +08:00
cxt 800c9a5722 基本资料的单位名称列表,请按照拼音顺序排列 2017-10-20 16:19:27 +08:00
daiao a60d1f8bca 评测中pull版本库失败后,页面提示实训云平台繁忙(繁忙等级:81),请稍后刷新并重试 2017-10-20 15:56:52 +08:00
daiao e712a6a557 output表加入公开和隐藏的测试集存储 2017-10-20 15:41:20 +08:00
caishi 7bfb06b881 创建实训时选择适用课程,双击输入框两次后,下拉框就不显示数据 2017-10-20 15:33:59 +08:00
daiao ee29d38315 增加调试信息 2017-10-20 15:29:08 +08:00
daiao 9ae5a1d24f Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-20 14:53:30 +08:00
caishi baa527e6c6 个人成长记录中心 2017-10-20 14:53:22 +08:00
daiao f557cd7d39 评测通过却测试通过的个数为0 2017-10-20 14:53:12 +08:00
huang ba46b6da01 Merge branch 'develop' into dev_daiao 2017-10-20 14:45:57 +08:00
caishi 28bc468d56 奖励金币弹框 2017-10-20 14:45:56 +08:00
miss 4cef107e36 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-20 14:45:36 +08:00
huang e0096d0293 添加实训用户自动挽救功能 2017-10-20 14:45:06 +08:00
daiao 65e72d898b 测试集返回结果的日志 2017-10-20 14:04:25 +08:00
cxt 8c4d4303d5 课堂首页增加试卷动态 2017-10-20 11:26:02 +08:00
daiao 3452a7a1ae training_task_status报错修复 2017-10-20 10:57:19 +08:00
daiao e8bacff399 积分体系优化 2017-10-20 10:46:33 +08:00
daiao d6986bacf3 Merge branch 'develop' into dev_daiao 2017-10-20 10:39:01 +08:00
daiao fc19ad6828 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-20 10:38:48 +08:00
huang 014eeea706 开启实训及评测的时候代码优化 2017-10-20 10:16:50 +08:00
daiao 87558515fe 修改用户金币机制 2017-10-20 10:06:12 +08:00
caishi e3e80ec3ab 评论的奖励按钮 2017-10-20 09:22:06 +08:00
daiao 070a52c194 实训评论样式修复 2017-10-19 18:58:55 +08:00
daiao d1bd048315 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-19 18:49:38 +08:00
daiao 3e5e273d89 实训未发布时,无权限 2017-10-19 18:49:21 +08:00
cxt 2ac95deb2b 实训作业的说明 2017-10-19 18:40:59 +08:00
cxt b35be99cc2 添加学生的改进 2017-10-19 17:12:48 +08:00
huang 2e69b628e7 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-19 16:26:06 +08:00
huang d08acee8dc 添加注释 2017-10-19 16:25:47 +08:00
daiao 48762defdb 评测异常处理更全面 2017-10-19 16:06:29 +08:00
daiao d5c3ed4a01 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-19 15:54:09 +08:00
daiao 6840b6ba59 评测积分体系优化 2017-10-19 15:53:34 +08:00
cxt 35bac7021e 提交作品的时候提示用户浏览器兼容信息 2017-10-19 15:31:34 +08:00
huang 3df1423029 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-19 15:17:03 +08:00
huang cc3606ac14 代码更新问题 2017-10-19 15:16:40 +08:00
cxt fe3b093aee 试卷列表修改 2017-10-19 15:08:54 +08:00
cxt 668adc2b4d Merge branch 'dev_cs' into dev_cxt
Conflicts:
	app/views/exercise/_exercises_list.html.erb
2017-10-19 14:25:31 +08:00
cxt 6d99257362 课堂资源的设置和延期发布合并弹框 2017-10-19 14:23:33 +08:00
daiao 919aaa975e 论坛帖子详情内需要有返回按钮 2017-10-19 11:16:53 +08:00
daiao b93a658a0f 实训选择题tpi页面点击评测信息tab无反应 2017-10-19 11:07:46 +08:00
caishi 444968fb9e 试卷样式 2017-10-19 10:45:34 +08:00
daiao ede0af408b 评测下一关做成全局刷新 2017-10-19 10:41:12 +08:00
caishi 9137081c1a Merge branch 'develop' into dev_cs 2017-10-19 10:39:16 +08:00
caishi 7609020510 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-19 10:39:04 +08:00
daiao 1f33ff17bf 实训tpm删除所有任务后页面只是局部刷新,模拟实战按钮还显示,应该去掉按钮 2017-10-19 10:32:56 +08:00
daiao b6abf61c69 注释评测按钮 2017-10-19 10:19:11 +08:00
daiao e399ae9823 html实训,点击评测后,还是一片白 2017-10-19 10:14:56 +08:00
caishi 9f0e20e97d 试卷列表样式小修改 2017-10-19 09:56:12 +08:00
cxt 17523a8c2d 作业第一次设置时补交设置是允许补交,但是扣分分数是0,应该默认是5分 2017-10-19 09:36:07 +08:00
daiao 23e8a5e579 Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-19 09:31:55 +08:00
daiao cc2c241050 评测机制修改 2017-10-19 09:31:39 +08:00
caishi ea8a1fd99c 选项内容超过五行出现滚动条 2017-10-19 09:30:18 +08:00
cxt e8a367233a 试卷选择题默认应该是4个 2017-10-18 18:04:38 +08:00
forge01 b05aa6a0ac Merge branch 'dev_daiao' of https://bdgit.trustie.net/hushasha/bigdata into dev_daiao 2017-10-18 17:44:21 +08:00
forge01 cf8834b596 修复更新代码的一些问题 2017-10-18 17:41:43 +08:00
daiao 8e5022718c Merge branch 'develop' into dev_daiao 2017-10-18 17:19:49 +08:00
daiao f39e628dcb Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-18 17:19:32 +08:00
forge01 b08ccba873 解决开启实训变量未定义问题 2017-10-18 17:19:03 +08:00
daiao 9682091f96 Merge branch 'develop' into dev_daiao 2017-10-18 17:18:05 +08:00
daiao 62dd1c89be Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-18 17:17:52 +08:00
cxt 121ae8a2ed 在线课堂的成员列表“导出成绩”数据表删除多余数据 2017-10-18 16:36:23 +08:00
forge01 1490d3b07d 实训开启和评测一些参数的修改 2017-10-18 16:21:53 +08:00
cxt 2c0524f00b 班级左侧功能入口为零不显示 2017-10-18 16:18:00 +08:00
daiao 0f796fc208 评测优化 2017-10-18 16:14:35 +08:00
forge01 f6a5532304 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-18 15:35:45 +08:00
forge01 1506241a39 优化代码重置问题 2017-10-18 15:23:03 +08:00
daiao 5a6aa8d265 粘贴未发布的实训中背景环境tab页面和合作者tab页面的链接,可以进入,需要有授权 2017-10-18 15:14:35 +08:00
caishi 075f01fd5a 实训tpm页面的评论tab加高度 2017-10-18 14:56:21 +08:00
daiao 35bbaca6fb 异常处理 2017-10-18 14:44:53 +08:00
caishi 0a09199a92 201703新版-第12项--用户列表 2017-10-18 10:43:35 +08:00
daiao fb6312041a getEvaluate抛异常错误 2017-10-18 10:16:01 +08:00
cxt c2c965c8d4 Merge branch 'develop' into dev_cxt
Conflicts:
	app/views/exercise/_exercises_list.html.erb
2017-10-18 09:52:46 +08:00
cxt 22e7e1a08c 职业认证页面输入单位名称时没有选择下拉列表中的单位,点击提交,没有给出提示为什么提交不了 2017-10-18 09:51:49 +08:00
daiao 1ff7a6d7ce 删除日志报错 2017-10-18 09:48:41 +08:00
cxt 6ef214545c 试卷列表的顺序按照试卷发布时间来排序,学生和教师看到的一样 2017-10-18 09:43:15 +08:00
cxt c64431c71a 试卷已截止,学生查看自己和他人的试卷,没有显示试卷答题的对错、获得分数以及答案 2017-10-18 09:30:37 +08:00
cxt b16a8c67cd 测验列表的调整 2017-10-18 09:22:04 +08:00
daiao cdad110424 评测get_waiting_time优化 2017-10-18 09:15:51 +08:00
cxt dfca7d00f7 有未设置标准答案的试卷导入提示 2017-10-17 18:21:00 +08:00
daiao 4b75fcbd45 实训tpi中评论上传图片需要做等比例缩放,且需要做鼠标点击图片放大功能 2017-10-17 17:56:38 +08:00
cxt 68f46623c9 试卷导入报500 2017-10-17 17:46:45 +08:00
miss a7972fb9d0 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-17 17:43:11 +08:00
cxt c687803745 实训作业中导出成绩后的内容修改 2017-10-17 17:31:29 +08:00
caishi d64345aed8 下拉框的值 2017-10-17 17:20:51 +08:00
caishi ed827d57db Merge branch 'dev_cs' of https://bdgit.trustie.net/hushasha/bigdata into dev_cs 2017-10-17 16:54:26 +08:00
cxt 2717a19647 Merge branch 'dev_cs' of https://bdgit.trustie.net/hushasha/bigdata into dev_cs 2017-10-17 16:53:21 +08:00
cxt d8fb6743d9 课堂的普通作业、实训作业、试卷增加立即发布和立即截止功能 2017-10-17 16:52:23 +08:00
huang 9cd2377944 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-17 16:47:16 +08:00
huang 1d9f28df2a 解决重置代码为空的问题 2017-10-17 16:46:41 +08:00
caishi 252d803800 Merge branch 'develop' into dev_cs 2017-10-17 16:06:44 +08:00
caishi 76c511d056 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-17 16:06:31 +08:00
caishi a7a997bf3f Merge branch 'dev_cs' into develop 2017-10-17 16:05:29 +08:00
caishi 0aad9b4c13 TPI评论 2017-10-17 16:05:00 +08:00
daiao a9121ff5a3 实训的讨论区请支持换页 2017-10-17 15:44:57 +08:00
caishi 1e10d97c12 资源多版本下载框样式修改 2017-10-17 15:09:00 +08:00
cxt 4e055a198a 实训作业的成绩评分调整 2017-10-17 14:57:53 +08:00
cxt aa75a7cf3f Merge branch 'dev_cs' of https://bdgit.trustie.net/hushasha/bigdata into dev_cs 2017-10-17 14:36:14 +08:00
cxt 5bb4d86d36 实训相关下拉框调整 2017-10-17 14:35:55 +08:00
caishi baf98088af TPM实训关卡完成状态 2017-10-17 14:04:56 +08:00
daiao 3550a95af9 评测优化 2017-10-17 14:00:39 +08:00
caishi 0d0eaa311b TPI评论和在线课堂里面的置顶 2017-10-17 12:14:57 +08:00
daiao f95f54546e code值 2017-10-17 10:50:00 +08:00
daiao 21be18194d get_waiting_time加入调试日志 2017-10-17 10:35:40 +08:00
daiao 5f4313f083 get_waiting_time的异常处理 2017-10-17 10:28:51 +08:00
daiao 153e57ff16 评测异常处理 2017-10-17 10:27:03 +08:00
caishi 942d3a261f 下拉框公用 2017-10-17 10:17:15 +08:00
daiao af595c76d6 流控增加首次测评功能 2017-10-17 10:15:18 +08:00
cxt d59ce31ea1 留言的老数据需要做链接替换处理 2017-10-17 10:01:40 +08:00
caishi 329051286d 个人信息编辑页面的遮罩层,用手机打开时不显示 2017-10-17 09:42:25 +08:00
cxt 95d6305d7f 作业和试卷已发布的状态是显示发布时间,未发布状态显示创建时间 2017-10-17 09:38:23 +08:00
daiao 22805f63f4 恢复 2017-10-17 09:07:31 +08:00
daiao c56f3ad0a3 课堂的普通作业、实训作业、试卷增加立即发布和立即截止功能 2017-10-17 09:05:21 +08:00
cxt e0be3e6c8d 分班列表中增加切换分班功能 2017-10-16 17:46:32 +08:00
daiao dbd8a6af2e 实训增加流控 2017-10-16 17:43:14 +08:00
daiao 629b51669d 评测流控上线 2017-10-16 17:40:04 +08:00
cxt 6009fb8cc8 ke调整 2017-10-16 17:15:24 +08:00
caishi 828d8662a6 z-index 2017-10-16 17:13:49 +08:00
daiao 5eb60a6164 Merge branch 'dev_cs' into dev_daiao 2017-10-16 16:54:40 +08:00
caishi 1e7aadac7b tpi提示 2017-10-16 16:53:55 +08:00
huang c3c04160a1 实训复制添加一个参数 2017-10-16 16:53:50 +08:00
daiao 4ed26c5add 实训评测等待时间 2017-10-16 16:48:49 +08:00
huang 858896ea35 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-16 16:41:25 +08:00
huang 95f2e2952b fork被注释问题 2017-10-16 16:41:05 +08:00
caishi 7fad101caa 讨论区title 2017-10-16 16:29:01 +08:00
huang 117d0be2e6 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-16 16:23:54 +08:00
huang 93666f8270 管理员中添加tpi定位信息 2017-10-16 16:23:35 +08:00
daiao ff8cb16a89 Merge branch 'dev_cs' into dev_daiao 2017-10-16 16:16:42 +08:00
daiao 6fbe20fd37 评测机制优化 2017-10-16 16:14:54 +08:00
caishi f7ddba7eaf tpi输出 2017-10-16 16:13:23 +08:00
daiao 533fc2ec8c Merge branch 'develop' into dev_daiao 2017-10-16 16:06:39 +08:00
daiao 6345d57b46 实训评测机制修改 2017-10-16 16:04:16 +08:00
miss f3d13898d7 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-16 15:36:08 +08:00
miss 96166ab1f3 tpm关卡经验值样式问题 2017-10-16 15:35:15 +08:00
caishi 40ca001376 tpi评测等待弹框 2017-10-16 15:28:27 +08:00
cxt c91c95c6e8 试卷中点击“向下插入xx题”时,光标需要定位到新的题目框中 2017-10-16 14:58:49 +08:00
cxt 4c0792a201 新建试卷时,在试卷标题处按回车试卷信息就保存了 2017-10-16 14:33:55 +08:00
cxt 04403aaf36 Merge branch 'develop' into dev_cxt 2017-10-16 14:27:10 +08:00
daiao 23cd1a7a51 加入流控 2017-10-16 14:26:28 +08:00
daiao 6f80bdf754 Merge branch 'develop' into dev_daiao 2017-10-16 11:43:38 +08:00
caishi ff92f36c25 Merge branch 'develop' into dev_cs 2017-10-16 11:11:24 +08:00
caishi 725db64d11 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-16 11:10:54 +08:00
caishi 0a2629933d Merge branch 'dev_cs' into develop 2017-10-16 11:10:31 +08:00
caishi ec896aa155 颜色 2017-10-16 11:10:04 +08:00
caishi c519ed6b6e 颜色 2017-10-16 11:09:26 +08:00
caishi f2d18c2413 弹框 2017-10-16 11:08:48 +08:00
huang f09bb9034c 开启实训的时候去掉TPMid(两个) 2017-10-15 11:45:33 +08:00
huang 818111cb98 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-15 11:21:28 +08:00
huang cd0a57ead2 评测和开启实训的时候传送tpm脚本 2017-10-15 11:21:09 +08:00
daiao 5d896c4013 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-14 18:17:24 +08:00
daiao 50037f67d1 数据迁移 2017-10-14 18:16:50 +08:00
cxt d1491e232c 隐藏作业说明 2017-10-14 18:06:09 +08:00
daiao 104f43db11 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-14 17:40:50 +08:00
daiao 55dd79e9e1 数据迁移 2017-10-14 17:40:30 +08:00
cxt 93344aa03c Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-14 17:04:10 +08:00
cxt 43d0d3df72 实训作业说明的调整 2017-10-14 16:58:20 +08:00
huang 0668796344 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-14 16:39:12 +08:00
daiao a0e744c7d1 删除前面的迁移 2017-10-14 16:15:06 +08:00
daiao 6753d4e553 数据迁移 2017-10-14 16:02:42 +08:00
daiao 6f97eca2b4 贴吧置顶样式修改 2017-10-14 15:44:49 +08:00
daiao 89e0930761 班级讨论帖子内容过长时,保存后内容显示会截断 2017-10-14 15:42:44 +08:00
daiao 72439844b4 将评测按钮颜色改为蓝色 2017-10-14 14:33:49 +08:00
daiao 44401f0dc9 Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-14 14:27:16 +08:00
daiao fbed428a5e 超级管理员查看他人实训的参考答案后,其本人通过实训后却显示扣分了。 2017-10-14 14:27:01 +08:00
cxt 13e5b6d8ca Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop 2017-10-14 14:23:34 +08:00
cxt 9b92e1c757 实训作业的说明 2017-10-14 14:23:15 +08:00
caishi d6235eb62d Merge branch 'develop' into dev_cs 2017-10-14 10:32:15 +08:00
XuCheng642 f56423aff5 Merge branch 'develop' into dev_xucheng 2017-10-13 23:32:46 +08:00
319 changed files with 8552 additions and 2960 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the exercise_bank controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the question_banks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -73,7 +73,6 @@ class ApplicationController < ActionController::Base
# return
# end
# end
def session_expiration
if session[:user_id]
if session_expired? && !try_to_autologin

View File

@ -365,32 +365,46 @@ class AttachmentsController < ApplicationController
def upload_attachment_version
@flag = false
Attachment.transaction do
@old_attachment = Attachment.find params[:old_attachment_id]
#取出当前上传的文件
@attachment = Attachment.find(params[:attachments ].first[1][:attachment_id])
#将需要修改的记录保存到历史记录
@history = AttachmentHistory.new
@history.attributes = @old_attachment.attributes.dup.except("id", "resource_bank_id")
@history.attachment_id = params[:old_attachment_id]
#需要更新版本号,需要拿到原来该文件最大的历史版本号
@old_history = @old_attachment.attachment_histories.reorder('version desc').first
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
@old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes",'is_publish','publish_time')
@status = @old_attachment.is_publish
# 如果附件描述被修改,则保存附件
unless params[:description] == @attachment.description
@old_attachment.description = params[:description]
@course = Course.find params[:course_id]
@old_attachment = Attachment.find params[:old_attachment_id]
if params[:attachments]
Attachment.transaction do
#取出当前上传的文件
@attachment = Attachment.find(params[:attachments].first[1][:attachment_id])
#将需要修改的记录保存到历史记录
@history = AttachmentHistory.new
@history.attributes = @old_attachment.attributes.dup.except("id", "resource_bank_id")
@history.attachment_id = params[:old_attachment_id]
#需要更新版本号,需要拿到原来该文件最大的历史版本号
@old_history = @old_attachment.attachment_histories.reorder('version desc').first
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
@old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes",'is_publish','publish_time')
@status = @old_attachment.is_publish
@old_attachment.save
#删除当前记录
@attachment.delete
@flag = true
end
@old_attachment.save
#删除当前记录
@attachment.delete
end
# 如果附件描述被修改,则保存
if params[:description] && params[:description].strip() != "" && params[:description] != @old_attachment.description
@old_attachment.description = params[:description]
@flag = true
end
if params[:publish_time] && params[:publish_time] != ""
@old_attachment.publish_time = params[:publish_time]
@old_attachment.is_publish = 0
@flag = true
end
if @old_attachment.is_public == 0 && params[:is_public]
@old_attachment.is_public = 1
@flag = true
end
# tip_attachment_update
@old_attachment.save
respond_to do |format|
format.js
end

View File

@ -1,181 +1,189 @@
#encoding: utf-8
class AvatarController < ApplicationController
include ActionView::Helpers::NumberHelper
#before_filter :set_cache_buster
include AvatarHelper
def upload
# Make sure that API users get used to set this content type
# as it won't trigger Rails' automatic parsing of the request body for parameters
unless request.content_type == 'application/octet-stream'
@source_type = params[:source_type]
@source_id = params[:source_id]
@temp_file = params[:img] || params[:avatar][:image]
if @temp_file.respond_to?(:original_filename)
@image_file = @temp_file.original_filename
#image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
else
@image_file=params[:filename]
end
@is_direct = params[:is_direct]
@auth_type = params[:auth_type]
#base64转换
img_base64_head = 'data:image/jpeg;base64,'
if @temp_file && @temp_file.start_with?(img_base64_head)
@temp_file = StringIO.new(Base64.decode64(@temp_file[img_base64_head.size,@temp_file.size-img_base64_head.size]))
end
else
unless request.raw_post.nil?
@source_type = params[:source_type]
@source_id = params[:source_id]
@temp_file = request.raw_post
@is_direct = params[:is_direct]
@auth_type = params[:auth_type]
if @temp_file.size > 0
if @temp_file.respond_to?(:original_filename)
@image_file = @temp_file.original_filename
#image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
else
@image_file=params[:filename]
end
@temp_file = StringIO.new(@temp_file)
end
end
end
size = @temp_file.size
if @temp_file && (@temp_file.size > 0)
if @temp_file.size > Setting.upload_avatar_max_size.to_i
@status = 1
@msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i))
elsif Trustie::Utils::Image.new(@temp_file).image?
diskfile=disk_filename(@source_type,@source_id)
if @source_type == 'UserAuthentication'
diskfile = disk_auth_filename('UserAuthentication', @source_id, @auth_type)
diskfile1 = diskfile + 'temp'
File.delete(diskfile1) if File.exist?(diskfile1)
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),auth_filename(@source_id,@auth_type))
else
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
end
# 用户头像上传时进行特别处理
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization'|| @source_type == 'Contest' || @source_type == 'UserAuthentication')
diskfile += "temp"
@urlfile += "temp"
end
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
path = File.dirname(diskfile)
unless File.directory?(path)
FileUtils.mkdir_p(path)
end
md5 = Digest::MD5.new
File.open(diskfile, "wb") do |f|
if @temp_file.respond_to?(:read)
@temp_file.rewind
buffer = ""
while (buffer = @temp_file.read(8192))
f.write(buffer)
md5.update(buffer)
end
else
f.write(@temp_file)
md5.update(@temp_file)
end
end
if @source_type == 'UserAuthentication'
elsif @source_type == 'Contest'
Trustie::Utils::Image.new(diskfile,true).compress(900)
else
Trustie::Utils::Image.new(diskfile,true).compress(300)
end
@status = 0
@msg = ''
else
@status = 2
@msg = l(:not_valid_image_file)
logger.error "上传失败: "+@msg
end
end
@temp_file = nil
respond_to do |format|
format.json{
render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html'
return
}
format.js
format.api {
if saved
render :action => 'upload', :status => :created
else
render_validation_errors(@avatar)
end
}
end
end
#add by zjc
#删除图片
def delete_image
@source_type = params[:source_type]
@source_id = params[:source_id]
@source = nil #eval(@source_type).find(@source_id)
c = Object.const_get(@source_type)
if c.respond_to?(:find)
@source = c.find(@source_id)
end
diskfile=disk_filename(@source_type,@source_id)
unless diskfile.nil? || diskfile == ""
path = File.dirname(diskfile)
if File.directory?(path) && File.exist?(diskfile)
# 用户头像进行特别处理
if @source_type == 'User' || @source_type == 'Course' || @source_type == 'Project'
diskfile1 = diskfile + 'temp'
File.open(diskfile1, "wb") do |f|
buffer = "DELETE"
f.write(buffer)
end
else
File.delete(diskfile)
end
end
end
rescue e do
logger.info e.message
end
respond_to do |format|
format.js
format.api {
if saved
render :action => 'upload', :status => :created
else
render_validation_errors(@avatar)
end
}
end
end
private
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
end
#encoding: utf-8
class AvatarController < ApplicationController
include ActionView::Helpers::NumberHelper
#before_filter :set_cache_buster
include AvatarHelper
def upload
# Make sure that API users get used to set this content type
# as it won't trigger Rails' automatic parsing of the request body for parameters
unless request.content_type == 'application/octet-stream'
@source_type = params[:source_type]
@source_id = params[:source_id]
@temp_file = params[:img] || params[:avatar][:image]
if @temp_file.respond_to?(:original_filename)
@image_file = @temp_file.original_filename
#image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
else
@image_file=params[:filename]
end
@is_direct = params[:is_direct]
@auth_type = params[:auth_type]
#base64转换
img_base64_head = 'data:image/jpeg;base64,'
if @temp_file && @temp_file.start_with?(img_base64_head)
@temp_file = StringIO.new(Base64.decode64(@temp_file[img_base64_head.size,@temp_file.size-img_base64_head.size]))
end
else
unless request.raw_post.nil?
@source_type = params[:source_type]
@source_id = params[:source_id]
@temp_file = request.raw_post
@is_direct = params[:is_direct]
@auth_type = params[:auth_type]
if @temp_file.size > 0
if @temp_file.respond_to?(:original_filename)
@image_file = @temp_file.original_filename
#image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
else
@image_file=params[:filename]
end
@temp_file = StringIO.new(@temp_file)
end
end
end
size = @temp_file.size
if @temp_file && (@temp_file.size > 0)
if @temp_file.size > Setting.upload_avatar_max_size.to_i
@status = 1
@msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i))
elsif Trustie::Utils::Image.new(@temp_file).image?
diskfile=disk_filename(@source_type,@source_id)
if @source_type == 'UserAuthentication'
diskfile = disk_auth_filename('UserAuthentication', @source_id, @auth_type)
diskfile1 = diskfile + 'temp'
File.delete(diskfile1) if File.exist?(diskfile1)
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),auth_filename(@source_id,@auth_type))
else
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
end
# 用户头像上传时进行特别处理
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization'|| @source_type == 'Contest' || @source_type == 'UserAuthentication')
diskfile += "temp"
@urlfile += "temp"
end
logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)")
path = File.dirname(diskfile)
unless File.directory?(path)
FileUtils.mkdir_p(path)
end
md5 = Digest::MD5.new
File.open(diskfile, "wb") do |f|
if @temp_file.respond_to?(:read)
@temp_file.rewind
buffer = ""
while (buffer = @temp_file.read(8192))
f.write(buffer)
md5.update(buffer)
end
else
f.write(@temp_file)
md5.update(@temp_file)
end
end
if @source_type == 'UserAuthentication'
elsif @source_type == 'Contest'
Trustie::Utils::Image.new(diskfile,true).compress(900)
else
Trustie::Utils::Image.new(diskfile,true).compress(300)
end
@status = 0
@msg = ''
else
@status = 2
@msg = l(:not_valid_image_file)
logger.error "上传失败: "+@msg
end
end
@temp_file = nil
respond_to do |format|
format.json{
render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html'
return
}
format.js
format.api {
if saved
render :action => 'upload', :status => :created
else
render_validation_errors(@avatar)
end
}
end
end
#add by zjc
#删除图片
def delete_image
@source_type = params[:source_type]
@source_id = params[:source_id]
@source = nil #eval(@source_type).find(@source_id)
if params[:m_delete]
else
c = Object.const_get(@source_type)
if c.respond_to?(:find)
@source = c.find(@source_id)
end
end
diskfile = disk_filename(@source_type,@source_id)
unless diskfile.nil? || diskfile == ""
path = File.dirname(diskfile)
if File.directory?(path)
# 用户头像进行特别处理
if @source_type == 'User' || @source_type == 'Course' || @source_type == 'Project'
diskfile1 = diskfile + 'temp'
File.open(diskfile1, "wb") do |f|
buffer = "DELETE"
f.write(buffer)
end
else
if params[:m_delete] == "1"
diskfile1 = diskfile +"ID"
ApplyUserAuthentication.where(:user_id => @source_id,:auth_type => 1).update_all(:is_delete => true)
File.delete(diskfile1)
elsif params[:m_delete] == "2"
diskfile1 = diskfile +"PRO"
ApplyUserAuthentication.where(:user_id => @source_id,:auth_type => 2).update_all(:is_delete => true)
File.delete(diskfile1)
end
end
end
end
redirect_to identity_authentication_managements_path()
rescue Exception => e
logger.info e.message
respond_to do |format|
format.js
format.api {
if saved
render :action => 'upload', :status => :created
else
render_validation_errors(@avatar)
end
}
end
end
private
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
end

View File

@ -211,7 +211,7 @@ class ChallengesController < ApplicationController
@position = params[:position].to_i
#@challenge_choose = @challenge.challenge_chooses
respond_to do |format|
format.js
format.js
end
end
@ -221,6 +221,10 @@ class ChallengesController < ApplicationController
@challenges = @shixun.challenges
add_shixun_modify_status(@shixun, 1)
@challenge.destroy
respond_to do |format|
format.js
format.html{redirect_to shixun_challenges_path(@shixun)}
end
end
def update
@ -247,6 +251,8 @@ class ChallengesController < ApplicationController
def update_evaluation
ActiveRecord::Base.transaction do
path = @challenge.path
exec_path = @challenge.exec_path
@challenge.update_attributes(params[:challenge])
begin
if params[:tab].to_i == 2
@ -259,8 +265,14 @@ class ChallengesController < ApplicationController
end
end
end
# 向jenkins端发送请求构建公共测试用例
shixun_modify_status_publish(@shixun, 1)
# 向中间层发送请求,构建公共测试用例
# 如果路径被改则需要提醒重置,仅改测试用例不需要提醒重置
add_shixun_modify_status(@shixun, 1)
if path == params[:challenge][:path] && exec_path == params[:challenge][:exec_path]
should_modify_myshixun_script @challenge.shixun, 0
else
should_modify_myshixun_script @challenge.shixun, 1
end
elsif params[:tab].to_i == 5
@challenge_tags.delete_all unless @challenge_tags.blank?
unless params[:knowledge].blank?

View File

@ -106,8 +106,13 @@ class CoursesController < ApplicationController
end
def shixun_statistics
@homeworks = @course.homework_commons.where("homework_type = 4 and publish_time < '#{Time.now}'").order("publish_time desc")
filename="#{format_date(Time.now)}_#{@course.teacher.show_real_name.to_s}_#{@course.name}_实训数据报告";
if params[:homework_id]
@homeworks = @course.homework_commons.where(:id => params[:homework_id])
else
@homeworks = @course.homework_commons.where("homework_type = 4 and publish_time < '#{Time.now}'").order("publish_time desc")
end
#filename="#{format_date(Time.now)}_#{@course.teacher.show_real_name.to_s}_#{@course.name}_实训数据报告";
filename="#{format_date(Time.now)}_#{@course.teacher.show_real_name.to_s}_#{@course.name}_#{@homeworks.first.name}_实训数据报告";
respond_to do |format|
format.xls {
@ -481,6 +486,7 @@ class CoursesController < ApplicationController
if params[:member_ids] && @group
params[:member_ids].each do |member_id|
member = Member.find member_id
@old_group = member.course_group
member.update_attributes(:course_group_id => params[:course_group_id].to_i) if member
end
end
@ -545,10 +551,12 @@ class CoursesController < ApplicationController
AND homework_commons.homework_type in (1, 4)
AND homework_commons.course_id = #{@course.id}
AND student_works.user_id = members.user_id
) AS score FROM members
) AS score,(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id
AND exercises.course_id = #{@course.id} AND exercise_users.user_id = members.user_id) AS ex_score
FROM members
JOIN students_for_courses
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
WHERE members.course_id = #{@course.id} ORDER BY score desc")
WHERE members.course_id = #{@course.id}")
if q.nil? || q == ""
else
members = []
@ -560,6 +568,10 @@ class CoursesController < ApplicationController
end
@members = members
end
@members.each do |member|
member[:course_score] = (member.score.nil? ? 0 : member.score) + (member.ex_score.nil? ? 0 : member.ex_score)
end
@members = @members.sort{|x,y| y[:course_score] <=> x[:course_score] }
#分页
@member_count = @members.count
@all_member_ids = @members.map(&:id).join(",")
@ -594,10 +606,12 @@ class CoursesController < ApplicationController
AND homework_commons.homework_type in (1, 4)
AND homework_commons.course_id = #{@course.id}
AND student_works.user_id = members.user_id
) AS score FROM members
) AS score,(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id
AND exercises.course_id = #{@course.id} AND exercise_users.user_id = members.user_id) AS ex_score
FROM members
JOIN students_for_courses
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
WHERE members.course_id = #{@course.id} AND members.course_group_id = 0 ORDER BY score desc")
WHERE members.course_id = #{@course.id} AND members.course_group_id = 0")
# if @order == "student_id"
# @members = @course.members.where(:course_group_id => 0).joins("join user_extensions on members.user_id = user_extensions.user_id").order("student_id #{@sort}").select{|m| m.roles.to_s.include?("Student")}
# else
@ -614,6 +628,10 @@ class CoursesController < ApplicationController
end
@members = members
end
@members.each do |member|
member[:course_score] = (member.score.nil? ? 0 : member.score) + (member.ex_score.nil? ? 0 : member.ex_score)
end
@members = @members.sort{|x,y| y[:course_score] <=> x[:course_score] }
#分页
@member_count = @members.count
@all_member_ids = @members.map(&:id).join(",")
@ -648,10 +666,12 @@ class CoursesController < ApplicationController
AND homework_commons.homework_type in (1, 4)
AND homework_commons.course_id = #{@course.id}
AND student_works.user_id = members.user_id
) AS score FROM members
) AS score,(SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id
AND exercises.course_id = #{@course.id} AND exercise_users.user_id = members.user_id) AS ex_score
FROM members
JOIN students_for_courses
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
WHERE members.course_id = #{@course.id} AND members.course_group_id = #{@group.id} ORDER BY score desc")
WHERE members.course_id = #{@course.id} AND members.course_group_id = #{@group.id}")
# if @order == "student_id"
# @members = @course.members.where(:course_group_id => @group.id).joins("join user_extensions on members.user_id = user_extensions.user_id").select{|m| m.roles.to_s.include?("Student")}.reorder("student_id #{@sort}")
# else
@ -668,7 +688,10 @@ class CoursesController < ApplicationController
end
@members = members
end
@members.each do |member|
member[:course_score] = (member.score.nil? ? 0 : member.score) + (member.ex_score.nil? ? 0 : member.ex_score)
end
@members = @members.sort{|x,y| y[:course_score] <=> x[:course_score] }
#分页
@member_count = @members.count
@all_member_ids = @members.map(&:id).join(",")
@ -693,7 +716,11 @@ class CoursesController < ApplicationController
def choose_course_group
@member_ids = params[:member_ids].split(",")
@type = params[:type]
@groups = @course.course_groups.order("name asc")
if params[:group_id]
@groups = @course.course_groups.where("id != #{params[:group_id]}").order("name asc")
else
@groups = @course.course_groups.order("name asc")
end
respond_to do |format|
format.js
end
@ -1502,7 +1529,7 @@ class CoursesController < ApplicationController
# course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false)
# course_request_messages.update_all(:viewed => true)
course_activities = @course.course_activities.where("course_act_type in ('HomeworkCommon', 'Attachment', 'Course', 'Message')")
course_activities = @course.course_activities.where("course_act_type in ('HomeworkCommon', 'Attachment', 'Course', 'Message', 'Exercise')")
@canShowRealName = User.current.member_of_course? @course
@page = params[:page] ? params[:page].to_i + 1 : 0
if params[:type].present?
@ -1519,6 +1546,8 @@ class CoursesController < ApplicationController
@course_activities = course_activities.where("course_act_type = 'Message'").order('updated_at desc')
when "poll"
@course_activities = course_activities.where("course_act_type = 'Poll'").order('updated_at desc')
when "exercise"
@course_activities = course_activities.where("course_act_type = 'Exercise'").order('updated_at desc')
when "attachment"
@course_activities = course_activities.where("course_act_type = 'Attachment'").order('updated_at desc')
when "journalsForMessage"
@ -2063,7 +2092,7 @@ class CoursesController < ApplicationController
count_game_test = 0
count_game_time = 0
# end
sheet[current_row, 2] = "# #{j + 1}"
sheet[current_row, 2] = "# #{get_hw_index(homework, true, 4)}"
sheet[current_row, 3] = homework.name
shixun = homework.homework_commons_shixuns.shixun if homework.homework_commons_shixuns
if shixun
@ -2107,19 +2136,19 @@ class CoursesController < ApplicationController
sheet[current_row,7] = "#{count_game_test}次评测"
sheet[current_row,8] = game_spend_time((count_game_time == 0 ? 0 : (count_game_time / count_test)).to_i)+"/次"
sheet.row(current_row).default_format = black
current_row += 1
#current_row += 1
end
sheet[current_row,2] = "合计"
sheet[current_row,4] = "#{game_count}"
sheet[current_row,5] = count_exp_score >= 0 ? "+#{count_exp_score}" : "-#{count_exp_score}"
sheet[current_row,6] = count_gold_score >= 0 ? "+#{count_gold_score}" : "#{count_gold_score}"
sheet[current_row,7] = "#{count_test}次评测"
sheet[current_row,8] = game_spend_time((count_time == 0 ? 0 : (count_time / count_test)).to_i)+"/次"
sheet.row(current_row).default_format = black
# sheet[current_row,2] = "合计"
# sheet[current_row,4] = "共#{game_count}"
# sheet[current_row,5] = count_exp_score >= 0 ? "+#{count_exp_score}" : "-#{count_exp_score}"
# sheet[current_row,6] = count_gold_score >= 0 ? "+#{count_gold_score}" : "#{count_gold_score}"
# sheet[current_row,7] = "共#{count_test}次评测"
# sheet[current_row,8] = game_spend_time((count_time == 0 ? 0 : (count_time / count_test)).to_i)+"/次"
# sheet.row(current_row).default_format = black
end
homeworks.each_with_index do |homework, i|
sheet = book.create_worksheet :name => "#{i+1}次作业"
sheet = book.create_worksheet :name => "关卡统计"
sheet.row(0).default_format = blue
sheet[0,0] = "课堂编号"
sheet[0,1] = "主讲老师"
@ -2137,7 +2166,7 @@ class CoursesController < ApplicationController
sheet[1,0] = course.id
sheet[1,1] = course.teacher.show_real_name
sheet[1,2] = course.name
sheet[1,3] = "# #{i + 1}"
sheet[1,3] = "# #{get_hw_index(homework, true, 4)}"
sheet[1,4] = homework.name
current_row = 1
shixun = homework.homework_commons_shixuns.shixun if homework.homework_commons_shixuns
@ -2221,9 +2250,9 @@ class CoursesController < ApplicationController
end
sheet1[6,homeworks.count+4] = "作业得分"
sheet1[6,homeworks.count+5] = "测评得分"
sheet1[6,homeworks.count+6] = "社区得分"
sheet1[6,homeworks.count+7] = "总得分"
sheet1[6,homeworks.count+8] = "分班"
#sheet1[6,homeworks.count+6] = "社区得分"
sheet1[6,homeworks.count+6] = "总得分"
sheet1[6,homeworks.count+7] = "分班"
count_row = 7
members.each_with_index do |member, i|
sheet1[count_row,0]= i+1
@ -2241,13 +2270,13 @@ class CoursesController < ApplicationController
end
hw_score = member.score.nil? ? 0 : member.score
ex_score = member.ex_score.nil? ? 0 : member.ex_score
act_score = member.act_score.nil? ? 0 : member.act_score
sum = hw_score + ex_score + act_score
#act_score = member.act_score.nil? ? 0 : member.act_score
sum = hw_score + ex_score
sheet1[count_row,homeworks.count+4] = hw_score.round(2)
sheet1[count_row,homeworks.count+5] = ex_score
sheet1[count_row,homeworks.count+6] = act_score
sheet1[count_row,homeworks.count+7] = sum.round(2)
sheet1[count_row,homeworks.count+8] = member.course_group_id == 0 ? "暂无" : member.course_group.name
#sheet1[count_row,homeworks.count+6] = act_score
sheet1[count_row,homeworks.count+6] = sum.round(2)
sheet1[count_row,homeworks.count+7] = member.course_group_id == 0 ? "暂无" : member.course_group.name
count_row += 1
end

View File

@ -0,0 +1,254 @@
#encoding: utf-8
class ExerciseBankController < ApplicationController
include ExerciseHelper
before_filter :require_login, :only => [:show, :new, :create, :edit, :update, :destroy]
before_filter :find_exercise_bank, :only => [:show, :edit, :update, :destroy, :set_public, :create_exercise_question, :update_question_num]
def show
@is_admin = User.current == @exercise.user || User.current.admin?
respond_to do |format|
format.html{render :layout => 'base_edu'}
end
end
def new
@exercise = ExerciseBank.new
respond_to do |format|
format.html{render :layout => 'base_edu'}
end
end
def create
if params[:exercise]
exercise = ExerciseBank.new
exercise.name = params[:exercise][:name]
exercise.description = params[:exercise][:description]
exercise.user_id = User.current.id
exercise.is_public = 0
exercise.quotes = 0
exercise.container_type = "Exercise"
unless params[:course_list].blank?
if CourseList.where(:name => params[:course_list].strip).count > 0
exercise.course_list_id = CourseList.where(:name => params[:course_list].strip).first.id
else
course_list = CourseList.create(:name => params[:course_list].strip, :user_id => User.current.id, :is_admin => 0)
exercise.course_list_id = course_list.id
end
end
if exercise.save
QuestionBank.create(:name => exercise.name, :container_id => exercise.id, :container_type => exercise.container_type, :quotes => exercise.quotes, :user_id => exercise.user_id, :is_public => exercise.is_public,
:course_list_id => exercise.course_list_id)
@exercise = exercise
respond_to do |format|
format.js
end
end
end
end
def edit
respond_to do |format|
format.html{render :layout => 'base_edu'}
end
end
def update
@exercise.name = params[:exercise][:name]
@exercise.description = params[:exercise][:description]
if params[:course_list].blank?
@exercise.course_list_id = nil
else
if CourseList.where(:name => params[:course_list].strip).count > 0
@exercise.course_list_id = CourseList.where(:name => params[:course_list].strip).first.id
else
course_list = CourseList.create(:name => params[:course_list].strip, :user_id => User.current.id, :is_admin => 0)
@exercise.course_list_id = course_list.id
end
end
if @exercise.save
@question.update_attributes(:name => @exercise.name, :course_list_id => @exercise.course_list_id)
respond_to do |format|
format.js
end
else
render_404
end
end
def create_exercise_question
question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title]
option = {
:question_title => question_title,
:question_type => params[:question_type] || 1,
:question_number => @exercise.exercise_bank_questions.count + 1,
:question_score => params[:question_score]
}
@exercise_questions = @exercise.exercise_bank_questions.new option
# params[:question_answer] 题目选项
if params[:question_answer]
for i in 1..params[:question_answer].count
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
question_option = {
:choice_position => i,
:choice_text => answer
}
@exercise_questions.exercise_bank_choices.new question_option
end
end
# 如果是插入的话那么从插入的这个id以后的question_num都将要+1
if params[:quest_id] != "0"
@is_insert = true
insert_que = ExerciseBankQuestion.find params[:quest_id]
if insert_que
@exercise.exercise_bank_questions.where("question_number>?",insert_que.question_number).update_all("question_number = question_number + 1")
@exercise_questions.question_number = insert_que.question_number + 1
end
end
if @exercise_questions.save
# params[:exercise_choice] 标准答案参数
# 问答题标准答案有三个,单独处理
if @exercise_questions.question_type == 3
for i in 1..params[:exercise_choice].count
standart_answer = ExerciseBankStandardAnswer.new
standart_answer.exercise_bank_question_id = @exercise_questions.id
standart_answer.answer_text = params[:exercise_choice].values[i-1]
standart_answer.save
end
elsif @exercise_questions.question_type == 4
unless params[:exercise_choice] == ""
standart_answer = ExerciseBankStandardAnswer.new
standart_answer.exercise_bank_question_id = @exercise_questions.id
standart_answer.answer_text = params[:exercise_choice]
standart_answer.save
end
else
standart_answer = ExerciseBankStandardAnswer.new
standart_answer.exercise_bank_question_id = @exercise_questions.id
if @exercise_questions.question_type == 1
standart_answer.exercise_bank_choice_id = sigle_selection_standard_answer(params[:exercise_choice])
elsif @exercise_questions.question_type == 2
standart_answer.exercise_bank_choice_id = multiselect_standard_answer(params[:exercise_choice])
end
standart_answer.save
end
respond_to do |format|
format.js
end
end
end
def update_exercise_question
@exercise_question = ExerciseBankQuestion.find params[:exercise_question]
@exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title]
@exercise_question.question_score = params[:question_score]
# 处理选项:如果选了某个选项,那么则要删除之前的选项
if params[:question_answer]
@exercise_question.exercise_bank_choices.each do |answer|
answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
end
for i in 1..params[:question_answer].count
question = @exercise_question.exercise_bank_choices.find_by_id params[:question_answer].keys[i-1]
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
if question
question.choice_position = i
question.choice_text = answer
question.save
else
question_option = {
:choice_position => i,
:choice_text => answer
}
@exercise_question.exercise_bank_choices.new question_option
end
end
end
# 更新标准答案
if params[:exercise_choice]
if @exercise_question.question_type == 3
# 删除不合理的选项
@exercise_question.exercise_bank_standard_answers.each do |answer|
answer.destroy unless params[:exercise_choice].keys.include? answer.id.to_s
end
for i in 1..params[:exercise_choice].count
# 找到对应的标准答案
question_standart = @exercise_question.exercise_bank_standard_answers.find_by_id params[:exercise_choice].keys[i-1]
# 标准答案值
answer_standart = (params[:exercise_choice].values[i-1].nil? || params[:exercise_choice].values[i-1].empty?) ? l(:label_new_answer) : params[:exercise_choice].values[i-1]
if question_standart
question_standart.answer_text = answer_standart
question_standart.save
else
standart_answer_option = {
:answer_text => answer_standart
}
@exercise_question.exercise_bank_standard_answers.new standart_answer_option
end
end
elsif @exercise_question.question_type == 4
answer_standart = @exercise_question.exercise_bank_standard_answers.empty? ? nil : @exercise_question.exercise_bank_standard_answers.first
if params[:exercise_choice] == "" && !answer_standart.nil?
answer_standart.destroy
elsif params[:exercise_choice] != "" && !answer_standart.nil?
answer_standart.answer_text = params[:exercise_choice]
answer_standart.save
elsif params[:exercise_choice] != "" && answer_standart.nil?
standart_answer_option = {
:answer_text => params[:exercise_choice]
}
@exercise_question.exercise_bank_standard_answers.new standart_answer_option
end
else
answer_standart = @exercise_question.exercise_bank_standard_answers.first
answer_standart.exercise_bank_choice_id = @exercise_question.question_type == 1 ? sigle_selection_standard_answer(params[:exercise_choice]) : multiselect_standard_answer(params[:exercise_choice])
answer_standart.save
end
@exercise_question.save
@exercise = @exercise_question.exercise_bank
respond_to do |format|
format.js
end
end
end
def update_question_num
@exercise_question = ExerciseBankQuestion.find params[:ques_id]
exercise_questions = @exercise.exercise_bank_questions
if @exercise_question
if params[:opr] == 'up' && @exercise_question.question_number > 1
@before_que = exercise_questions.where("question_number = #{@exercise_question.question_number - 1}").first
if @before_que && @exercise_question.update_attribute('question_number', @exercise_question.question_number - 1)
@before_que.update_attribute('question_number', @before_que.question_number + 1)
end
elsif params[:opr] == 'down' && @exercise_question.question_number < exercise_questions.count
@after_que = exercise_questions.where("question_number = #{@exercise_question.question_number + 1}").first
if @after_que && @exercise_question.update_attribute('question_number', @exercise_question.question_number + 1)
@after_que.update_attribute('question_number', @after_que.question_number - 1)
end
end
respond_to do |format|
format.js
end
end
end
def delete_exercise_question
@exercise_question = ExerciseBankQuestion.find params[:exercise_question]
@exercise = @exercise_question.exercise_bank
ExerciseBankQuestion.where("question_number>?",params[:quest_num].to_i).update_all("question_number = question_number - 1")
if @exercise_question && @exercise_question.destroy
respond_to do |format|
format.js
end
end
end
private
def find_exercise_bank
@exercise = ExerciseBank.find params[:id]
@question = QuestionBank.where(:container_id => @exercise.id, :container_type => @exercise.container_type).first
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -3,11 +3,13 @@ class ExerciseController < ApplicationController
layout "base_courses"
before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy,
:commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,
:commit_exercise, :commit_answer,:publish_exercise, :end_exercise, :republish_exercise,
:show_student_result,:student_exercise_list, :update_question_num,
:send_to_course, :get_student_uncomplete_question, :edit_question_score, :setting, :set_public,
:ex_setting]
:ex_setting, :add_to_exercise_bank]
before_filter :find_course, :only => [:index,:new,:create]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :create_exercise_question, :publish_exercise, :end_exercise,
:update_question_num, :send_to_course, :edit_question_score, :set_public, :ex_setting]
include ExerciseHelper
def index
@ -18,9 +20,9 @@ class ExerciseController < ApplicationController
#remove_invalid_exercise(@course)
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if @is_teacher
exercises = @course.exercises.order("created_at desc")
exercises = @course.exercises.order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
else
exercises = @course.exercises.where("exercise_status <> 1").order("created_at desc")
exercises = @course.exercises.where("exercise_status <> 1").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
end
if params[:type]
@type = params[:type]
@ -444,19 +446,44 @@ class ExerciseController < ApplicationController
# 发布试卷
def publish_exercise
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
@index = params[:index]
@exercise.exercise_status = 2
@exercise.publish_time = Time.now
if @exercise.save
@exercise.course.members.each do |m|
@exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2)
end
#redirect_to exercise_index_url(:course_id=> @course.id)
respond_to do |format|
format.js
if @exercise.exercise_status == 1 && @exercise.publish_time
@exercise.exercise_status = 2
@exercise.publish_time = Time.now
if @exercise.save
course = @exercise.course
course.student.each do |student|
ExerciseUser.create(:user_id => student.student_id, :exercise_id => @exercise.id, :commit_status => 0)
end
@exercise.course.members.each do |m|
@exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2)
end
if @exercise.course_acts.size == 0
@exercise.course_acts << CourseActivity.new(:user_id => @exercise.user_id,:course_id => @exercise.course_id)
end
end
end
redirect_to student_exercise_list_exercise_path(@exercise)
end
def end_exercise
if @exercise.exercise_status == 2 && @exercise.end_time > Time.now
course = @exercise.course
@exercise.update_attributes(:exercise_status => 3, :end_time => Time.now)
course.student.each do |student|
exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", student.student_id, @exercise.id).first
if exercise_user
if exercise_user.commit_status == 0 && !exercise_user.start_at.nil?
exercise_user.update_attributes(:commit_status => 1, :end_at => Time.now)
end
s_score = calculate_student_score(@exercise, student.student)
exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score && exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
if student.student.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
exercise_user.update_attributes(:subjective_score => 0)
end
end
end
end
redirect_to student_exercise_list_exercise_path(@exercise)
end
# 重新发布试卷
@ -692,8 +719,11 @@ class ExerciseController < ApplicationController
cur_exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current, @exercise.id).first
cur_exercise_user.update_attributes(:status => 1, :commit_status => 1, :end_at => Time.now)
#if @exercise.time && @exercise.time != -1
score = calculate_student_score(@exercise, User.current)
cur_exercise_user.update_attributes(:objective_score => score, :score => score + (cur_exercise_user.subjective_score > 0 ? cur_exercise_user.subjective_score : 0))
score = calculate_student_score(@exercise, User.current)
cur_exercise_user.update_attributes(:objective_score => score, :score => score + (cur_exercise_user.subjective_score > 0 ? cur_exercise_user.subjective_score : 0))
if User.current.exercise_answer.where(:exercise_question_id => @exercise.exercise_questions.where(:question_type => 4).map(&:id)).empty?
cur_exercise_user.update_attributes(:subjective_score => 0)
end
#end
# 答题过程中需要统计完成量
#@uncomplete_question = get_uncomplete_question(@exercise, User.current)
@ -821,16 +851,17 @@ class ExerciseController < ApplicationController
#导入试卷的弹框
def other_exercise
# 查作者是我,或者作者是当前课程的老师,且不在当前课程内的试卷 进行导入
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@r_sort = @b_sort == "desc" ? "asc" : "desc"
# 查作者是我的试卷 进行导入
#@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
#@r_sort = @b_sort == "desc" ? "asc" : "desc"
@search = params[:search] ? params[:search].to_s.strip.downcase : ""
#courses = User.current.courses.not_deleted.select { |course| User.current.allowed_to?(:as_teacher,course)}
#course_ids = courses.empty? ? "(-1)" : "(" + courses.map { |course| course.id}.join(',') + ")"
#none_courses = User.current.courses.where("is_delete = 1 or #{Course.table_name}.id = #{params[:course_id].to_i}")
#none_course_ids = none_courses.empty? ? "(-1)" : "(" + none_courses.map { |course| course.id}.join(',') + ")"
#@exercises = Exercise.where("(user_id = #{User.current.id} or course_id in #{course_ids}) and course_id != #{params[:course_id].to_i} and exercise_name like '%#{@search}%'").order("#{@order} #{@b_sort}")
@exercises = Exercise.where("user_id = #{User.current.id} and exercise_name like '%#{@search}%'").order("#{@order} #{@b_sort}")
if(params[:type].blank? || params[:type] == "1") #我的题库
@exercises = User.current.exercise_banks.where(:container_type => "Exercise")
elsif params[:type] == "2" #公共题库
@exercises = ExerciseBank.where(:container_type => "Exercise", :is_public => true)
end
@type = params[:type] || "1"
@exercises = @exercises.where("name like '%#{@search}%'").reorder("created_at desc")
@course_id = params[:course_id]
@is_remote = true
@ex_count = @exercises.count
@ -866,19 +897,19 @@ class ExerciseController < ApplicationController
course_id = params[:course_id]
@course = Course.find(course_id)
if params[:exercise_id]
exercise = Exercise.find(params[:exercise_id])
exercise = ExerciseBank.find(params[:exercise_id])
option = {
:exercise_name => exercise.exercise_name,
:exercise_name => exercise.name,
:exercise_status => 1,
:user_id => User.current.id,
:show_result => 1,
:course_id => @course.id,
:time => -1,
:exercise_description => exercise.exercise_description
:exercise_description => exercise.description
}
@exercise = Exercise.create option
exercise.exercise_questions.each do |q|
exercise.exercise_bank_questions.each do |q|
option = {
:question_title => q[:question_title],
:question_type => q[:question_type] || 1,
@ -887,23 +918,64 @@ class ExerciseController < ApplicationController
}
@exercise_question = @exercise.exercise_questions.new option
for i in 1..q.exercise_choices.count
for i in 1..q.exercise_bank_choices.count
choice_option = {
:choice_position => i,
:choice_text => q.exercise_choices[i-1][:choice_text]
:choice_text => q.exercise_bank_choices[i-1][:choice_text]
}
@exercise_question.exercise_choices.new choice_option
end
for i in 1..q.exercise_standard_answers.count
for i in 1..q.exercise_bank_standard_answers.count
standard_answer_option = {
:exercise_choice_id => q.exercise_standard_answers[i-1][:exercise_choice_id],
:answer_text => q.exercise_standard_answers[i-1][:answer_text]
:exercise_choice_id => q.exercise_bank_standard_answers[i-1][:exercise_bank_choice_id],
:answer_text => q.exercise_bank_standard_answers[i-1][:answer_text]
}
@exercise_question.exercise_standard_answers.new standard_answer_option
end
end
@exercise.save
@exercise.exercise_questions.where(:question_type => [1, 2, 3]).each do |eq|
if eq.exercise_standard_answers.count == 0
@status = 1
break
end
end
end
end
def add_to_exercise_bank
exercise_bank = ExerciseBank.new(:name => @exercise.exercise_name, :description => @exercise.exercise_description, :user_id => User.current.id, :is_public => @exercise.is_public,
:course_list_id => @exercise.course.try(:course_list_id), :container_id => @exercise.id, :container_type => "Exercise", :quotes => 1)
@exercise.exercise_questions.each do |q|
option = {
:question_title => q[:question_title],
:question_type => q[:question_type] || 1,
:question_number => q[:question_number],
:question_score => q[:question_score]
}
exercise_bank_question = exercise_bank.exercise_bank_questions.new option
for i in 1..q.exercise_choices.count
choice_option = {
:choice_position => i,
:choice_text => q.exercise_choices[i-1][:choice_text]
}
exercise_bank_question.exercise_bank_choices.new choice_option
end
for i in 1..q.exercise_standard_answers.count
standard_answer_option = {
:exercise_bank_choice_id => q.exercise_standard_answers[i-1][:exercise_choice_id],
:answer_text => q.exercise_standard_answers[i-1][:answer_text]
}
exercise_bank_question.exercise_bank_standard_answers.new standard_answer_option
end
end
if exercise_bank.save
@exercise.update_column('exercise_bank_id', exercise_bank.id)
QuestionBank.create(:name => exercise_bank.name, :container_id => exercise_bank.id, :container_type => exercise_bank.container_type, :quotes => exercise_bank.quotes, :user_id => exercise_bank.user_id, :is_public => exercise_bank.is_public,
:course_list_id => exercise_bank.course_list_id)
end
end
@ -1020,4 +1092,9 @@ class ExerciseController < ApplicationController
rescue Exception => e
render_404
end
#是不是课程的老师
def teacher_of_course
render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
end
end

View File

@ -26,7 +26,7 @@ class FilesController < ApplicationController
before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,
:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,
:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,
:search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description, :edit_file_description]
:search_files_in_subfield,:upload_files_menu,:setting,:republish_file,:update_file_description, :edit_file_description]
helper :sort
include SortHelper
@ -103,8 +103,10 @@ class FilesController < ApplicationController
end
end
def file_hidden
def setting
@file = Attachment.find params[:id]
@attachment = @file
@attachment_histories = @file.attachment_histories
@course = Course.find params[:course_id]
respond_to do |format|
format.js

View File

@ -24,7 +24,12 @@ class ForumsController < ApplicationController
@memo,message = cs.create_feedback params,User.current
respond_to do |format|
if !@memo.new_record?
format.html { redirect_to forum_path(@memo.forum) }
if params[:direct]
format.html { redirect_to forums_path() }
else
format.html { redirect_to forum_path(@memo.forum) }
end
# format.html { redirect_to forum_path(@memo.forum) }
else
sort_init 'updated_at', 'desc'
sort_update 'created_at' => "#{Memo.table_name}.created_at",

View File

@ -4,74 +4,100 @@ class GamesController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:file_update]
before_filter :find_myshixun, :only => [:index]
before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :prev_step,:outputs_show, :file_edit, :file_update, :get_waiting_time, :web_display,
:game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice, :sync_codes]
:game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice,
:sync_codes, :myshixun_repair]
before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code, :html_show]
before_filter :allowd_manager
before_filter :allowd_view, :only => [:show]
before_filter :find__shixun_language, :only => [:show, :entry]
include ApplicationHelper
CODES = %W(1 2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z)
require 'open3'
# 同步更新最新代码
# 同步完成后需要更新myshixun的commit_id为实训的commit最新值
# --------------------------
# 新思路有冲突则则重置没有冲突直接pull
# identifier为password---
# --------------------------
def sync_codes
g = Gitlab.client
myshixun_user_login = User.where(:id => @myshixun.user_id).first.try(:login)
myshixun_rep_identifier = Repository.where(:myshixun_id => @myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
gitlab_address = Redmine::Configuration['gitlab_address']
myshixun_domain = Redmine::Configuration['myshixun_domain']
gitlab_myshixun_url = git_myshixun_url(@myshixun, @myshixun.try(:user_id))
shixun = @myshixun.shixun
gitlab_shixun_url = git_shixun_url(shixun, (shixun.try(:fork_from).blank? ? "educoder" : "eduforge"))
if RUBY_PLATFORM =~ /w32/
path = "c:/test/"
else
path = "/home/pdl/myshixun_shell"
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
begin
# 重置代码的时候先保存当前打开文件的代码
# games = @myshixun.games
# games.each do |game|
# current_code = g.files(@myshixun.gpid, game.challenge.try(:path), "master").try(:content)
# if current_code.present?
# game.game_code.update_attribute(:current_code, Base64.decode64(current_code))
# else
# raise("实训云平台繁忙繁忙等级97")
# end
# end
shixun_new_commit = g.commits(@myshixun.shixun.try(:gpid)).first.try(:id)
if @myshixun.commit_id != shixun_new_commit
if @myshixun.reset_time != @myshixun.shixun.try(:reset_time)
flag = 2
else
flag = 0
end
else
flag = 1
end
git_myshixun_url = git_myshixun_url_ip(@myshixun, @myshixun.try(:user_id))
login = @myshixun.shixun.try(:git_login)
git_shixun_url = git_shixun_url_ip(@myshixun.shixun, login)
git_myshixun_url = Base64.urlsafe_encode64(git_myshixun_url)
git_shixun_url = Base64.urlsafe_encode64(git_shixun_url)
params = {tpmID: "#{@myshixun.shixun.try(:id)}", tpiID: "#{@myshixun.try(:id)}", :tpiGitURL => "#{git_myshixun_url}", :tpmGitURL => "#{git_shixun_url}", :commitId => "#{@myshixun.commit_id}", :identifier => "xinhu1ji2qu3", :flag => "#{flag}"}
uri = "#{shixun_tomcat}/bridge/game/resetTpmRepository"
res = uri_exec uri, params
if (res && res['code'] != 0)
@message = "实训云平台繁忙繁忙等级95"
raise("实训云平台繁忙繁忙等级95")
end
# games.each do |game|
# last_current_code = game.game_code.try(:current_code)
# g.edit_file(@myshixun.gpid, :content => last_current_code, :file_path => game.challenge.try(:path), :branch_name => "master", :commit_message => "shixun reset")
# end
shixun_new_commit = g.commits(@myshixun.shixun.try(:gpid)).first.try(:id)
@myshixun.update_column(:commit_id, shixun_new_commit)
@myshixun.update_column(:reset_time, @myshixun.shixun.try(:reset_time))
respond_to do |format|
format.js{ redirect_to myshixun_game_path( @game, :myshixun_id => @myshixun)}
end
rescue Exception => e
@message = e.try(:message)
logger.error(e)
respond_to do |format|
format.js
end
end
script = "cd #{path}
git clone #{gitlab_address.to_s+'/'+myshixun_user_login+'/'+ myshixun_rep_identifier}.git
cd #{myshixun_rep_identifier}/
git remote set-url origin https://#{shixun.fork_from.blank? ? "educoder" : "eduforge"}:xinhu1ji2qu3@#{myshixun_domain}/#{myshixun_user_login}/#{myshixun_rep_identifier}.git
git remote add remote_origin #{gitlab_shixun_url}
#git pull
git pull remote_origin master
if [ $? -eq 0 ];then
echo -e 'git pull succssed'
else
git reset --hard #{@myshixun.commit_id}
git pull remote_origin master
if [ $? -eq 0 ];then
echo -e 'git reset and pull succssed'
else
echo -e 'git reset and pull failed'
fi
fi
git push -f origin master
if [ $? -eq 0 ];then
echo -e 'git push succssed'
else
echo -e 'git push failed'
fi
cd ../
rm -rf #{myshixun_rep_identifier}/"
aFile =File.new(File.join("#{path}","#{@myshixun.identifier}.sh"), "w+")
if aFile
aFile.syswrite(script)
else
logger.error "Unable to open file!"
end
# 出现代码不存在、脚本异常等自动修复
# 88错误的修复等
def myshixun_repair
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
begin
git_myshixun_url = git_myshixun_url_ip(@myshixun, @myshixun.try(:user_id))
git_myshixun_url = Base64.urlsafe_encode64(git_myshixun_url)
params = {tpiID: "#{@myshixun.try(:id)}", :tpiGitURL => "#{git_myshixun_url}", :tpmID => "#{@myshixun.shixun.try(:id)}"}
uri = "#{shixun_tomcat}/bridge/game/solveProblems"
res = uri_exec uri, params
if (res && res['code'] != 0)
@message = "实训云平台繁忙繁忙等级96"
raise("实训云平台繁忙繁忙等级96")
end
respond_to do |format|
format.js{ redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun)}
end
rescue Exception => e
@message = e.try(:message)
logger.error(e)
respond_to do |format|
format.js
end
end
system("sh #{path}/#{@myshixun.identifier}.sh")
# stdin, stdout, stderr = Open3.popen3("sh #{path}/#{@myshixun.identifier}.sh")
shixun_new_commit = g.commits(@myshixun.shixun.try(:gpid)).first.try(:id)
@myshixun.update_column(:commit_id, shixun_new_commit)
sleep(2) # g
respond_to do |format|
format.js{ redirect_to myshixun_game_path( @game, :myshixun_id => @myshixun)}
end
# render :json => {:status => 200}
end
def index
@ -120,6 +146,10 @@ class GamesController < ApplicationController
@shixun = @myshixun.shixun
# 判断tpm是否修改了
@tpm_modified = tpm_is_modified(@myshixun, @shixun.try(:gpid))
unless (@shixun.modify_time.blank? || @myshixun.modify_time.blank? || @shixun.reset_time.blank? || @myshixun.reset_time.blank?)
@tpm_cases_modified = (@shixun.modify_time > @myshixun.modify_time ? true : false)
@tpm_script_modified = (@shixun.reset_time > @myshixun.reset_time ? true : false)
end
# end
@praise_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "Challenge").count
@tread_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "ChallengeTread").count
@ -131,7 +161,9 @@ class GamesController < ApplicationController
@rev = @rev.nil? ? "master" : @rev
@type = params[:type]
challenge_path = @game_challenge.path
@discusses_count = @shixun.discusses.where(:parent_id => nil).count
@discusses_count = @shixun.discusses.count
# 用户选项
#@user_answer = @game.outputs.first.actual_output.split("") unless @st == 0 || @game.outputs.blank?
# 默认打开文件
@ -163,7 +195,7 @@ class GamesController < ApplicationController
@test_sets = test_set_static_data(test_sets)
end
logger.info("#################################{@public_test_sets}")
logger.info("#################################{@test_sets}")
@test_sets_count = test_sets.count
@test_sets_hidden_count = test_sets.blank? ? 0 :test_sets.select{|test_set| test_set.is_public == false}.count
@test_sets_public_count = @test_sets_count - @test_sets_hidden_count
@ -211,10 +243,17 @@ class GamesController < ApplicationController
@g = Gitlab.client
content = params[:content].try(:strip)
code_file = @g.edit_file(@myshixun.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "shixun exec")
unless code_file.blank?
render :json => {:success => "success"}
logger.info("########### branch_name: #{code_file}")
# status为2说明是重新评测
if @game.status == 2
code = CODES.sample(8).join
resubmit = "#{code}_#{@myshixun.id}"
end
unless code_file.blank?
render :json => {:success => "success", :resubmit => resubmit}
end
rescue Exception => e
render :json => {:success => "fail", :contents => "实训云平台繁忙繁忙等级81请稍后刷新并重试", :position => @game.challenge.position}
=begin
respond_to do |format|
format.js
@ -236,36 +275,39 @@ class GamesController < ApplicationController
# 获取评测的等待的时间
# res['waitNum'] 评测等待人数
# res['waitingTime'] 评测等待时间
# res['onRun'] 0 表示在等待中 1 表示可执行
# res['ableToCreate'] 0 表示在等待中 1 表示可执行 -1 表示超过最大等待人数
def get_waiting_time
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
uri = "#{shixun_tomcat}/bridge/game/getWaitingTime"
params = {:tpiID => "#{@myshixun.id}"}
resubmit = @_params['resubmit']
params = {:tpiID => "#{@myshixun.id}", :first => @_params[:first].to_i}
res = uri_exec uri, params
logger.info("############ res: #{res}")
if (res && res['code'] != 0)
@message = "实训云平台繁忙繁忙等级94"
raise("实训云平台繁忙繁忙等级94")
end
render :json => {:result => "success", :onRun => res['onRun'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :resubmit => resubmit }
#render :json => {:result => "success", :onRun => 0, :waitNum => 12, :waitingTime => 1234 }
logger.info("########### get_waiting_time: #{params}")
logger.info("########### ableToCreate : #{res['ableToCreate']}")
render :json => {:result => "success", :ableToCreate => res['ableToCreate'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :position => @game.challenge.position}
#render :json => {:result => "success", :ableToCreate => 1, :waitNum => 10, :waitingTime => 1324 }
rescue Exception => e
render :json => {:result => "failed"}
render :json => {:result => "fail", :contents => '实训云平台繁忙繁忙等级94请稍后刷新并重试', :position => @game.challenge.position}
end
# status 0: 未提交测评或者提交测评失败后报错1中间状态还没返回值2返回值并成功
# resubmit 唯一随机码,为了区分每一次重新评测结果
CODES = %W(1 2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z)
def game_build
#render :json => {:result => "success", :ableToCreate => 1, :waitNum => 13, :port => 41222 }
game_challenge = @game.challenge
shixun = @myshixun.shixun
gitUrl = git_myshixun_url_ip(@myshixun, @myshixun.try(:user_id))
gitUrl = Base64.urlsafe_encode64(gitUrl)
taskId = @game.id
code = CODES.sample(8).join
#code = CODES.sample(8).join
# status为2说明是重新评测
if @game.status == 2
resubmit = "#{code}_#{@myshixun.id}"
resubmit = params[:resubmit]
else
# 重新评测不影响已通关的实训状态
@game.update_attributes!(:status => 1) if resubmit.nil?
@ -275,36 +317,37 @@ class GamesController < ApplicationController
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
step = game_challenge.try(:position)
# 注意:这个地方的参数写的时候不能换行
params = {:tpiID => "#{@myshixun.id}", :buildID => "#{taskId}", :instanceGitURL => "#{gitUrl}", :instanceChallenge => "#{step}", :resubmit => resubmit, :operationEnvironment => "#{shixun.try(:language)}"}
params = {:tpmRepoName => "#{@myshixun.shixun.try(:identifier)}", :commitId => "#{@myshixun.commit_id}", tpmID: "#{shixun.id}", :tpiID => "#{@myshixun.id}", :buildID => "#{taskId}", :tpiGitURL => "#{gitUrl}", :instanceChallenge => "#{step}", :resubmit => resubmit, :operationEnvironment => "#{shixun.try(:language)}", :time => @_params[:first].to_i}
# uri = URI("#{shixun_tomcat}/bridge/game/gameEvaluate")
uri = "#{shixun_tomcat}/bridge/game/gameEvaluate"
res = uri_exec uri, params
logger.info("#####################buildJobForInstance result is #{res}")
logger.info("#####################buildJobForInstance params is #{params}")
if (res && res['code'] != 0)
@message = "实训云平台繁忙繁忙等级86"
raise("实训云平台繁忙繁忙等级86")
end
render :json => {:result => "success", :resubmit => resubmit}
render :json => {:result => "success", :resubmit => resubmit, :ableToCreate => res['ableToCreate'], :waitNum => res['waitNum'], :waitingTime => res['waitingTime'], :position => @game.challenge.position, :port => res['port'] }
rescue Exception => e
if resubmit.nil?
@game.update_attributes!(:status => 0)
end
logger.error("###################" + e.message)
#REDO Jenkins服务异常弹框抛出
render :json => {:result => "failed"}
render :json => {:result => 'fail', :contents =>"实训云平台繁忙繁忙等级86请稍后刷新并重试", :position => game_challenge.position}
end
# @myshixun -status 1:完成实训
# 全部通关奖励1000分
# retry_status 评测的唯一标识,重新评测对以前已产生的结果不造成影响
# params[:resubmit] 不为空表示已通过该关后重新评测, 重新评测必须是通过该关后才能执行
# @had_done 1 通关所有关
# port PHP/Web会有端口号其他语言返回-1
def game_status
game_challenge = @game.challenge
had_done = @game.had_done
resubmit_identifier = @game.resubmit_identifier
shixun = @myshixun.shixun
port = params[:port]
score = 0
tag_count = 0
logger.info("##### resubmit_identifier is #{resubmit_identifier}")
@ -317,8 +360,6 @@ class GamesController < ApplicationController
@game.update_attribute(:end_time, Time.now)
game_passed_code(@game.id, game_challenge.try(:path), @myshixun.try(:gpid), 1)
if !@game.answer_open && shixun.status > 1
reward_grade(@game.user, @game.id, 'Game', game_challenge.score)
reward_experience(@game.user, @game.id, 'Game', game_challenge.score)
score = game_challenge.score
tag_count = game_challenge.challenge_tags.count
elsif shixun.status > 1 && @game.answer_open
@ -382,7 +423,8 @@ class GamesController < ApplicationController
language: @language,
score: score,
tag_count: tag_count,
position: game_challenge.position
position: game_challenge.position,
port: port
}
end
@ -416,6 +458,10 @@ class GamesController < ApplicationController
end
@had_done = @game.had_done
if @right
# 选择题最后一关更新status
if @had_done
@myshixun.update_attribute(:status, 1)
end
@game.update_attributes(:status => 2, :end_time => Time.now)
reward_grade(@game.user, @game.id, 'Game', score)
reward_experience(@game.user, @game.id, 'Game', score)
@ -460,14 +506,17 @@ class GamesController < ApplicationController
end
# 自动推送下一个任务
# 从waiting_time发的请求则有type
def next_step
unless show_next_stage?(@game, @myshixun.shixun.try(:status))
render_403
end
#unless show_next_stage?(@game, @myshixun.shixun.try(:status))
# render_403
#end
next_game = @game.next_game
next_game.update_attributes(:status => 0, :open_time => Time.now) if next_game.status == 3
respond_to do |format|
format.js{ redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun)}
format.html{redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun)}
end
end
@ -497,7 +546,7 @@ class GamesController < ApplicationController
@answer = challenge.answer
end
if challenge.shixun.status < 2 || @game.answer_open || (challenge.st != 0 && @game.status == 2)
if challenge.shixun.status < 2 || User.current.admin? || @game.answer_open || (challenge.st != 0 && @game.status == 2)
@viewed = 1
else
if @score >= 0
@ -555,23 +604,21 @@ class GamesController < ApplicationController
end
def reset_original_code
@g = Gitlab.client
begin
@shixun = @myshixun.shixun
@g = Gitlab.client
game_code = GameCode.where(:game_id => @game.id).first
GameCode.create(:game_id => @game.id) if game_code.blank?
content = game_code.try(:original_code)
if content.nil?
raise("初始代码为空,代码重置失败")
end
@path = params[:path]
@rev = @rev.nil? ? "master" : @rev
message = "file reset"
update_gitlab_file(content, @path, @rev, message)
content = @g.files(@shixun.gpid, @path, @rev).try(:content)
content = tran_base64_decode64(content)
update_gitlab_file(content, @path, @rev, "file reset")
file_content = @g.files(@myshixun.gpid, @path, @rev).content
@content = tran_base64_decode64(file_content)
if @content.nil?
raise("初始代码为空,代码重置失败")
# @entries = @repository.entries(@path, @rev)
end
respond_to do |format|
format.js
@ -626,12 +673,10 @@ class GamesController < ApplicationController
compile_success = (actual_output.blank? || !actual_output.downcase.match(/error/).blank?) ? 0 : 1
public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :input => test_set.input,
:actual_output => actual_output, :output => test_set.output, :compile_success => compile_success}
logger.info("1111#################################{public_result.to_json}")
test_result << public_result.to_json
end
end
test_result = test_result.blank? ? test_result : test_result.join(",")
logger.info("222#################################{test_result}")
return test_result
end

View File

@ -248,6 +248,7 @@ class HomeworkBankController < ApplicationController
private
def find_homework_bank
@homework = HomeworkBank.find params[:id]
@question = QuestionBank.where(:container_id => @homework.id, :container_type => ['Common', 'Shixun']).first
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -9,10 +9,10 @@ class HomeworkCommonController < ApplicationController
before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_homework,:setting,:set_public,:homework_setting,:update_explanation]
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_homework,:end_homework,:setting,:set_public,:homework_setting,:update_explanation]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,
:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
:open_student_works,:add_to_homework_bank,:publish_homework,:update_explanation]
:open_student_works,:add_to_homework_bank,:publish_homework,:end_homework,:update_explanation]
before_filter :member_of_course, :only => [:index,:setting]
def index
@ -31,22 +31,22 @@ class HomeworkCommonController < ApplicationController
end
if @order.blank?
if @is_teacher
@homework_commons = @homework_commons.order("publish_time desc")
@homework_commons = @homework_commons.order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
else
@homework_commons = @homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time desc")
@homework_commons = @homework_commons.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
end
else
case @order
when '1'
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("homework_commons.publish_time desc")
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("IF(ISNULL(homework_commons.publish_time),0,1),homework_commons.publish_time DESC, homework_commons.created_at DESC")
when '3'
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("homework_commons.publish_time desc")
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("IF(ISNULL(homework_commons.publish_time),0,1),homework_commons.publish_time DESC, homework_commons.created_at DESC")
when '4'
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("homework_commons.publish_time desc")
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("IF(ISNULL(homework_commons.publish_time),0,1),homework_commons.publish_time DESC, homework_commons.created_at DESC")
when '5'
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("homework_commons.publish_time desc")
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("IF(ISNULL(homework_commons.publish_time),0,1),homework_commons.publish_time DESC, homework_commons.created_at DESC")
else
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("homework_commons.publish_time desc")
@homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("IF(ISNULL(homework_commons.publish_time),0,1),homework_commons.publish_time DESC, homework_commons.created_at DESC")
end
end
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@ -117,7 +117,7 @@ class HomeworkCommonController < ApplicationController
end
homework.anonymous_comment = 1
homework.homework_type = params[:shixun_homework] ? 4 : (params[:homework_type].to_i || 1)
homework.late_penalty = 0
homework.late_penalty = 5
homework.teacher_priority = 1
homework.user_id = User.current.id
homework.course_id = params[:course]
@ -475,7 +475,7 @@ class HomeworkCommonController < ApplicationController
def update_explanation
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
@homework.update_attribute('explanation', params[:homework_common][:explanation])
redirect_to student_work_index_path(:homework => @homework.id, :tab => 2)
#redirect_to student_work_index_path(:homework => @homework.id, :tab => 2)
end
#加入到题库
@ -533,34 +533,61 @@ class HomeworkCommonController < ApplicationController
end
def publish_homework
if @homework.homework_detail_manual.comment_status > 0
@status = 1
elsif @homework.publish_time.nil?
@status = 2
else
homework_detail_manual = @homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 1)
@homework.update_attributes(:publish_time => Time.now)
@status = 3
if @homework.homework_type != 3
create_works_list @homework
end
if @homework.homework_detail_manual.try(:comment_status) == 0 && @homework.publish_time
@homework.update_attribute("publish_time", Time.now)
@homework.homework_detail_manual.update_attribute('comment_status', 1)
create_works_list @homework
#更新CourseHomeworkStatistics中每个学生的未交作品数
# @course.student.each do |student|
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
# homework.course.student.each do |student|
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
# course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
# end
@course.members.each do |m|
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => @course.id, :viewed => false, :status => nil)
course = @homework.course
course.members.each do |m|
@homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => nil)
end
if @homework.course_acts.size == 0
@homework.course_acts << CourseActivity.new(:user_id => @homework.user_id,:course_id => @homework.course_id)
end
end
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
redirect_to student_work_index_path(:homework => @homework.id)
end
def end_homework
if @homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > Time.now
@homework.update_attribute("end_time", Time.now)
if @homework.homework_type == 4
@homework.homework_detail_manual.update_attribute("comment_status", 2)
shixun = @homework.homework_commons_shixuns.shixun
@homework.student_works.where("work_status != 0").each do |student_work|
unless student_work.myshixun.status == 1
student_work.update_column("late_penalty", @homework.late_penalty)
student_work.update_column("work_status", 2)
student_work.late_penalty = @homework.late_penalty
end
passed_count = @homework.homework_detail_manual.answer_open_evaluation ? had_passed_changllenge_num(shixun, student_work.user) : had_passed_no_ans_changllenge_num(shixun, student_work.user)
final_score =(passed_count.to_f / shixun.challenges.count) * 100
student_work.update_column("final_score", format("%.2f",final_score.to_f))
score = final_score - student_work.late_penalty
student_work.update_column("work_score", format("%.2f",(score < 0 ? 0 : score).to_f))
end
@homework.student_works.where("work_status = 0").each do |student_work|
myshixun = Myshixun.where(:shixun_id => @homework.homework_commons_shixuns.shixun_id, :user_id => student_work.user_id).first
if myshixun
student_work.update_attributes(:work_status => (myshixun.status == 1 ? 1 : 2), :late_penalty => myshixun.status == 1 ? 0 : @homework.late_penalty, :commit_time => myshixun.created_at, :myshixun_id => myshixun.id)
student_work.late_penalty = myshixun.status == 1 ? 0 : @homework.late_penalty
passed_count = @homework.homework_detail_manual.answer_open_evaluation ? had_passed_changllenge_num(shixun, student_work.user) : had_passed_no_ans_changllenge_num(shixun, student_work.user)
final_score =(passed_count.to_f / shixun.challenges.count) * 100
student_work.update_column("final_score", format("%.2f",final_score.to_f))
score = final_score - student_work.late_penalty
student_work.update_column("work_score", format("%.2f",(score < 0 ? 0 : score).to_f))
end
end
end
end
redirect_to student_work_index_path(:homework => @homework.id)
end
# 成绩公开范围弹框

View File

@ -8,39 +8,43 @@ class ManagementsController < ApplicationController
include ApplicationHelper
#用户修改
def myshixuns
@g = Gitlab.client
if params[:search]
@myshixuns = Myshixun.where(:identifier => params[:search]).includes(:shixun)
else
@myshixuns = Myshixun.where("0=0").includes(:shixun)
end
@myshixuns_count = @myshixuns.count
limit = 20
@myshixuns_pages = Paginator.new @myshixuns_count, limit, params['page'] || 1
@offset ||= @myshixuns_pages.offset
@myshixuns = paginateHelper @myshixuns, limit
respond_to do |format|
format.js
format.html
end
end
def anomaly_detection
end
def account
@user = User.find(params[:user_id])
ue = @user.user_extensions
# @trail_authentication = ApplyAction.where(:user_id => @user.id, :container_type => "TrialAuthorization").order("created_at desc").first
# @authentication = @user.authentication
# if @user.nickname.nil? || @user.lastname.nil? || ue.try(:identity).nil? || ue.try(:location).nil? || ue.try(:location).nil?
# @require_auth = true
# else
# if User.current.certification != 1 && (@trail_authentication.blank? || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 5*60) < Time.now.to_i))
# @require_trail_auth = true
# end
# end
# @s_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').first
# @d_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').first
# AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').update_all(:viewed => true)
# AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').update_all(:viewed => true)
lg = @user.login
@pref = @user.pref
diskfile = disk_filename('User', @user.id)
diskfile1 = diskfile + 'temp'
begin
if request.post?
@user.nickname = params[:nickname]
@user.lastname = params[:lastname]
@user.firstname = ""
@user.show_realname = params[:show_realname] ? 0 : 1
@user.pref.attributes = params[:pref]
@user.mail = params[:mail]
@user.phone = params[:phone]
@user.password = params[:new_password]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
#@user.password = params[:new_password]
if params[:new_password] && params[:new_password_confirmation]
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
end
@se = @user.extensions
@se.school_id = params[:occupation]
@se.department_id = params[:department_id]
@ -59,26 +63,28 @@ class ManagementsController < ApplicationController
@se.student_id = nil
end
@se.brief_introduction = params[:brief_introduction]
if @user.save && @se.save
reward_grade(@user, @user.id, 'Account', 500)
# 头像保存
FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
@user.pref.save
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
set_language_if_valid @user.language
flash[:notice] = l(:notice_account_updated)
return
else
@user.login = lg
end
@user.save
@se.save
# if @user.save && @se.save
# reward_grade(@user, @user.id, 'Account', 500)
# # 头像保存
# FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1
# @user.pref.save
# @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
# set_language_if_valid @user.language
# flash[:notice] = l(:notice_account_updated)
# return
# else
# # @user.login = lg
# end
end
# 不管前面是否有异常,如果文件已存在就删除
ensure
File.delete(diskfile1) if File.exist?(diskfile1)
end
@setting_type = 1
redirect_to update_user_managements_path(:user => @user)
end
# 镜像管理
@ -302,11 +308,12 @@ class ManagementsController < ApplicationController
@sub_type = 1
@jour = JournalsForMessage.where(:jour_type => 'HomeworkCommon').order("created_on desc")
@jour_count = @jour.count
limit = 20
@page = (params['page'] || 1).to_i
@limit = 20
@is_remote = true
@jour_pages = Paginator.new @jour_count, limit, params['page'] || 1
@jour_pages = Paginator.new @jour_count, @limit, params['page'] || 1
@offset ||= @jour_pages.offset
@jour = paginateHelper @jour, limit
@jour = paginateHelper @jour, @limit
respond_to do |format|
format.html
format.js
@ -318,12 +325,13 @@ class ManagementsController < ApplicationController
@menu_type = 8
@sub_type = 3
@memo = Memo.where("0=0").order("created_at desc")
@page = (params['page'] || 1).to_i
@memo_count = @memo.count
limit = 20
@limit = 20
@is_remote = true
@memo_pages = Paginator.new @memo_count, limit, params['page'] || 1
@memo_pages = Paginator.new @memo_count, @limit, params['page'] || 1
@offset ||= @memo_pages.offset
@memo = paginateHelper @memo, limit
@memo = paginateHelper @memo, @limit
respond_to do |format|
format.html
format.js
@ -443,12 +451,13 @@ end
@department = @department.where(:school_id => apply)
end
@department = @department.reorder("created_at #{@sx_order}")
@page = (params['page'] || 1).to_i
@department_count =@department.count
limit = 20
@limit = 20
@is_remote = true
@department_pages = Paginator.new @department_count, limit, params['page'] || 1
@department_pages = Paginator.new @department_count, @limit, params['page'] || 1
@offset ||=@department_pages.offset
@department = paginateHelper @department, limit
@department = paginateHelper @department, @limit
respond_to do |format|
format.js
format.html
@ -469,7 +478,7 @@ end
def add_department
department = Department.where(:school_id => params[:school], :name => params[:department]).first
if department.nil?
department = Department.create(:school_id => params[:school],:name => params[:department])
department = Department.create(:school_id => params[:school],:name => params[:department],:is_auth => 1)
ApplyAddDepartment.create(:school_id => params[:school],
:status => 1,
:name => params[:department],
@ -535,12 +544,13 @@ end
@schools = @schools.where("name like '%#{search}%'")
end
@schools = @schools.reorder("created_at #{@sx_order}")
@page = (params['page'] || 1).to_i
@schools_count = @schools.count
limit = 20
@limit = 20
@is_remote = true
@schools_pages = Paginator.new @schools_count, limit, params['page'] || 1
@schools_pages = Paginator.new @schools_count, @limit, params['page'] || 1
@offset ||= @schools_pages.offset
@schools= paginateHelper @schools, limit
@schools= paginateHelper @schools, @limit
respond_to do |format|
format.js
format.html
@ -603,14 +613,15 @@ end
def save_school
uploaded_io = params[:logo]
sl = School.create(:name => params[:schoolname],:province => params[:province],:city => params[:city],:address => params[:address])
unless uploaded_io.nil?
File.open(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb') do |file|
file.write(uploaded_io.read)
end
sl.logo_link = '/images/school/'+sl.id.to_s+'.png'
sl.save
end
school_pinyin = Pinyin.t(params[:schoolname].strip, splitter: '')
sl = School.create(:name => params[:schoolname],:province => params[:province],:city => params[:city],:address => params[:address],:pinyin =>school_pinyin)
# unless uploaded_io.nil?
# File.open(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb') do |file|
# file.write(uploaded_io.read)
# end
# sl.logo_link = '/images/school/'+sl.id.to_s+'.png'
# sl.save
# end
@user = User.current
@se = @user.extensions
@ -870,7 +881,7 @@ end
redirect_to unit_managements_path
end
# 课列表
# 课列表
def classroom
@menu_type = 2
@sub_type = 1
@ -893,12 +904,13 @@ end
end
end
@courselist = @courselist.order("created_at #{@sx_order}")
@page = (params['page'] || 1).to_i
@courselist_count = @courselist.count
limit = 20
@limit = 20
@is_remote = true
@courselist_pages = Paginator.new @courselist_count, limit, params['page'] || 1
@courselist_pages = Paginator.new @courselist_count, @limit, params['page'] || 1
@offset ||= @courselist_pages.offset
@courselist = paginateHelper @courselist, limit
@courselist = paginateHelper @courselist,@limit
# @courselist = @courselist.order("courselist.created_at #{@sx_order}")
respond_to do |format|
@ -924,10 +936,10 @@ end
@timing=Course.where(:is_end=>false).count
@end=Course.where(:is_end=>true).count
@course_lists = CourseList.where(:id => Course.where(:is_delete => 0 ).map(&:course_list_id) )
unless params[:school_id] || params[:search] || params[:keyword] || params[:status]
user_exs=UserExtensions.where(:school_id=> @courses.map(&:school_id))
@schools = School.where(:id =>user_exs.map(&:school_id))
end
# unless params[:school_id] || params[:search] || params[:keyword] || params[:status]
# user_exs = UserExtensions.where(:school_id=> @courses.map(&:school_id))
# @schools = School.where(:id =>user_exs.map(&:school_id))
# end
@search = params[:search] # 搜索字
@keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
@status = params[:status]
@ -962,13 +974,14 @@ end
# @courses= @courses.where("name like '%#{@search}%'")
end
@courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").reorder("updatetime #{@sx_order}")
@page = (params['page'] || 1).to_i
@export_courses = @courses
@courses_count = @courses.count
limit = 20
@limit = 20
@is_remote = true
@courses_pages = Paginator.new @courses_count, limit, params['page'] || 1
@courses_pages = Paginator.new @courses_count, @limit, params['page'] || 1
@offset ||= @courses_pages.offset
@courses = paginateHelper @courses, limit
@courses = paginateHelper @courses, @limit
respond_to do |format|
format.js
format.html
@ -980,6 +993,53 @@ end
end
end
def shixun_task
@menu_type = 2
@sub_type = 3
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
# @shixun_task = Course.where(:homework_type => 4)
homework_commons = HomeworkCommon.where(:homework_type => 4)
@shixun_task = Course.where(:id => homework_commons.map(&:course_id))
@keyword = params[:keyword]
@search = params[:search]
@school_id = params[:school_id]
if params[:school_id] && params[:school_id] != ''
@shixun_task = @shixun_task.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("ue.school_id = #{params[:school_id]}")
# @shixun_task = @shixun_task.includes(:user => {:user_extensions => []}).where("user_extensions.school_id = #{params[:school_id]}")
end
if @search.blank?
@shixun_task = @shixun_task
else
if "u_name" == @keyword
user_id = User.where("concat(lastname, firstname) like '%#{@search}%'")
@shixun_task = @shixun_task.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'")
else
@shixun_task = @shixun_task.where("courses.name like '%#{@search}%'")
end
end
@export_shixun_task = @shixun_task
@page = (params['page'] || 1).to_i
@shixun_task_count = @shixun_task.count
@limit = 20
@is_remote = true
@shixun_task_pages = Paginator.new @shixun_task_count, @limit, params['page'] || 1
@offset ||= @shixun_task_pages.offset
@shixun_task = paginateHelper @shixun_task, @limit
respond_to do |format|
format.js
format.html
format.xls{
@export_shixun_task = @export_shixun_task.all
filename = "#{l(:label_shixun_task_xls)}.xls"
send_data(shixun_task_xls(@export_shixun_task), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
end
# 班级首页显示
def course_homepage_show
if params[:course_id]
@ -1022,12 +1082,12 @@ end
@schools = School.where(:id => user_exs.map(&:school_id))
end
@c_shixuns = @c_shixuns.order("created_at #{@sx_order}")
@page = (params['page'] || 1).to_i
@c_shixuns_count = @c_shixuns.count
limit = 20
@c_shixuns_pages = Paginator.new @c_shixuns_count, limit, params['page'] || 1
@limit = 20
@c_shixuns_pages = Paginator.new @c_shixuns_count, @limit, params['page'] || 1
@offset ||= @c_shixuns_pages.offset
@c_shixuns = paginateHelper @c_shixuns, limit
@c_shixuns = paginateHelper @c_shixuns, @limit
respond_to do |format|
format.js
format.html
@ -1063,12 +1123,13 @@ end
user_exs = UserExtensions.where(:user_id => @c_shixuns.map(&:user_id))
@schools = School.where(:id => user_exs.map(&:school_id))
end
@page = (params['page'] || 1).to_i
@c_shixuns = @c_shixuns.order("created_at #{@sx_order}")
@c_shixuns_count = @c_shixuns.count
limit = 20
@c_shixuns_pages = Paginator.new @c_shixuns_count, limit, params['page'] || 1
@limit = 20
@c_shixuns_pages = Paginator.new @c_shixuns_count, @limit, params['page'] || 1
@offset ||= @c_shixuns_pages.offset
@c_shixuns = paginateHelper @c_shixuns, limit
@c_shixuns = paginateHelper @c_shixuns, @limit
respond_to do |format|
format.js
format.html
@ -1116,7 +1177,7 @@ end
user_id = UserExtensions.where(:school_id => school_id).map(&:user_id)
@users = @users.where(:id => user_id).order("#{@order_key} #{@us_order}")
end
@page = (params['page'] || 1).to_i
@users_count = @users.count
@limit = 20
@is_remote = true
@ -1158,11 +1219,12 @@ end
@audit_sx_num = Shixun.where(:status => 1).count
@publish_sx_num =Shixun.where(:status => 2).count
@close_sx_num = Shixun.where(:status => 3).count
@page = (params['page'] || 1).to_i
@shixuns_count = @shixuns.count
limit = 20
@shixuns_pages = Paginator.new @shixuns_count, limit, params['page'] || 1
@limit = 20
@shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1
@offset ||= @shixuns_pages.offset
@shixuns = paginateHelper @shixuns, limit
@shixuns = paginateHelper @shixuns, @limit
respond_to do |format|
format.js
format.html
@ -1199,11 +1261,12 @@ end
if params[:homepage_show]
@shixuns = @shixuns.where(:homepage_show => params[:homepage_show].to_i)
end
@page = (params['page'] || 1).to_i
@shixuns_count = @shixuns.count
limit = 20
@shixuns_pages = Paginator.new @shixuns_count, limit, params['page'] || 1
@limit = 20
@shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1
@offset ||= @shixuns_pages.offset
@shixuns = paginateHelper @shixuns, limit
@shixuns = paginateHelper @shixuns, @limit
respond_to do |format|
format.js
format.html
@ -1247,11 +1310,56 @@ end
else
@shixuns = Shixun.where("name like '%#{search}%'").where(:status => 3).order("updated_at #{@sx_order}")
end
@page = (params['page'] || 1).to_i
@shixuns_count = @shixuns.count
limit = 20
@shixuns_pages = Paginator.new @shixuns_count, limit, params['page'] || 1
@limit = 20
@shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1
@offset ||= @shixuns_pages.offset
@shixuns = paginateHelper @shixuns, limit
@shixuns = paginateHelper @shixuns, @limit
respond_to do |format|
format.js
format.html
end
end
# 实训成员列表
def shixun_member
@menu_type = 3
@sub_type = 4
@shixun_member = Myshixun.where("0=0").order("created_at desc")
keyword = params[:keyword]
search = params[:search]
member = params[:member]
if search.blank?
@shixun_member = @shixun_member
else
if "u_name" == keyword
user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
@shixun_member = @shixun_member.where(:user_id => user_id)
elsif keyword == "sx_name"
@shixun_member = @shixun_member.joins(:shixun).where("shixuns.name like '%#{search}%'")
else
school_id = School.where("name like '%#{search}%'").blank? ? "(-1)" : "(" + School.where("name like '%#{search}%'").map(&:id).join(",") + ")"
user_id = UserExtensions.where("school_id in #{school_id}").blank? ? "(-1)" : "(" + UserExtensions.where("school_id in #{school_id}").map(&:user_id).join(",") + ")"
@shixun_member = @shixun_member.where("user_id in #{user_id}")
end
end
if member && member != ''
user_id = User.where("concat(lastname, firstname) like '%#{member}%'").blank? ? "(-1)" : "(" + User.where("concat(lastname, firstname) like '%#{member}%'").map(&:id).join(",") + ")"
@shixun_member = @shixun_member.joins(:shixun).where("shixuns.user_id in #{user_id}")
end
@page = (params['page'] || 1).to_i
@shixun_member_count = @shixun_member.count
@limit = 20
@is_remote = true
@shixun_member_pages = Paginator.new @shixun_member_count, @limit, params['page'] || 1
@offset ||= @shixun_member_pages.offset
@shixun_member = paginateHelper @shixun_member, @limit
respond_to do |format|
format.js
format.html
@ -1263,6 +1371,7 @@ end
@sub_type = 2
@sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
@users = User.where(:status => 1).order("last_login_on #{@sx_order}").all
@page = (params['page'] || 1).to_i
@users_count = @users.count
@limit = 20
@is_remote = true
@ -1277,12 +1386,13 @@ end
@sub_type = 3
@apply_action = School.where(:auto_users_trial => 1).order('updated_at desc')
@auto_school_ids = @apply_action.empty? ? "(-1)" : "(" + @apply_action.map(&:id).join(",") + ")"
@page = (params['page'] || 1).to_i
@apply_action_count = @apply_action.count
limit = 20
@limit = 20
@is_remote = true
@apply_action_pages = Paginator.new @apply_action_count, limit, params['page'] || 1
@apply_action_pages = Paginator.new @apply_action_count, @limit, params['page'] || 1
@offset ||= @apply_action_pages.offset
@apply_action = paginateHelper @apply_action, limit
@apply_action = paginateHelper @apply_action, @limit
respond_to do |format|
format.html
format.js
@ -1397,6 +1507,12 @@ end
end
end
student_id = params[:student_id]
if params[:student_id] && params[:student_id] != ''
@users = @users.joins(:user_extensions).where("user_extensions.student_id like '%#{student_id}%'")
end
@page = (params['page'] || 1).to_i
@users_count = @users.count
@limit = 20
@is_remote = true
@ -1663,7 +1779,7 @@ end
else #同意
shixun.update_column('status', 2)
apply_action.update_attributes(:status => 1, :dealer_id => User.current.id)
add_shixun_modify_status shixun, 1
shixun_modify_status_without_publish shixun, 1
# 实训发布后则不允许修改代码
# g = Gitlab.client
# shixun.shixun_members.each do |member|
@ -1735,4 +1851,49 @@ end
book.write xls_report
xls_report.string
end
def shixun_task_xls shixun_task
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "course"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["ID","课堂名称","创建者","创建者单位","学生"," 实训作业","序号","发布时间","已提交","有效作品","通关","状态"])
count_row = 1
shixun_task.each_with_index do |shixun_task,index|
school = shixun_task.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : shixun_task.teacher.school_name
teacher_name = shixun_task.teacher ? shixun_task.teacher.show_real_name : ""
sheet1[count_row,0] = index + 1
sheet1[count_row,1] = shixun_task.name
sheet1[count_row,2] = teacher_name
sheet1[count_row,3] = school
sheet1[count_row,4] = shixun_task.student.count
sheet1[count_row,5] = get_shixun_task(shixun_task.id).count
get_shixun_task(shixun_task.id).each_with_index do |gst, j|
sheet1[count_row,6] = j + 1
sheet1[count_row,7] = format_time(gst.publish_time)
sheet1[count_row,8] = had_commit_studentwork_count(gst)
sheet1[count_row,9] = effective_shixun_work_count gst
sheet1[count_row,10] = tongguan_shixun_work_count gst
sheet1[count_row,11] = if HomeworkDetailManual.where(:homework_common_id => gst.id).first.comment_status == 0
"未发布"
elsif HomeworkDetailManual.where(:homework_common_id => gst.id).first.comment_status == 1
"提交中"
elsif HomeworkDetailManual.where(:homework_common_id => gst.id).first.comment_status == 3
"匿评中"
elsif HomeworkDetailManual.where(:homework_common_id => gst.id).first.comment_status == 4
"申诉中"
elsif HomeworkDetailManual.where(:homework_common_id => gst.id).first.comment_status == 5
"评阅中"
else HomeworkDetailManual.where(:homework_common_id => gst.id).first.comment_status == 6
"已结束"
end
count_row += 1
end
end
book.write xls_report
xls_report.string
end
end

View File

@ -4,11 +4,36 @@ class MyshixunsController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh]
before_filter :require_login, :except => [:training_task_status, :close_webssh]
before_filter :check_authentication, :except => [:training_task_status, :close_webssh]
before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh]
before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy]
include ApplicationHelper
# 临时使用
def destroy
if User.current.admin?
user = @myshixun.owner
@myshixun.games.each do |game|
ex =Experience.where(:container_type => "Game", :container_id => game.id).first
ex.destroy if ex.present?
gr = Grade.where(:container_type => "Game", :container_id => game.id).first
gr.destroy if gr.present?
grade = user.try(:grade).to_i - game.try(:final_score).to_i
grade = grade > 0 ? grade : 0
user.update_column(:grade, grade)
end
@myshixun.destroy
# 删除积分和经验值
#g = Gitlab.client
#g.delete_project(@myshixun.gpid) if @myshixun.gpid.present?
end
end
def sync_reset_time
@myshixun.update_column(:modify_time, @myshixun.shixun.try(:modify_time))
render :json => {:data => "success"}
end
# 将代码重置到开启状态
# 方法使用文件更新非Git重置
def code_reset
@ -130,12 +155,14 @@ class MyshixunsController < ApplicationController
logger.info(outPut)
game = Game.find(game_id)
challenge = game.challenge
test_sets = game.challenge.test_sets
unless jenkins_testsets.blank?
jenkins_testsets.each do |j_test_set|
logger.info("j_test_set: ############## #{j_test_set['output']}")
jenkins_testsets.each_with_index do |j_test_set, i|
logger.info("j_test_set: ############## #{j_test_set}")
actual_output = tran_base64_decode64(j_test_set['output'])
is_public = test_sets.where(:position => j_test_set['caseId']).first.try(:is_public)
logger.info "actual_output:################################################# #{actual_output}"
game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'],
game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], :is_public => is_public,
:actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i)
# output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first
# logger.info("#############{outPut}")
@ -147,12 +174,18 @@ class MyshixunsController < ApplicationController
# end
end
end
logger.info("#############status: #{status}")
logger.info("#############status=='0': #{status == '0'}")
logger.info("#############resubmit: #{resubmit}")
if status == "0"
if !resubmit.blank?
game.update_attributes(:retry_status => 2, :resubmit_identifier => resubmit)
else
game.update_attributes(:status => 2, :end_time => Time.now)
unless game.answer_open? # 如果没有查看答案,则获得该关卡得分
game.update_attribute(:end_time, Time.now)
if !game.answer_open && (challenge.shixun.try(:status) > 1) # 如果没有查看答案,则获得该关卡得分
reward_grade(game.user, game.id, 'Game', challenge.score)
reward_experience(game.user, game.id, 'Game', challenge.score)
game.update_attribute(:final_score, challenge.score)
end
end

View File

@ -0,0 +1,145 @@
#encoding: utf-8
class QuestionBanksController < ApplicationController
before_filter :require_login, :only => [:index, :show, :new, :create, :edit, :update, :destroy, :destroy_all, :choose_user_course, :send_h_bank_to_course]
before_filter :find_question_bank, :only => [:show, :edit, :update, :destroy, :set_public]
def index
@order,@b_sort = params[:order] || "updated_at",params[:sort] || "desc"
@user = User.current
@r_sort = @b_sort == "desc" ? "asc" : "desc"
@search = params[:search]
if(params[:type].blank? || params[:type] == "1") #我的题库
@homeworks = @user.question_banks.where("container_type in ('Common', 'Shixun', 'Exercise') and name like ?", "%#{@search}%")
elsif params[:type] == "2" #公共题库
@homeworks = QuestionBank.where(:is_public => true).where("container_type in ('Common', 'Shixun', 'Exercise') and name like ?", "%#{@search}%")
end
if params[:property]
@property = params[:property]
@homeworks = @homeworks.where(:container_type => params[:property])
end
@homeworks = @homeworks.reorder("#{@order} #{@b_sort}")
@type = params[:type] ? params[:type] : '1'
@limit = 15
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,15
respond_to do |format|
format.js
format.html {render :layout => 'base_edu'}
end
end
def new
end
def show
case @question.container_type
when 'Common', 'Shixun'
redirect_to homework_bank_path(@question.container_id)
when 'Exercise', 'Poll'
redirect_to exercise_bank_path(@question.container_id)
end
end
def destroy
case @question.container_type
when 'Common', 'Shixun'
@container.homework_commons.update_all(:homework_bank_id => nil)
when 'Exercise'
Exercise.where(:exercise_bank_id => @container.id).update_all(:exercise_bank_id => nil)
end
if @container.destroy
@question.destroy
end
redirect_to question_banks_path()
end
def set_public
ActiveRecord::Base.transaction do
begin
@question.update_attributes(:is_public => true)
@container.update_attributes(:is_public => true)
rescue Exception => e
puts e
end
end
respond_to do |format|
format.html{ redirect_to question_bank_path(@question) }
format.js
end
end
def destroy_all
if params[:check_homework_bank] && !params[:check_homework_bank].blank?
begin
params[:check_homework_bank].each do |hb_id|
question = QuestionBank.find hb_id
if question && question.user == User.current
case question.container_type
when 'Common', 'Shixun'
container = HomeworkBank.find question.container_id
container.homework_commons.update_all(:homework_bank_id => nil)
when 'Exercise'
container = ExerciseBank.find question.container_id
Exercise.where(:exercise_bank_id => container.id).update_all(:exercise_bank_id => nil)
end
if container.destroy
question.destroy
end
end
end
rescue Exception => e
puts e
end
end
redirect_to question_banks_path
end
def choose_user_course
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@courses = User.current.courses.where("is_delete = 0 and is_end = 0 and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select{ |course| User.current.has_teacher_role(course)}
else
@courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)}
end
@homework_ids = params[:check_homework_bank] if params[:check_homework_bank]
@search = params[:search]
respond_to do |format|
format.js
end
end
def send_h_bank_to_course
course = Course.find params[:course_id]
if course
params[:homework_id].each do |homework_id|
question = QuestionBank.find homework_id
case question.container_type
when 'Common', 'Shixun'
homework = HomeworkBank.find question.container_id
quote_homework_bank homework, course
when 'Exercise'
exercise = ExerciseBank.find question.container_id
quote_exercise_bank exercise, course
when 'Poll'
end
end
end
end
private
def find_question_bank
@question = QuestionBank.find params[:id]
case @question.container_type
when 'Common', 'Shixun'
@container = HomeworkBank.find @question.container_id
when 'Exercise', 'Poll'
@container = ExerciseBank.find @question.container_id
end
rescue ActiveRecord::RecordNotFound
render_404
end
end

View File

@ -128,18 +128,18 @@ class SchoolController < ApplicationController
end
if params[:no_school_ids]
if(condition == '')
@school = School.where("id not in #{params[:no_school_ids]}").reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100)
@school = School.where("id not in #{params[:no_school_ids]}").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i || 1)).per(100)
@school_count = School.count
else
@school = School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100)
@school = School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i || 1)).per(100)
@school_count = School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count
end
else
if(condition == '')
@school = School.reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100)
@school = School.reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i || 1)).per(100)
@school_count = School.count
else
@school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100)
@school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i || 1)).per(100)
@school_count = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count
end
end

View File

@ -6,8 +6,8 @@ class ShixunsController < ApplicationController
before_filter :check_authentication, :except => [:ghook]
before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search, :shixun_courses, :new_disscuss, :shixun_migrate]
skip_before_filter :verify_authenticity_token, :only => [:ghook]
before_filter :shixun_view_allow, :only => [:show]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators]
before_filter :shixun_view_allow, :only => [:show, :collaborators, :propaedeutics, :shixun_discuss]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators, :update]
before_filter :validation_email, :only => [:new]
include ApplicationHelper
@ -437,10 +437,11 @@ class ShixunsController < ApplicationController
# copy_myshixun自动创建系列game,game中只包含状态等信息公共信息从Challeges中读取
# 开启过实训的则直接跳入my实训页面
def shixun_exec
unless allow_shixun_exec(@shixun) && (User.current.manager_of_shixun?(@shixun) || @shixun.status > 0)
render_403
return
end
# unless allow_shixun_exec(@shixun) && (User.current.manager_of_shixun?(@shixun) || @shixun.status > 0)
# render_403
# return
# end
# 添加事务锁防止并发情况下tpi被多次创建
myshixun = Myshixun.where(:user_id => User.current.id, :shixun_id => @shixun.id).first
unless myshixun.blank?
logger.info("current task id is #{myshixun.current_task}")
@ -449,9 +450,11 @@ class ShixunsController < ApplicationController
end
ActiveRecord::Base.transaction do
begin
# lock
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
code = down_generate_identifier("myshixun")
myshixun = Myshixun.create!(:shixun_id => @shixun.id, :user_id => User.current.id, :identifier => code)
myshixun = Myshixun.create!(:shixun_id => @shixun.id, :user_id => User.current.id, :identifier => code,
:modify_time => @shixun.modify_time, :reset_time => @shixun.reset_time)
# fork版本库如果用户没有同步则先同步用户
g = Gitlab.client
if User.current.gid.nil?
@ -472,7 +475,7 @@ class ShixunsController < ApplicationController
logger.info("start openGameInstance")
uri = "#{shixun_tomcat}/bridge/game/openGameInstance"
logger.info("end openGameInstance")
params = {tpiID: "#{myshixun.id}", tpmID: "#{@shixun.id}", instanceGitURL:rep_url, operationEnvironment:"#{@shixun.try(:language)}"}
params = {tpiID: "#{myshixun.id}", tpmID: "#{@shixun.id}", tpmGitURL:rep_url, operationEnvironment:"#{@shixun.try(:language)}", tpiRepoName: gshixun.try(:name)}
logger.info("openGameInstance params is #{params}")
res = uri_exec uri, params
if (res && res['code'].to_i != 0)
@ -487,7 +490,7 @@ class ShixunsController < ApplicationController
game =Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id, :open_time => Time.now, :identifier => code)
# 记录刚开始时默认代开文件原始代码
# 刚开始fork的一段时间是获取不了content内容的
game_passed_code(game.try(:id), challenge.try(:path), myshixun.try(:gpid), 0)
game_code_init(game.id)
end
if params[:type] == "1" # 重置过来的请求
shixun_mod = ShixunModify.where(:shixun_id => myshixun.try(:shixun_id), :myshixun_id => myshixun.try(:id)).first
@ -500,12 +503,13 @@ class ShixunsController < ApplicationController
else
raise("实训云平台繁忙繁忙等级81")
end
# unlock
logger.info("myshixun id si #{myshixun.id} and current_task id is#{myshixun.current_task.id}")
redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun, :is_subject => params[:is_subject])
rescue Exception => e
flash[:error] = e.message
logger.info("failed to exec shixun: current task id is #{e}")
g.delete_project(gshixun.id) if !gshixun.id.nil?
g.delete_project(gshixun.id) if gshixun.try(:id).present?
redirect_to shixun_challenges_path(@shixun)
raise ActiveRecord::Rollback
end
@ -553,6 +557,8 @@ class ShixunsController < ApplicationController
@shixun.webssh = params[:webssh].to_i
@shixun.can_copy = params[:can_copy].to_i
@shixun.identifier = identifier
@shixun.reset_time = Time.now
@shixun.modify_time = Time.now
# if params[:course_id]
# params[:course_id].each do |course_id|
# @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id)
@ -626,7 +632,7 @@ class ShixunsController < ApplicationController
user_gid = User.find_by_mail("eduforge@163.com").try(:gid)
gshixun = g.fork(@shixun.gpid, user_gid)
raise "版本库创建失败" if gshixun.try(:id).blank?
#gshixun = g.edit_project(gshixun.id, new_shixun.identifier, new_shixun.identifier)
gshixun = g.edit_project(gshixun.id, new_shixun.identifier, new_shixun.identifier)
raise "实训复制失败" if (gshixun.try(:name) != new_shixun.identifier || gshixun.try(:path) != new_shixun.identifier)
new_shixun.update_column(:gpid, gshixun.id)
# 同步复制者至gitlab,必须要求用户绑定了邮箱
@ -705,14 +711,7 @@ class ShixunsController < ApplicationController
end
end
# 中间层创建测试集
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
gameInfo = new_shixun.gameInfo
uri ="#{shixun_tomcat}/bridge/game/publishGame"
params = {gameInfo:gameInfo}
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级90")
end
shixun_modify_status_publish(new_shixun, 1)
flash[:notice] = "实训复制成功"
redirect_to shixun_challenges_path(new_shixun)
rescue Exception => e
@ -790,7 +789,7 @@ class ShixunsController < ApplicationController
begin
@shixun.save!
if language != params[:language] && @shixun.status != 2 # 已发布不触发重置
add_shixun_modify_status(@shixun, 1)
should_modify_myshixun_script(@shixun, 1)
end
rescue
@error = "实训保存失败"
@ -804,15 +803,22 @@ class ShixunsController < ApplicationController
def shixun_discuss
@discusses = @shixun.discusses.reorder("created_at desc")
@discusses_num = @discusses.count
@discusses = get_no_children_comments_all @discusses
@discusses_count = @discusses.count
#@limit = 15
#@is_remote = true
#@discusses_pages = Paginator.new @discusses_count, @limit, params['page'] || 1
# @offset ||= @discusses_pages.offset
#@discusses = paginateHelper @discusses, @limit
#@game_challenge = params[:challenge_id].blank? ? Challenge.find(@discusses.challenge_id) : Challenge.find(params[:challenge_id])
@limit = 15
@is_remote = true
@discusses_pages = Paginator.new @discusses_count, @limit, params['page'] || 1
@offset ||= @discusses_pages.offset
@discusses = paginateHelper @discusses, @limit
@game_challenge = params[:challenge_id].blank? ? Challenge.find(@discusses.first.try(:challenge_id)) : Challenge.find(params[:challenge_id])
challenge_id = params[:challenge_id].nil? ? @shixun.challenges.first.try(:id) : params[:challenge_id].to_i
@game_challenge = Challenge.find(challenge_id)
@praise = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?", @game_challenge.id, @game_challenge.class.to_s, User.current.id).first
@tread = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?", @game_challenge.id, "ChallengeTread", User.current.id).first
@praise_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "Challenge").count
@tread_count = PraiseTread.where(:praise_tread_object_id => @game_challenge.id, :praise_tread_object_type => "ChallengeTread").count
respond_to do |format|
format.js
format.html

View File

@ -604,7 +604,7 @@ class StudentWorkController < ApplicationController
@student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
end
end
redirect_to student_work_index_path(:homework => @homework.id)
redirect_to student_work_path(@student_work)
end
def edit
@ -670,7 +670,7 @@ class StudentWorkController < ApplicationController
end
end
respond_to do |format|
format.html{redirect_to student_work_index_path(:homework => @homework.id)}
format.html{ redirect_to student_work_path(@student_work) }
end
end
@ -1632,7 +1632,7 @@ class StudentWorkController < ApplicationController
def homework_to_xls items
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "homework"
sheet1 = book.create_worksheet :name => "学生成绩"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
if @homework.homework_type == 1 #普通作业
@ -1729,26 +1729,168 @@ class StudentWorkController < ApplicationController
end
count_row += 1
end
elsif @homework.homework_type == 4 #普通作业
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_complete_status),
l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
elsif @homework.homework_type == 4 #实训作业
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_update_time),
l(:excel_homework_complete_status), l(:excel_homework_spend_time),l(:excel_homework_total_exp),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
count_row = 1
shixun = @homework.homework_commons_shixuns.shixun
items.each do |homework|
myshixun = Myshixun.where(:id => homework.myshixun_id).first
sheet1[count_row,0]=homework.user.id
sheet1[count_row,1] = homework.user.show_name
sheet1[count_row,2] = homework.user.login
sheet1[count_row,3] = homework.user.user_extensions.student_id
sheet1[count_row,4] = homework.user.mail
sheet1[count_row,5] = homework.name
sheet1[count_row,6] = homework.work_status == 0 ? '--' : had_passed_changllenge_num(shixun, homework.user).to_s+"/"+shixun.challenges.count.to_s
sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2)
sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2)
sheet1[count_row,9] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty
sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score)
sheet1[count_row,11] = format_time(homework.created_at)
sheet1[count_row,6] = format_time(homework.updated_at)
sheet1[count_row,7] = homework.work_status == 0 ? '--' : had_passed_changllenge_num(shixun, homework.user).to_s+"/"+shixun.challenges.count.to_s
sheet1[count_row,8] = myshixun ? (had_passed_changllenge_num(shixun, homework.user) > 0 ? game_spend_time(myshixun.total_spend_time) : '--') : "--"
sheet1[count_row,9] = myshixun ? myshixun.total_score : "--"
sheet1[count_row,10] = homework.late_penalty
sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? "--" : homework.score.round(2) : "--"
sheet1[count_row,12] = homework.commit_time ? format_time(homework.commit_time) : "--"
count_row += 1
end
black = Spreadsheet::Format.new :color => :black, :weight => :bold, :size => 10
#实训统计
current_row = 0
sheet2 = book.create_worksheet :name => "学员统计"
sheet2.row(0).default_format = blue
sheet2.row(0).concat(["学生id","学生姓名","作业编号","作业/实训名称","关卡"," 经验值","金币","评测历史","评测时间","评测结果"])
@homework.course.student.each_with_index do |course, i|
# 总统计
count_exp_score = 0
count_gold_score = 0
count_test = 0
count_time = 0
game_count = 0
# end
user = course.student
current_row += 1
sheet2[current_row, 0] = user.login
sheet2[current_row, 1] = user.show_real_name
# 关卡统计
count_game_exp_score = 0
count_game_gold_score = 0
count_game_test = 0
count_game_time = 0
# end
sheet2[current_row, 2] = "# #{get_hw_index(@homework, true, 4)}"
sheet2[current_row, 3] = @homework.name
shixun = @homework.homework_commons_shixuns.shixun if @homework.homework_commons_shixuns
if shixun
shixun.challenges.each_with_index do |challenge, k|
sheet2[current_row, 4] = "#{k+1}"
games = Game.where(:challenge_id => challenge.id, :user_id => user.id)
game_count = game_count + games.count
if games.count > 0
games.each do |game|
sheet2[current_row, 5] = game.final_score ? "+#{game.final_score.to_s}" : "--"
sheet2[current_row, 6] = game.final_score ? (game.answer_open? ? "#{-challenge.score.to_i}" : "+#{game.final_score.to_i}") : "--"
count_exp_score += (game.final_score ? game.final_score.to_i : 0)
count_gold_score += (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
count_game_exp_score += (game.final_score ? game.final_score.to_i : 0)
count_game_gold_score += (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
count = game.outputs.count
if count > 0
outputs = game.outputs.where(:test_set_position => 1).reorder("created_at asc")
outputs.each_with_index do |output, k|
count_test += 1
count_game_test += 1
sheet2[current_row, 7] = "#{k+1}次评测"
sheet2[current_row, 8] = k == 0 ? game_spend_time((output.created_at - game.created_at).to_i) : game_spend_time((output.created_at - outputs[k-1].created_at).to_i)
count_time = count_time + (k == 0 ? (output.created_at - game.created_at).to_i : (output.created_at - outputs[k-1].created_at).to_i)
count_game_time += (k == 0 ? (output.created_at - game.created_at).to_i : (output.created_at - outputs[k-1].created_at).to_i)
sheet2[current_row, 9] = game.outputs.where(:query_index => output.query_index).select{|ou| ou.result == false}.count > 0 ? "失败" : "成功"
current_row += 1
end
else
current_row += 1
end
end
else
current_row += 1
end
end
end
sheet2[current_row,4] = "合计"
sheet2[current_row,5] = count_game_exp_score >= 0 ? "+#{count_game_exp_score}" : "-#{count_game_exp_score}"
sheet2[current_row,6] = count_game_gold_score >= 0 ? "+#{count_game_gold_score}" : "#{count_game_gold_score}"
sheet2[current_row,7] = "#{count_game_test}次评测"
sheet2[current_row,8] = game_spend_time((count_game_time == 0 ? 0 : (count_game_time / count_test)).to_i)+"/次"
sheet2.row(current_row).default_format = black
end
sheet3 = book.create_worksheet :name => "关卡统计"
sheet3.row(0).default_format = blue
sheet3[0,0] = "课堂编号"
sheet3[0,1] = "主讲老师"
sheet3[0,2] = "课堂名称"
sheet3[0,3] = "作业编号"
sheet3[0,4] = "作业/实训名称"
sheet3[0,5] = "关卡"
sheet3[0,6] = "学生id"
sheet3[0,7] = "学生姓名"
sheet3[0,8] = "经验值"
sheet3[0,9] = "金币"
sheet3[0,10] = "评测历史"
sheet3[0,11] = "评测时间"
sheet3[0,12] = "评测结果"
sheet3[1,0] = @homework.course.id
sheet3[1,1] = @homework.course.teacher.show_real_name
sheet3[1,2] = @homework.course.name
sheet3[1,3] = "# #{get_hw_index(@homework, true, 4)}"
sheet3[1,4] = @homework.name
current_row = 1
shixun = @homework.homework_commons_shixuns.shixun if @homework.homework_commons_shixuns
if shixun
shixun.challenges.each_with_index do |challenge, j|
sheet3[current_row,5] = "#{j+1}"
games = Game.where(:challenge_id => challenge.id, :user_id => @homework.student_works.where("work_status != 0").map(&:user_id))
count_exp_score = 0
count_gold_score = 0
count_test = 0
count_time = 0
if games.count > 0
games.each do |game|
user = game.user
sheet3[current_row,6] = user.login
sheet3[current_row,7] = user.show_real_name
sheet3[current_row,8] = game.final_score ? "+#{game.final_score.to_s}" : "--"
count_exp_score = count_exp_score + (game.final_score ? game.final_score.to_i : 0)
sheet3[current_row,9] = game.final_score ? (game.answer_open? ? "#{-challenge.score.to_i}" : "+#{game.final_score.to_i}") : "--"
count_gold_score = count_gold_score + (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
count = game.outputs.count
if count > 0
outputs = game.outputs.where(:test_set_position => 1).reorder("created_at asc")
outputs.each_with_index do |output, k|
count_test = count_test + 1
sheet3[current_row,10] = "#{k+1}次评测"
sheet3[current_row,11] = k == 0 ? game_spend_time((output.created_at - game.created_at).to_i) : game_spend_time((output.created_at - outputs[k-1].created_at).to_i)
count_time = count_time + (k == 0 ? (output.created_at - game.created_at).to_i : (output.created_at - outputs[k-1].created_at).to_i)
sheet3[current_row,12] = game.outputs.where(:query_index => output.query_index).select{|ou| ou.result == false}.count > 0 ? "失败" : "成功"
current_row = current_row + 1
end
else
current_row = current_row + 1
end
end
else
current_row = current_row + 1
end
sheet3[current_row,6] = "合计"
sheet3[current_row,7] = games.count.to_s + ""
sheet3[current_row,8] = count_exp_score >= 0 ? "+#{count_exp_score}" : "-#{count_exp_score}"
sheet3[current_row,9] = count_gold_score >= 0 ? "+#{count_gold_score}" : "#{count_gold_score}"
sheet3[current_row,10] = "#{count_test}次评测"
sheet3[current_row,11] = game_spend_time((count_time == 0 ? 0 : (count_time / count_test)).to_i)+"/次"
sheet3.row(current_row).default_format = black
current_row = current_row + 1
end
end
end
book.write xls_report
xls_report.string

View File

@ -694,13 +694,19 @@ class UsersController < ApplicationController
@course_result_pages = Paginator.new @course_result_count, @limit, params['page'] || 1
@offset ||= @course_result_pages.offset
@course_result = paginateHelper @course_result, @limit
else
elsif @index == 2
# @shixuns_result = Shixun.where(:status => [2,3]).where("name like ?", "%#{@search}%").reorder("created_at desc")
@shixuns_result = Shixun.where("name like ?", "%#{@search}%").reorder("created_at desc")
@shixuns_result_count = @shixuns_result.count
@shixun_pages = Paginator.new @shixuns_result_count, @limit, params['page'] || 1
@offset ||= @shixun_pages.offset
@shixuns_result = paginateHelper @shixuns_result, @limit
else
@user_result = User.find_by_sql("select * from users where concat(lastname,firstname) like '%#{@search}%'")
@user_result_count = @user_result.count
@user_pages = Paginator.new @user_result_count, @limit, params['page'] || 1
@offset ||= @user_pages.offset
@user_result = paginateHelper @user_result, @limit
end
respond_to do |format|
format.html{render :layout=>'base_edu'}
@ -1297,11 +1303,11 @@ class UsersController < ApplicationController
#导入作业,确定按钮
def user_select_homework
params[:checkMenu].each do |homework_bank|
homework = HomeworkBank.find_by_id homework_bank
if params[:checkMenu]
homework = HomeworkBank.find_by_id params[:checkMenu]
@select_course = Course.find params[:select_course]
if homework && @select_course
quote_homework_bank homework, @select_course
@homework = quote_homework_bank homework, @select_course
end
end
respond_to do |format|

View File

@ -72,7 +72,7 @@ class WatchersController < ApplicationController
end
else
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true} }
format.js { render :partial => 'set_watcher',
:locals => {
:user => User.current,

View File

@ -41,12 +41,13 @@ module ApplicationHelper
when 1
str = "<span class='color-light-green'>按时提交</span>"
when 2
str = "<span class='color-orange'>延时提交</span>"
str = "<span class='color-red'>延时提交</span>"
end
end
# 判断TPM的代码是否被修改了
# 判断依据是看tpm的最新提交记录和tpi数据库中存储的commit_id是否一致
def tpm_is_modified myshixun, shixun_gpid
g = Gitlab.client
myshixun_commit_id = myshixun.commit_id
@ -110,37 +111,58 @@ module ApplicationHelper
end
end
def only_publish_game shixun, type
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
gameInfo = shixun.gameInfo
uri ="#{shixun_tomcat}/bridge/game/publishGame"
params = {:gameInfo => "#{gameInfo}"}
logger.info("%%%%%%%%%%%%params is #{params}")
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级90")
end
end
def publish_game_and_tpimodify myshixun, type
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
git_myshixun_url = git_myshixun_url_ip(myshixun, myshixun.try(:user_id))
git_myshixun_url = Base64.urlsafe_encode64(git_myshixun_url)
params = {tpiID: "#{myshixun.try(:id)}", :tpiGitURL => "#{git_myshixun_url}", :tpmID => "#{myshixun.shixun.try(:id)}"}
uri ="#{shixun_tomcat}/bridge/game/resetTpiScript"
params = {:gameInfo => "#{gameInfo}"}
logger.info("%%%%%%%%%%%%params is #{params}")
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级98")
end
end
# 若实训有更改,则修改已发不实训的标记为已更改
# shixun_modifies表中1表示已更改进入myshixun需要强制重置0表示没有修改
# type 0:表示已经是最新的了1表示已经有修改
# res返回结果0表示正确-1表示有异常
def add_shixun_modify_status shixun, type
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
# 更新测试集
gameInfo = shixun.gameInfo
uri ="#{shixun_tomcat}/bridge/game/publishGame"
# 更新脚本
tpiList =[]
myshixuns = shixun.myshixuns
if myshixuns.present?
myshixuns.each do |myshixun|
logger.info("tpiID is #{myshixun.id}")
tpiID = myshixun.id
instanceGitURL = git_myshixun_url_ip(myshixun, myshixun.try(:user_id))
logger.info("instanceGitURL is #{instanceGitURL}")
tpiList << {:tpiID => tpiID, :instanceGitURL => instanceGitURL}
logger.info("###############{tpiList.to_json unless tpiList.blank?}")
end
end
tpiList = Base64.urlsafe_encode64(tpiList.to_json) unless tpiList.blank?
params = {:gameInfo => "#{gameInfo}", :tpiList => "#{tpiList}" }
params = {:gameInfo => "#{gameInfo}"}
logger.info("%%%%%%%%%%%%params is #{params}")
# end
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级90")
end
shixun_modify_status_without_publish shixun, type
end
# 判断实训的路径、language是否更改如果修改在TPI中需要重置脚本
# 目前为止container为challenge和game类型
# 改工作必须在challenge或者game保存后执行
# type 1表示既需要提示又需要更新脚本的0表示仅仅需要提示
def should_modify_myshixun_script shixun, type
if type == 1
shixun.update_column(:reset_time, shixun.try(:updated_at))
else
shixun.update_column(:modify_time, shixun.try(:updated_at))
end
end
def shixun_modify_status_publish shixun, type
@ -207,17 +229,17 @@ module ApplicationHelper
file_content = tran_base64_decode64(file_content)
game_code = GameCode.where(:game_id => game_id).first
if game_code.nil?
if type == 0
GameCode.create!(:game_id => game_id, :original_code => file_content, :path => path)
else
# 这种情况正常是不会出现的,因为没创建成功抛异常,之所以这样写为了防止异常没处理的问题
GameCode.create!(:game_id => game_id, :original_code => file_content, :new_code => file_content, :path => path)
end
GameCode.create!(:game_id => game_id, :original_code => file_content, :new_code => file_content, :path => path)
else
game_code.update_attribute(:new_code, file_content)
end
end
def game_code_init game_id
game_code = GameCode.where(:game_id => game_id).first
GameCode.create(:game_id => game_id) if game_code.blank?
end
# 判断用户是否认证
def check_authentication
# return true
@ -236,6 +258,11 @@ module ApplicationHelper
str.gsub(" ", "<span class=\"empty\" style = \"background:#8d8787;\"></span>").gsub(/\r\n$/, "<i class=\"fa fa-level-down font-16\" style = \"color:#8d8787;\" aria-hidden=\"true\"></i>").gsub("\r\n", "<br>").gsub(/\t/, "<span class=\"tab-key\" style = \"background:#8d8787;\"><i class=\"fa fa-long-arrow-right color-grey3\" aria-hidden=\"true\"></i></span>").html_safe
end
# textarea 以/r/n开头时回车效果会被替换因此先把\r转换成\r 再添加一个\r直接添加\r不行
def match_specific_symbol1(str)
str.gsub(/\A\r/, "\r\r")
end
# 积分表中建立记录行为,有过奖励则不重复奖励
def reward_grade(user, container_id, container_type, score)
grade = Grade.where(:user_id => user.id, :container_id => container_id, :container_type => container_type).first
@ -271,7 +298,7 @@ module ApplicationHelper
# 实训语言的种类
def shixun_language
["Java", "C", "C++", "Python2.7", "Python3.6", "MySQL/Java", "Html", "JFinal", "Docker", "Ethereum", "Dynamips", "MachineLearning", "Verilog","Spark","MySQL/Python3.6","PHP","PHP/Web"]
["Java", "C", "C++", "Python2.7", "Python3.6", "MySQL/Java", "Html", "JFinal", "Docker", "Ethereum", "Dynamips", "MachineLearning", "Verilog","Spark","MySQL/Python3.6","PHP","PHP/Web","Hadoop"]
end
# 实训试用专业
@ -357,7 +384,7 @@ module ApplicationHelper
if myshixun.nil?
0
else
myshixun.games.select{|game| game.status == 2 && !game.answer_open}.count
myshixun.games.select{|game| game.status == 2 && game.final_score > 0}.count
end
end
@ -527,16 +554,18 @@ module ApplicationHelper
end
def git_myshixun_url_ip myshixun, user_id
g = Gitlab.client
login = User.where(:id => user_id).first.try(:login)
rep_identify = Repository.where(:myshixun_id => myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
rep_identify = g.project(myshixun.gpid).try(:name)
gitlab_address = Redmine::Configuration['gitlab_address_ip']
gitUrl = gitlab_address.to_s+"/"+login+"/"+ rep_identify + "."+"git"
end
# myshixun git url by domain
def git_myshixun_url myshixun, user_id
g = Gitlab.client
login = User.where(:id => user_id).first.try(:login)
rep_identify = Repository.where(:myshixun_id => myshixun.id, :type => "Repository::Gitlab").first.try(:identifier)
rep_identify = g.project(myshixun.gpid).try(:name)
gitlab_address = Redmine::Configuration['gitlab_address']
gitUrl = gitlab_address.to_s+"/"+login+"/"+ rep_identify + "."+"git"
end
@ -628,6 +657,35 @@ module ApplicationHelper
StudentWork.where("work_status !=? and homework_common_id=? and is_delete = 0",0, homework_common.id).count
end
# 实训作业的有效作品数
def effective_shixun_work_count homework_common
count = 0
shixun = homework_common.homework_commons_shixuns.shixun
if shixun
StudentWork.where("work_status !=? and homework_common_id=? and is_delete = 0",0, homework_common.id).each do |work|
if had_passed_changllenge_num(shixun, work.user) > 0
count = count + 1
end
end
end
count
end
# 实训作业的通关作品数
def tongguan_shixun_work_count homework_common
count = 0
shixun = homework_common.homework_commons_shixuns.shixun
if shixun
challenge_count = shixun.challenges.count
StudentWork.where("work_status !=? and homework_common_id=? and is_delete = 0",0, homework_common.id).each do |work|
if had_passed_changllenge_num(shixun, work.user) == challenge_count
count = count + 1
end
end
end
count
end
# 未提交作品数统计
def had_uncommit_studentwork_count homework_common
homework_common.course.student.count - homework_common.student_works.where("work_status !=?", 0).count
@ -2112,7 +2170,7 @@ module ApplicationHelper
title << "创新源于实践"
elsif @course
title << (@course.name.nil? ? "在线课堂" : @course.name)
elsif params[:controller] == "homework_bank"
elsif params[:controller] == "homework_bank" || params[:controller] == "question_banks" || params[:controller] == "exercise_bank"
title << ("题库")
elsif params[:controller] == "managements"
title << ("后台管理")
@ -2133,7 +2191,7 @@ module ApplicationHelper
elsif @organization
title << (@organization.name.nil? ? "创新源于实践" : @organization.name)
elsif @forum || params[:controller] == "forums"
title << "论坛"
title << "讨论区"
elsif @my_syllabuses
title << "我的课堂"
elsif @user
@ -4854,12 +4912,12 @@ end
def get_ex_index(exercise, course, is_teacher)
if is_teacher
exercises = course.exercises.order("created_at asc")
exercises = course.exercises.order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
else
exercises = course.exercises.where("exercise_status > 0").order("created_at asc")
exercises = course.exercises.where("exercise_status > 0").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
end
ex_ids = exercises.map{|ex| ex.id} if !exercises.blank?
index = ex_ids.index(exercise.id)
index = ex_ids.length - 1 - ex_ids.index(exercise.id)
return index
end
@ -4867,15 +4925,15 @@ def get_hw_index(hw,is_teacher,type=0)
homework_commons = hw.course.homework_commons
if is_teacher
if type != 0
homeworks = homework_commons.where("homework_commons.homework_type = #{type}").order("publish_time desc")
homeworks = homework_commons.where("homework_commons.homework_type = #{type}").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
else
homeworks = homework_commons.order("publish_time desc")
end
else
if type != 0
homeworks = homework_commons.where("homework_commons.homework_type = #{type} and publish_time <= '#{Time.now}'").order("publish_time desc")
homeworks = homework_commons.where("homework_commons.homework_type = #{type} and publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
else
homeworks = homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time desc")
homeworks = homework_commons.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC")
end
end
hw_ids = homeworks.map{|hw| hw.id} if !homeworks.blank?
@ -5010,13 +5068,28 @@ def create_works_list homework
name = homework.name
name_str = name + "的作品提交"
str = ""
students.each do |student|
if str != ""
str += ","
if homework.homework_type == 4
students.each do |student|
if str != ""
str += ","
end
myshixun = Myshixun.where(:shixun_id => homework.homework_commons_shixuns.shixun_id, :user_id => student.student_id).first
if myshixun
str += "('#{name_str}',#{homework.id},#{student.student_id}, 1, #{myshixun.id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
else
str += "('#{name_str}',#{homework.id},#{student.student_id}, 0, null, null, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
end
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{format_time(Time.now)}', '#{format_time(Time.now)}')"
sql = "insert into student_works (name, homework_common_id, user_id, work_status, myshixun_id, commit_time, created_at, updated_at) values" + str
else
students.each do |student|
if str != ""
str += ","
end
str += "('#{name_str}',#{homework.id},#{student.student_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
sql = "insert into student_works (name, homework_common_id, user_id, created_at, updated_at) values" + str
end
sql = "insert into student_works (name, homework_common_id,user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
@ -5371,7 +5444,7 @@ def quote_resource_bank resource, course
end
def quote_homework_bank homework, course
new_homework = HomeworkCommon.new(:name => homework.name, :user_id => User.current.id, :description => homework.description, :homework_type => homework.homework_type, :late_penalty => 0,
new_homework = HomeworkCommon.new(:name => homework.name, :user_id => User.current.id, :description => homework.description, :homework_type => homework.homework_type, :late_penalty => 5,
:course_id => course.id, :teacher_priority => 1, :anonymous_comment => 1, :quotes => 0, :is_open => 0, :homework_bank_id => homework.id, :score_open => 1,
:anonymous_appeal => 0, :is_public => 0, :reference_answer => homework.reference_answer, :answer_public => 1, :allow_late => 1)
@ -5427,7 +5500,45 @@ def quote_homework_bank homework, course
new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
new_homework.homework_detail_group.save if new_homework.homework_detail_group
homework.update_column(:quotes, homework.quotes+1)
QuestionBank.where(:container_id => homework.id, :container_type => ["Common", "Shixun"]).update_all(:quotes => homework.quotes)
end
return new_homework
end
def quote_exercise_bank exercise, course
new_exercise = Exercise.new(:exercise_name => exercise.name, :exercise_description => exercise.description, :user_id => User.current.id, :is_public => 0,
:exercise_status => 1, :show_result => 1, :course_id => course.id, :time => -1, :exercise_bank_id => exercise.id)
exercise.exercise_bank_questions.each do |q|
option = {
:question_title => q[:question_title],
:question_type => q[:question_type] || 1,
:question_number => q[:question_number],
:question_score => q[:question_score]
}
exercise_question = new_exercise.exercise_questions.new option
for i in 1..q.exercise_bank_choices.count
choice_option = {
:choice_position => i,
:choice_text => q.exercise_bank_choices[i-1][:choice_text]
}
exercise_question.exercise_choices.new choice_option
end
for i in 1..q.exercise_bank_standard_answers.count
standard_answer_option = {
:exercise_choice_id => q.exercise_bank_standard_answers[i-1][:exercise_bank_choice_id],
:answer_text => q.exercise_bank_standard_answers[i-1][:answer_text]
}
exercise_question.exercise_standard_answers.new standard_answer_option
end
end
if new_exercise.save
exercise.update_column(:quotes, exercise.quotes+1)
QuestionBank.where(:container_id => exercise.id, :container_type => "Exercise").update_all(:quotes => exercise.quotes)
end
return new_exercise
end
def major_level_option
@ -5496,3 +5607,45 @@ def syllabus_major_option fir_dis = 213
content
end
def convert_to_char(str)
result = ""
length = str.length
unless str.nil?
if length === 1
result += (str.to_i + 64).chr
return result
elsif length > 1
for i in 0...length
result += (str[i].to_i + 64).chr
end
return result
end
end
return result
end
def convert_to_chi_num num
result = ""
case num.to_i
when 1
result = '一'
when 2
result = '二'
when 3
result = '三'
when 4
result = '四'
when 5
result = '五'
when 6
result = '六'
when 7
result = '七'
when 8
result = '八'
when 9
result = '九'
end
return result
end

View File

@ -667,14 +667,14 @@ module CoursesHelper
end
#分班下拉框
def course_group_option course
def course_group_option course_groups
type = []
option1 = []
option1 << "选择分班"
option1 << 0
type << option1
unless course.course_groups.nil?
course.course_groups.each do |cg|
unless course_groups.nil?
course_groups.each do |cg|
option = []
option << cg.name
option << cg.id

View File

@ -0,0 +1,28 @@
module ExerciseBankHelper
def get_bank_current_score exercise
total_score = 0
mc_score = 0
mcq_score = 0
single_score = 0
multi_score = 0
unless exercise.nil?
exercise.exercise_bank_questions.each do |exercise_question|
unless exercise_question.question_score.nil?
total_score += exercise_question.question_score
case exercise_question.question_type
when 1
mc_score += exercise_question.question_score
when 2
mcq_score += exercise_question.question_score
when 3
single_score += exercise_question.question_score
when 4
multi_score += exercise_question.question_score
end
end
end
return total_score, mc_score, mcq_score, single_score, multi_score
end
return total_score, mc_score, mcq_score, single_score, multi_score
end
end

View File

@ -39,4 +39,8 @@ module ManagementsHelper
del_req.form_data = del_data
del_res = del_http.start { |http| http.request del_req }
end
def get_shixun_task id
HomeworkCommon.where(:course_id => id,:homework_type => 4)
end
end

View File

@ -0,0 +1,17 @@
module QuestionBanksHelper
def get_work_count work
work_count = 0
case work.container_type
when 'Common', 'Shixun'
bank = HomeworkBank.find work.container_id
work_count = StudentWork.where(:is_delete => 0, :work_status => [1, 2, 3], :homework_common_id => bank.homework_commons.map(&:id)).count
when 'Exercise'
bank = ExerciseBank.find work.container_id
work_count = ExerciseUser.where(:commit_status => 1, :exercise_id => Exercise.where(:exercise_bank_id => bank.id).map(&:id)).count
when 'Poll'
bank = ExerciseBank.find work.container_id
work_count = PollUser.where(:poll_id => Poll.where(:exercise_bank_id => bank.id).map(&:id)).count
end
work_count
end
end

View File

@ -3,14 +3,26 @@ include UserScoreHelper
module StudentWorkHelper
def update_shixun_work_status homework
homework.student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => homework.homework_commons_shixuns.shixun_id, :user_id => work.user_id).first
if myshixun
work.update_attributes(:work_status => myshixun.created_at <= homework.end_time ? 1 : 2, :late_penalty => myshixun.created_at <= homework.end_time ? 0 : homework.late_penalty, :commit_time => myshixun.created_at, :myshixun_id => myshixun.id)
if homework.end_time > Time.now
homework.student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => homework.homework_commons_shixuns.shixun_id, :user_id => work.user_id).first
if myshixun
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.created_at, :myshixun_id => myshixun.id)
end
end
set_shixun_final_score homework, work, homework.homework_detail_manual.answer_open_evaluation
end
else
homework.student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => homework.homework_commons_shixuns.shixun_id, :user_id => work.user_id).first
if myshixun
work.update_attributes(:work_status => (myshixun.status == 1 && (myshixun.updated_at < homework.end_time)) ? 1 : 2, :late_penalty => (myshixun.status == 1 && (myshixun.updated_at < homework.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.created_at, :myshixun_id => myshixun.id)
end
end
set_shixun_final_score homework, work, homework.homework_detail_manual.answer_open_evaluation
end
set_shixun_final_score homework, work, homework.homework_detail_manual.answer_open_evaluation
end
end

View File

@ -263,19 +263,31 @@ module WatchersHelper
end
#用户关注、取消关注
def watcher_link_for_user(target, user)
def watcher_link_for_user(target, user, type=0)
return '' unless user && user.logged?
watched = target.watched_by?(user)
text = watched ? '已关注' : '添加关注'
url = watch_path(:object_type => 'user',
:object_id => target.id,
:target_id => target.id)
if type == 0
url = watch_path(:object_type => 'user',
:object_id => target.id,
:target_id => target.id)
else
url = watch_path(:object_type => 'user',
:object_id => target.id,
:target_id => target.id,
:search => 1)
end
method = watched ? 'delete' : 'post'
id = watched ? 'cancel_watch' : ''
title = watched ? '取消关注' : '已关注'
if target != user
link_to text, url, :remote => true, :method => method, :remote => true,
:class => "fr font-14 user_watch",:id => id, :title => title
if type == 0
link_to text, url, :remote => true, :method => method, :remote => true,
:class => "fr font-14 user_watch",:id => id, :title => title
else
link_to text, url, :remote => true, :method => method, :remote => true,
:class => "white-btn orange-btn focus-on",:id => "cancel_watch_#{target.id}", :title => title
end
else
link_to "关注", "javascript:void(0)", :remote => true, :method => method,
:class => "fr font-14 user_watch", :id => id, :title => title

View File

@ -2,5 +2,5 @@ class ApplyUserAuthentication < ActiveRecord::Base
belongs_to :user
# status0 审核中 1 同意 2 拒绝 3 撤销
# auth_type1 实名认证, 2 职业认证
attr_accessible :auth_type, :dealer, :deal_time, :remarks, :status, :user_id
attr_accessible :auth_type, :dealer, :deal_time, :remarks, :status, :user_id, :is_delete
end

View File

@ -59,7 +59,7 @@ class Challenge < ActiveRecord::Base
def next_challenge
challenge_count = Challenge.where(:shixun_id => self.shixun_id).count
render_404 if self.position ==challenge_count
self.position = 0 if self.position == challenge_count
Challenge.where(:position => (self.position + 1), :shixun_id => self.shixun).first
end

View File

@ -20,7 +20,7 @@ class CourseMessage < ActiveRecord::Base
validates :course_message_id,presence: true
validates :course_message_type, presence: true
#validates_length_of :content, :maximum => 100
after_create :add_user_message
# after_create :add_user_message
def add_user_message
#unless self.course_message_type == 'JoinCourseRequest'

View File

@ -1,4 +1,4 @@
class Department < ActiveRecord::Base
belongs_to :school
attr_accessible :name, :school_id
end
class Department < ActiveRecord::Base
belongs_to :school
attr_accessible :name, :school_id, :is_auth
end

View File

@ -3,10 +3,12 @@ class Exercise < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :user
belongs_to :course ,:touch => true
belongs_to :exercise_bank
has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number"
has_many :exercise_users, :dependent => :destroy
has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过
# 课程消息
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
after_create :acts_as_course_message
def acts_as_course_message

View File

@ -0,0 +1,10 @@
class ExerciseBank < ActiveRecord::Base
belongs_to :user
belongs_to :course_list
has_many :exercise_bank_questions, :dependent => :destroy, :order => "#{ExerciseBankQuestion.table_name}.question_number"
attr_accessible :container_id, :container_type, :description, :is_public, :name, :quotes, :user_id, :course_list_id, :created_at, :updated_at
def course_list_name
self.course_list ? self.course_list.name : ""
end
end

View File

@ -0,0 +1,5 @@
class ExerciseBankChoice < ActiveRecord::Base
belongs_to :exercise_bank_question
has_many :exercise_bank_standard_answers
#attr_accessible :choice_position, :choice_text
end

View File

@ -0,0 +1,20 @@
#encoding: utf-8
class ExerciseBankQuestion < ActiveRecord::Base
belongs_to :exercise_bank
has_many :exercise_bank_choices, :dependent => :destroy
has_many :exercise_bank_standard_answers, :dependent => :destroy
#attr_accessible :question_number, :question_score, :question_title, :question_type
def question_type_name
case self.question_type
when 1
"单选题"
when 2
"多选题"
when 3
"填空题"
when 4
"简答题"
end
end
end

View File

@ -0,0 +1,5 @@
class ExerciseBankStandardAnswer < ActiveRecord::Base
belongs_to :exercise_bank_question
belongs_to :exercise_bank_choice
#attr_accessible :answer_text
end

View File

@ -135,6 +135,17 @@ class HomeworkCommon < ActiveRecord::Base
end
# 作业的实训
def shixun
Shixun.find(self.homework_commons_shixuns.try(:shixun_id))
end
# 作业实训过关的数目
def pass_game_count
user_id = self.course.student.map(&:student_id)
Myshixun.where(:shixun_id => self.shixun.try(:id), :status => 1, :user_id => user_id).count
end
#动态的更新
def update_activity
update_course_activity(self.class, self.id)

View File

@ -1,6 +1,7 @@
# encoding: utf-8
# status 1:完成实训
class Myshixun < ActiveRecord::Base
attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public, :identifier, :shixun_id
attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public, :identifier, :shixun_id, :modify_time, :reset_time
# has_many :users, :through => :myshixun_members
has_many :myshixun_members, :dependent => :destroy
has_one :repository, :dependent => :destroy
@ -10,6 +11,9 @@ class Myshixun < ActiveRecord::Base
has_one :webssh, :dependent => :destroy
has_many :student_works
validates :shixun_id, :uniqueness => {:scope => :user_id,
:message => "不能被重复开启"}
def total_stage
self.games.count
end
@ -48,7 +52,8 @@ class Myshixun < ActiveRecord::Base
score = 0
self.games.each do |game|
if game.status == 2
score += game.final_score.to_i
total_exp = game.answer_open? ? 0 : game.challenge.score.to_i
score += total_exp
end
end
score

View File

@ -4,6 +4,7 @@ class Poll < ActiveRecord::Base
include ApplicationHelper
belongs_to :user
belongs_to :exercise_bank
has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
has_many :poll_users, :dependent => :destroy
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过

View File

@ -0,0 +1,21 @@
#encoding: utf-8
class QuestionBank < ActiveRecord::Base
belongs_to :user
belongs_to :course_list
#attr_accessible :container_id, :container_type, :quotes
def bank_type
type = ""
case self.container_type
when 'Common'
type = "普通作业"
when 'Shixun'
type = "实训作业"
when 'Exercise'
type = "试卷"
when 'Poll'
type = "问卷"
end
type
end
end

View File

@ -1,16 +1,22 @@
# encoding: utf-8
# status 控制实训的状态0编辑1: 申请发布; 2正式发布 3关闭
# is_updated 字段为1表示实训的更改可能会影响到后续的评测0表示更改不会影响后续的评测
# 繁忙等级参数80发布实训失败返回code为-181实训开启的时候fork失败;83开启实训的时候openGameInstance返回非0值84jenkins系统异常post数据不成功
# reset_time表示需要更新脚本的时间
# modify_time表示仅测试集更新的时间
# 繁忙等级参数80发布实训失败返回code为-181实训开启的时候fork失败或者pull失败;83开启实训的时候openGameInstance返回非0值84jenkins系统异常post数据不成功
# 85challenge创建的时候Jenkins处理异常;86实训评测失败jenkins返回错误结果; 87版本库删除异常88点击评测失败没返回数据89重置链接jenkins返回失败
# 90: 更新公共测试用例失败返回code非091实训有改动评测的时候初始化数据返回数据code非092webssh开启失败接口getConnectInfo返回code值非0
# 93: 实训断开连接失败接口deleteSSH返回code值非0
# 94: 获取评测等待时间失败接口getWaitingTime返回code值为非0
# 95代码重置失败
# 96代码自动修复失败
# 97tpi获取当前代码为空
# 98更新tpi脚本异常
# 116challenge创建关卡的时候返回结果错误
#
class Shixun < ActiveRecord::Base
attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication,
:myshixun_count, :propaedeutics, :trainee, :major_id, :homepage_show, :webssh, :hidden, :fork_from, :can_copy
:myshixun_count, :propaedeutics, :trainee, :major_id, :homepage_show, :webssh, :hidden, :fork_from, :can_copy, :modify_time, :reset_time
has_many :users, :through => :shixun_members
has_many :shixun_members, :dependent => :destroy
@ -29,6 +35,13 @@ class Shixun < ActiveRecord::Base
scope :visible, lambda{where(status: [2,3])}
include ApplicationHelper
# 实训的版本库创建者为"educoder" 和"eduforge"
# "educoder"为原创,"eduforge"为复制的时候用户
def git_login
self.fork_from.blank? ? "educoder" : "eduforge"
end
# 获取特定格式的实训测试用例
# params = {:challengeStage => "#{@challenge.position}", :challengeType => "#{@challenge.evaluation_way.to_i}",
# :challengeProgramName => "#{@challenge.exec_path}",

View File

@ -32,7 +32,7 @@ class StudentsForCourse < ActiveRecord::Base
def create_student_works
course = self.course
str = ""
homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status != 0")
homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_type in (1, 4) and homework_detail_manuals.comment_status != 0")
if homeworks.count != 0
homeworks.each do |hw|
if hw.student_works.where("user_id = #{self.student_id}").count == 0

View File

@ -15,5 +15,79 @@ class Tiding < ActiveRecord::Base
attr_accessible :belong_container_id, :belong_container_type, :container_id, :container_type, :parent_container_id,
:parent_container_type, :status, :trigger_user_id, :user_id, :viewed
def subject
case at_message_type
when "Issue"
"新建问题: " + at_message.subject
when "Journal"
"问题留言: " + at_message.journalized.subject
when 'Message'
if(at_message.topic?)
"发布新帖: "
else
"回复帖子: "
end + at_message.subject
when 'JournalsForMessage'
if at_message.jour_type == 'Principal'
"留言: 在#{at_message.at_user.show_name}主页中留言"
else
"作业: #{at_message.jour.name} 中留言"
end
else
logger.error "error type: #{at_message_type}"
end
end
def description
case at_message_type
when "Issue"
at_message.description
when "Journal"
at_message.notes
when 'Message'
at_message.content
when "JournalsForMessage"
at_message.notes
else
logger.error "error type: #{at_message_type}"
end
end
def author
case at_message_type
when "Issue"
at_message.author
when "Journal"
at_message.user
when 'Message'
at_message.author
when 'JournalsForMessage'
at_message.user
else
logger.error "error type: #{at_message_type}"
end
end
def url
case at_message_type
when "Issue"
{controller: :issues, action: :show, id: at_message}
when "Journal"
{controller: :issues, action: :show, id: at_message.journalized}
when 'Message'
{controller: :boards, action: :show, project_id: at_message.board.project, id: at_message.board}
when 'JournalsForMessage'
if at_message.jour_type == 'Principal'
{controller: :users, action: :user_messages, id: at_message.at_user}
elsif at_message.jour_type == 'HomeworkCommon'
{controller: :homework_common, action: :index, course: at_message.jour.course_id}
elsif at_message.jour_type == 'Course'
{controller: :courses, action: :feedback, id: at_message.jour_id}
end
else
logger.error "error type: #{at_message_type}"
end
end
end

View File

@ -119,6 +119,8 @@ class User < Principal
#end
#题库
has_many :homework_banks, :dependent => :destroy
has_many :exercise_banks, :dependent => :destroy
has_many :question_banks, :dependent => :destroy
#竞赛
has_many :contests, :dependent => :destroy
has_many :works, :dependent => :destroy

View File

@ -1,106 +1,106 @@
# encoding: utf-8
=begin
identity字段含义
0
1
2
#3 开发者
=end
class UserExtensions < ActiveRecord::Base
validate :school, presence: true
belongs_to :user
belongs_to :school, :class_name => 'School', :foreign_key => :school_id
belongs_to :department
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id
validates_length_of :description, :maximum => 255
validates_length_of :brief_introduction, :maximum => 255
TEACHER = 0
STUDENT = 1
ENTERPRISE = 2
DEVELOPER = 3
#this method was used to update the table user_extensions
def update_user_extensions(birthday=nil,brief_introduction=nil,
gender=nil,location=nil,occupation=nil,work_experience=nil,zip_code=nil)
self.birthday = birthday
self.brief_introduction = brief_introduction
self.gender = gender
self.location = location
self.occupation = occupation
self.work_experience = work_experience
self.zip_code = zip_code
self.save
end
def get_brief_introduction
return self.brief_introduction
end
# added by meng
def show_identity
if User.current.language == 'zh'||User.current.language == ''
case self.identity
when 0
user_identity = l(:label_account_identity_teacher)
when 1
user_identity = l(:label_account_identity_student)
when 2
user_identity = l(:label_account_identity_professional)
when 3
user_identity = l(:label_account_identity_professional)
else
user_identity = ''
end
else
case self.identity
when 0
user_identity = l(:label_account_identity_teacher)
when 1
user_identity = l(:label_account_identity_student)
when 2
user_identity = l(:label_account_identity_professional)
when 3
user_identity = l(:label_account_identity_professional)
else
user_identity = ''
end
end
return user_identity
end
# end
def self.introduction(user, message)
unless user.user_extensions.nil?
info = user.user_extensions
info.brief_introduction = message
info.save
else
info = UserExtensions.new
info.user_id = user.id
info.brief_introduction = message
info.save
end
end
def user_technical_title
if self.technical_title
title = self.technical_title
else
case self.identity
when 0
title = l(:label_account_identity_teacher)
when 1
title = l(:label_account_identity_student)
when 2
title = l(:label_account_identity_professional)
when 3
title = l(:label_account_identity_professional)
else
title = ''
end
end
end
end
# encoding: utf-8
=begin
identity字段含义
0
1
2
#3 开发者
=end
class UserExtensions < ActiveRecord::Base
validate :school, presence: true
belongs_to :user
belongs_to :school, :class_name => 'School', :foreign_key => :school_id
belongs_to :department
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id,:school_id,:department_id
validates_length_of :description, :maximum => 255
validates_length_of :brief_introduction, :maximum => 255
TEACHER = 0
STUDENT = 1
ENTERPRISE = 2
DEVELOPER = 3
#this method was used to update the table user_extensions
def update_user_extensions(birthday=nil,brief_introduction=nil,
gender=nil,location=nil,occupation=nil,work_experience=nil,zip_code=nil)
self.birthday = birthday
self.brief_introduction = brief_introduction
self.gender = gender
self.location = location
self.occupation = occupation
self.work_experience = work_experience
self.zip_code = zip_code
self.save
end
def get_brief_introduction
return self.brief_introduction
end
# added by meng
def show_identity
if User.current.language == 'zh'||User.current.language == ''
case self.identity
when 0
user_identity = l(:label_account_identity_teacher)
when 1
user_identity = l(:label_account_identity_student)
when 2
user_identity = l(:label_account_identity_professional)
when 3
user_identity = l(:label_account_identity_professional)
else
user_identity = ''
end
else
case self.identity
when 0
user_identity = l(:label_account_identity_teacher)
when 1
user_identity = l(:label_account_identity_student)
when 2
user_identity = l(:label_account_identity_professional)
when 3
user_identity = l(:label_account_identity_professional)
else
user_identity = ''
end
end
return user_identity
end
# end
def self.introduction(user, message)
unless user.user_extensions.nil?
info = user.user_extensions
info.brief_introduction = message
info.save
else
info = UserExtensions.new
info.user_id = user.id
info.brief_introduction = message
info.save
end
end
def user_technical_title
if self.technical_title
title = self.technical_title
else
case self.identity
when 0
title = l(:label_account_identity_teacher)
when 1
title = l(:label_account_identity_student)
when 2
title = l(:label_account_identity_professional)
when 3
title = l(:label_account_identity_professional)
else
title = ''
end
end
end
end

View File

@ -356,9 +356,10 @@
if ($("input[name='occupation']").val() != '') { //如果已经有id了。肯定存在不用去找了。
return;
}
$("#search_school_result_list").html('');
$.ajax({
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value + '&page=' + page,
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value + '&page=1',
type: 'post',
success: function (data) {
schoolsResult = data.schools;
@ -366,7 +367,6 @@
maxPage = Math.ceil(count / 100); //最大页码值
if (schoolsResult.length != undefined && schoolsResult.length != 0) {
var i = 0;
$("#search_school_result_list").html('');
for (; i < schoolsResult.length; i++) {
link = '<a onclick="window.changeValue(\'' + schoolsResult[i].school.name.replace(/\s/g, " ") + '\',\'' + schoolsResult[i].school.id + '\')" href="javascript:void(0)">' + schoolsResult[i].school.name + '</a><br/>';
$("#search_school_result_list").append(link);
@ -383,7 +383,6 @@
$("#no_school_hint").hide();
}
} else {
$("#search_school_result_list").html('');
str = e.target.value.length > 4 ? e.target.value.substr(0, 4) + "..." : e.target.value;
$("#no_school_hint").html('你的单位不在列表中?请点击<a class="link-color-blue" onclick="apply_add_school();" href="javascript:void(0);">申请添加</a>');
$("#no_school_hint").show();

View File

@ -25,8 +25,13 @@
<% end %>
<% end %>
</li>
<li class="clearfix mb10">
<li class="clearfix mb10" style="position:relative;">
<%= image_tag(url_to_auth_img(user.id, 'ID'), :width => 200, :height => 150, :class => 'edu-renzheng-img fl mr20') %>
<% if apply_user.is_delete == true %>
<span style="position:absolute;bottom:0;">用户图片已删除</span>
<% else %>
<%= link_to "删除", delete_avatar_path(:source_type => 'UserAuthentication',:source_id => user.id ,:m_delete => '1' ), :method => 'post', :style => 'position:absolute;bottom:0;' %>
<% end %>
</li>
<% if apply_user.status == 2 %>
<li>原因:<span class="color-orange"><%= apply_user.remarks %></span></li>

View File

@ -1,71 +1,71 @@
<h3>
<%=l(:label_message_plural)%>
</h3>
<%= render 'tab_messages' %>
<h4><%= l(:label_forum) %></h4>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 30px; white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="来源(贴吧ID)">
来源(贴吧ID)
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 70px;">
时间
</th>
<th style="width: 120px;">
标题
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=@page * 30%>
<% for memo in @memo -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%= memo.forum_id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if memo.try(:author).try(:realname) == ' '%><%= memo.try(:author)%><% else %><%=memo.try(:author).try(:realname) %><% end %>'>
<% if memo.try(:author).try(:realname) == ' '%>
<%= link_to(memo.try(:author), user_path(memo.author)) %>
<% else %>
<%= link_to(memo.try(:author).try(:realname), user_path(memo.author)) %>
<% end %>
</td>
<td class="center">
<%= format_date(memo.created_at) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=memo.subject %>'>
<% if memo.parent_id.nil? || memo.subject.starts_with?('RE:')%>
<%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %>
<% else %>
<%= link_to("RE:"+memo.subject, forum_memo_path(memo.forum, memo), :target => "_blank") %>
<% end %>
</td>
<td class="center">
<%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_message_plural)) -%>
<h3>
<%=l(:label_message_plural)%>
</h3>
<%= render 'tab_messages' %>
<h4><%= l(:label_forum) %></h4>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 30px; white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title="来源(贴吧ID)">
来源(贴吧ID)
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 70px;">
时间
</th>
<th style="width: 120px;">
标题
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=@page * 30%>
<% for memo in @memo -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%= memo.forum_id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if memo.try(:author).try(:realname) == ' '%><%= memo.try(:author)%><% else %><%=memo.try(:author).try(:realname) %><% end %>'>
<% if memo.try(:author).try(:realname) == ' '%>
<%= link_to(memo.try(:author), user_path(memo.author)) %>
<% else %>
<%= link_to(memo.try(:author).try(:realname), user_path(memo.author)) %>
<% end %>
</td>
<td class="center">
<%= format_date(memo.created_at) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=memo.subject %>'>
<% if memo.parent_id.nil? || memo.subject.starts_with?('RE:')%>
<%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %>
<% else %>
<%= link_to("RE:"+ memo.subject.html_safe, forum_memo_path(memo.forum, memo), :target => "_blank") %>
<% end %>
</td>
<td class="center">
<%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_message_plural)) -%>

View File

@ -5,26 +5,72 @@
});
});
</script>
<span class="f16 fontBlue fb">选择版本 </span>
<p class="c_red">注:该文件有历史版本,请选择您需要的文件,点击文件名下载。</p>
<p class="fontGrey3 mb4 fb">版本及序号</p>
<div class="task-popup" style="width:600px;">
<div class="task-popup-title clearfix">
<h3 class="fl color-grey3">选择版本</h3>
<a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>
</div>
<div class="task-popup-content">
<p class="c_red">注:该文件有历史版本,请选择您需要的文件,点击文件名下载。</p>
<div class="clear mt5" id="attachment_history_popub">
<table class="muban_table mb15" style="text-align: center;" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="pl5" style="text-align: left;">资源名称</th>
<th width="60">版本号</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<%= link_to truncate(@attachment.filename,length: 35, omission: '...'),
download_named_attachment_path(@attachment.id, @attachment.filename),
:title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:410px;",:class => "linkBlue f14 fb fl ml5" %>
<span class="muban_icons_blue mt5 ml5 fl">当前版本</span>
</td>
<td>0</td>
</tr>
<% @attachment_histories.each do |history| %>
<tr>
<td>
<%= link_to truncate(history.filename,length: 35, omission: '...'),
download_named_attachment_path(history.id, history.filename),
:title => history.filename+"\n"+history.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:410px;",:class => "linkBlue f14 fb fl ml5" %>
<div style="max-height:165px; overflow-y:auto; background-color: #e3e3e3; line-height:33px;" class="p10">
</td>
<td><%= history.version %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% if false %>
<span class="f16 fontBlue fb">选择版本 </span>
<p class="c_red">注:该文件有历史版本,请选择您需要的文件,点击文件名下载。</p>
<p class="fontGrey3 mb4 fb">版本及序号</p>
<div style="max-height:165px; overflow-y:auto; background-color: #e3e3e3; line-height:33px;" class="p10">
<span class="attachment">
<%= link_to truncate(@attachment.filename,length: 35, omission: '...'),
download_named_attachment_path(@attachment.id, @attachment.filename),
:title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:280px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
</span>
<span class="fr">版本号:当前</span>
<div class="cl"></div>
<% @attachment_histories.each do |history| %>
<span class="fr">版本号:当前</span>
<div class="cl"></div>
<% @attachment_histories.each do |history| %>
<span class="attachment">
<%= link_to truncate(history.filename,length: 35, omission: '...'),
download_history_attachment_path(history.id, history.filename),
:title => history.filename+"\n"+history.description.to_s,
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
download_history_attachment_path(history.id, history.filename),
:title => history.filename+"\n"+history.description.to_s,
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
</span>
<span class="fr">版本号:<%= history.version %></span>
<div class="cl"></div>
<% end %>
</div>
<span class="fr">版本号:<%= history.version %></span>
<div class="cl"></div>
<% end %>
</div>
<% end %>

View File

@ -1,5 +1,8 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>');
showModal('ajax-modal', '452px');
//$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>');
//showModal('ajax-modal', '452px');
var htmlvalue = '<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>';
pop_box_new(htmlvalue, 550, 465);
/*
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
@ -7,4 +10,4 @@ $('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
//与更新版本弹窗js冲突新增样式代码
$('#ajax-modal').parent().css({"border":"3px solid #269ac9", "padding":"4px"});
$('#ajax-modal').css("padding","6.6px 13.2px 16px 16px");
$('#ajax-modal').css("padding","6.6px 13.2px 16px 16px");*/

View File

@ -1,11 +1,6 @@
<% if @flag %>
<% if @status == 1 %>
notice_box("更新成功");
submit_resource_search(); // 为了刷新
<% else %>
var htmlvalue = "<%=escape_javascript(render :partial => 'update_publish_time_box') %>";
pop_box_new(htmlvalue, 470, 140);
<% end %>
notice_box("更新成功");
<%else%>
$("#upload_file_count").html('(更新失败)');
<%end %>
<%end %>
$("#resource_detail_<%=@old_attachment.id %>").html("<%= escape_javascript(render :partial=>'files/resource_detail',:locals => {:file => @old_attachment}) %>");

View File

@ -38,7 +38,7 @@
<% if User.current.manager_of_shixun?(@shixun) %>
<p class="fr" id="shixun_icon_<%= index %>">
<% if @shixun.status == 0 %>
<a href="javascript:void(0);" class="mr5" onclick="delete_confirm_box_2('<%= shixun_challenge_path(challenge, :shixun_id => @shixun) %>', '确定要删除该任务吗?')" ><i class="fa fa-trash-o color-grey font-16" data-tip-down="删除"></i></a>
<a href="javascript:void(0);" class="mr5" onclick="delete_confirm_box_3('<%= shixun_challenge_path(challenge, :shixun_id => @shixun) %>', '确定要删除该任务吗?')" ><i class="fa fa-trash-o color-grey font-16" data-tip-down="删除"></i></a>
<% unless challenge.position < 2 %>
<a href="<%= index_up_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" data-remote="true"><i class="fa fa-long-arrow-up color-grey font-16 mr5" data-tip-down="上移"></i></a>
<% end %>
@ -56,13 +56,13 @@
<span class="mr100 itoblock_w150"><%= shixun_done(@shixun, challenge.position).to_i %>人&nbsp;完成挑战</span>
<span class="mr100 itoblock_w150"><%= shixun_running(@shixun, challenge.position).to_i %>人&nbsp;正在挑战</span>
<% if challenge.st != 0 %>
<span class="mr100 w150 g_frame"><%= challenge.choose_score %>经验值</span>
<span class="mr90 itoblock_w75 g_frame"><%= challenge.choose_score %>经验值</span>
<% else %>
<span class="mr100 w150 g_frame"><%= challenge.score %>经验值</span>
<span class="mr90 itoblock_w75 g_frame"><%= challenge.score %>经验值</span>
<% end %>
<% if @shixun.status == 2 %>
<% game = Game.where(:challenge_id => challenge.id, :user_id => User.current.id).first %>
<span class="mr390 fr">
<span class="mr350 fr">
<% case game.try(:status) %>
<% when 0 %>
待完成&nbsp;&nbsp;<a href='<%= operation_shixun_path(@shixun, :myshixun_id => challenge.current_user_game.try(:myshixun)) %>' data-remote="true"><i data-tip-down='点击开始' class='fa fa-play-circle color-light-green fr font-24 -text-danger w20_center'></i></a>

View File

@ -4,7 +4,7 @@
<span class="color-green fb fl" name="sample_inputs_label"></span>
<span class="fl mr20 ml10">
<input type="checkbox" name="test_set[lock][]" value="9" id="setlock_0" class="ml-3 mr5 magic-checkbox">
<label for="setlock_0" style="top: 0px;">锁定</label>
<label for="setlock_0" style="top: 0px;">隐藏</label>
</span>
<input type="hidden" name="test_set[hidden][]"/>
<a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a>
@ -45,27 +45,27 @@
<% if test_set.is_public? %>
<span class="fl mr20 ml10">
<input type="checkbox" name="test_set[lock][]" value="9" id="setlock_<%= index %>" class="ml-3 mr5 magic-checkbox">
<label for="setlock_<%= index %>" style="top: 0px;">锁定</label>
<label for="setlock_<%= index %>" style="top: 0px;">隐藏</label>
</span>
<!--<input type="checkbox" name="test_set[lock][]" class="fl ml5 mr5 mt8"><span class="fl mr5">锁定</span>-->
<!--<input type="checkbox" name="test_set[lock][]" class="fl ml5 mr5 mt8"><span class="fl mr5">隐藏</span>-->
<% else %>
<span class="fl mr20 ml10">
<input type="checkbox" name="test_set[lock][]" value="9" id="setlock_<%= index %>" class="ml-3 mr5 magic-checkbox" checked="checked">
<label for="setlock_<%= index %>" style="top: 0px;">锁定</label>
<label for="setlock_<%= index %>" style="top: 0px;">隐藏</label>
</span>
<!--<input type="checkbox" name="test_set[lock][]" class="fl ml5 mr5 mt8" checked="checked"><span class="fl mr5">锁定</span>-->
<!--<input type="checkbox" name="test_set[lock][]" class="fl ml5 mr5 mt8" checked="checked"><span class="fl mr5">隐藏</span>-->
<% end %>
<input type="hidden" name="test_set[hidden][]"/>
<% if index == 0 %>
<span class="color-grey fr" style="font-size:12px;">温馨提示:选中“锁定”,则对学员隐藏该条测试集,但在“提交评测”时也将被自动检测。</span>
<span class="color-grey fr" style="font-size:12px;">温馨提示:选中“隐藏”,则对学员隐藏该条测试集,但在“提交评测”时也将被自动检测。</span>
<% end %>
<a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a>
<% if index > 0 %>
<a href="javascript:void(0)" title="删除" class="sample_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt7"></i></a>
<% end %>
</p>
<textarea class="panel-form-width-40 panel-box-sizing" id="textarea_sample_input_test" name="test_set[input][]" placeholder="输入"><%= test_set.input %></textarea>
<textarea class="panel-form-width-40 panel-box-sizing" id="textarea_sample_output_test" name="test_set[output][]" placeholder="希望输出"><%= test_set.output %></textarea>
<textarea class="panel-form-width-40 panel-box-sizing" id="textarea_sample_input_test" name="test_set[input][]" placeholder="输入" wrap="hard"><%= match_specific_symbol1 test_set.input %></textarea>
<textarea class="panel-form-width-40 panel-box-sizing" id="textarea_sample_output_test" name="test_set[output][]" placeholder="希望输出"><%= match_specific_symbol1 test_set.output %></textarea>
</li>
<% end %>
</ul>
@ -75,10 +75,10 @@
<li class="clearfix">
<p class="clearfix">
<span class="color-green fb fl" name="sample_inputs_label">组1</span>
<span class="color-grey fr" style="font-size:12px;">温馨提示:选中“锁定”,在“提交评测”时它也将被自动检测,但学员暂不可查看内容。</span>
<span class="color-grey fr" style="font-size:12px;">温馨提示:选中“隐藏”,在“提交评测”时它也将被自动检测,但学员暂不可查看内容。</span>
<span class="fl mr20 ml10">
<input type="checkbox" name="test_set[lock][]" value="9" id="setlock_1" class="ml-3 mr5 magic-checkbox">
<label for="setlock_1" style="top: 0px;">锁定</label>
<label for="setlock_1" style="top: 0px;">隐藏</label>
</span>
<input type="hidden" name="test_set[hidden][]"/>
<a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a>
@ -178,7 +178,7 @@
});
});
// 判断测试集是否锁定, 0未锁定1锁定
// 判断测试集是否隐藏, 0未隐藏1隐藏
function test_set_whether_lock(){
var lock = document.getElementsByName("test_set[lock][]");
var hid = document.getElementsByName("test_set[hidden][]");

View File

@ -15,7 +15,7 @@
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
@ -38,25 +38,25 @@
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">B</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">C</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">D</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<% else%>
@ -64,7 +64,7 @@
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice <%= question.right_key ? "check-option-bg" : "" %>" onclick="selectchoice(this, <%= @challenge_choose.category %>);" name="option_span" data-tip-down="点击设置答案"><%= (question.try(:position) + 65).chr %></span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"><%= question.try(:option_name) %></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question[cnt][]" placeholder="请输入选项内容"><%= question.try(:option_name) %></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<% end %>
@ -194,6 +194,9 @@
}
$(function(){
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
var subject_editormd = editormd("challenge_choose_subject", {
width: "89.6%",
height: 400,
@ -274,6 +277,9 @@
}
}
}
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
$("#current-option").html("");
if($(".check-option-bg").length>0){
for(var i=0;i<$(".check-option-bg").length;i++){

View File

@ -2,7 +2,7 @@
'/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js' %>
<div class="white_bg">
<div class="panel-form">
<li class="clearfix pr30">
<li class="clearfix">
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
<a href="<%= edit_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.id, :index => @index) %>" data-remote="true" class="task-btn task-btn-green fr">编辑</a>
<a href="javascript:void(0);" onclick="delete_confirm_box_3('<%= destroy_challenge_choose_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.id) %>', '您是否确定删除?')" class="task-btn fr mr10 deloption-btn">删除</a>

View File

@ -46,7 +46,7 @@
</div>
<% if @challenge.st == 0 %>
<div class="stage-part mt20">
<ul class="nav_check_item border-bottom-orange clearfix">
<ul class="nav_check_item border-bottom-orange clearfix" style="margin-bottom: 0px">
<li class="fl <%= @tab == 1 ? "check_nav" : "" %>">
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 1) %>" class="color-black">本关任务</a>
</li>

View File

@ -56,7 +56,7 @@ a:hover{ }
<div style="display:none;" class="mt10" id="feedback_div">
<% get_memo %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum,:direct => "1")) do |f| %>
<%= f.text_area :subject, :id=>"subject", :style => "width: 570px;", :class => "feedbackText mb5", :placeholder => "请在此输入平台的问题和建议您也可以通过QQ留言谢谢" %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<span class="c_grey fl">还能输入<span id="textCount" class="c_orange">50</span>个字符</span>

View File

@ -45,6 +45,8 @@
<%= render :partial => 'users/course_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<% when 'Poll' %>
<%= render :partial => 'users/course_poll', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'Exercise' %>
<%= render :partial => 'users/course_exercise', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'JournalsForMessage' %>
<%= render :partial => 'users/course_journalsformessage', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'Attachment' %>

View File

@ -1,4 +1,4 @@
<div class="homepageRightBanner user_bg_shadow bor-grey-e mb10" style="width:1003px;padding: 0px" >
<div class="with100 user_bg_shadow bor-grey-e mb10" >
<div class="clearfix padding10">
<div class="NewsBannerName" style="width: 100px">
<%= get_acts_list_type @type %>
@ -9,6 +9,7 @@
<%= link_to "实训作业", {:controller => "courses", :action => "show", :type => "shixun_homework"}, :remote => true, :class =>"edu-filter-cir-grey mr15 font-12 #{@type == 'shixun_homework' ? 'active' : ''} fl"%>
<%= link_to "资源", {:controller => "courses", :action => "show", :type => "attachment"}, :remote => true, :class =>"edu-filter-cir-grey mr15 font-12 #{@type == 'attachment' ? 'active' : ''} fl"%>
<%= link_to "讨论", {:controller => "courses", :action => "show", :type => "message"}, :remote => true, :class =>"edu-filter-cir-grey mr15 font-12 #{@type == 'message' ? 'active' : ''} fl"%>
<%= link_to "试卷", {:controller => "courses", :action => "show", :type => "exercise"}, :remote => true, :class =>"edu-filter-cir-grey mr15 font-12 #{@type == 'exercise' ? 'active' : ''} fl"%>
<%#= link_to "成员管理", {:controller => "courses", :action => "show", :type => "message"}, :remote => true, :class =>"edu-filter-cir-grey mr15 font-12 #{@type == 'message' ? 'active' : ''} fl"%>
</div>
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,@course) %>
@ -48,6 +49,8 @@
</div>
</div>
<div class="cl"></div>
<% if false %>
<!--TO成员管理-->
<div class="resources mt10 user_bg_shadow bor-grey-e">
@ -78,6 +81,7 @@
</div>
</div>
<% end %>
<%= render :partial => 'courses/course_activity', :locals => {:course_activities => @course_activities,:page => 0,:type => @type} %>
<script>
$(function(){

View File

@ -119,7 +119,7 @@
<div class="sy_tips_box_inner undis" style="left: <%=is_teacher ? '230px' : '215px' %>; top: -60px; text-align: left;">
<span style="top: 75px;"></span>
<p >
<font class="fb"show_real_name.show_name %>(<%=user.login %>)</font><br/>
<font class="fb">(<%=user.login %>)</font><br/>
资源&nbsp;&nbsp;&nbsp;&nbsp;发布数:<%= member.resource_num.nil? ? 0 : member.resource_num %><br/>
<font class="mr15">问答&nbsp;&nbsp;&nbsp;&nbsp;发布数:<%= member.message_num.nil? ? 0 : member.message_num %></font>回复数:<%= member.message_reply_num.nil? ? 0 : member.message_reply_num %><br/>
<font class="mr15">通知&nbsp;&nbsp;&nbsp;&nbsp;提交数:<%= member.news_num.nil? ? 0 : member.news_num %></font>留言数:<%= member.news_reply_num.nil? ? 0 : member.news_reply_num %><br/>
@ -139,7 +139,7 @@
<span class="hidden" style="display:inline-block; vertical-align:middle; max-width:70px;"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
<a href="javascript:void(0)" class="sy_icons_edit pic_edit_icon fr mt9 options_show_or_hide" alt="编辑" style="background-position:0 5px;"></a>
</div>
<%= select( :name,:group_id, course_group_option(@course),
<%= select( :name,:group_id, course_group_option(@course.course_groups),
{ :include_blank => false,:selected => member.course_group_id},
{:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w100 undis class-edit sy_fenban_select", :style => "margin-left: 5px;"}) %>
<% end %>

View File

@ -127,13 +127,8 @@
course_list_name = $("#new_course_list").val();
});
$("#new_course_list").on('click', function (e) {
if ($("#new_course_list").val().trim() != '') { //如果已经有id了。肯定存在不用去找了。
event.stopPropagation();
return;
} else{
search_course_ajax('');
event.stopPropagation();
}
search_course_ajax($("#new_course_list").val().trim());
e.stopPropagation();
});
$(".course_list_ul").on('click', 'p', function(event) {
$("#new_course_list").val($(this).html());

View File

@ -106,7 +106,7 @@
$(".course_list_ul").on('click', 'p',function(event) {
$("#edit_course_list").val($(this).html());
if($("#edit_course_name").val() == ""){
$("#edit_course_name").val($("#edit_course_list").val());
$("#edit_course_name").val($("#edit_course_list").val().trim());
} else{
if($("#edit_course_name").val().indexOf(course_list_name) == 0){
$("#edit_course_name").val($("#edit_course_name").val().replace(course_list_name, $("#edit_course_list").val()));

View File

@ -16,7 +16,7 @@
</div>
<div class="clearfix mb15">
<% if @course.course_groups.count > 0 %>
<%= select_tag :course_group_id,options_for_select(course_group_option(@course),0), {:id=>"course_group_id", :class=>"task-form-100 task-height-40 panel-box-sizing mb10 color-grey3"} %>
<%= select_tag :course_group_id,options_for_select(course_group_option(@course.course_groups),0), {:id=>"course_group_id", :class=>"task-form-100 task-height-40 panel-box-sizing mb10 color-grey3"} %>
<% end %>
<div class="mb10 edu-position" style="text-align: right">

View File

@ -9,7 +9,7 @@
<input type="hidden" name="member_ids[]" value="<%= id %>">
<% end %>
<input type="hidden" name="type" value="<%= @type %>">
<%= select_tag :course_group_id,options_for_select(course_group_option(@course),0), {:id=>"course_group_id", :class=>"task-height-40 color-grey ml10", :style => 'width:400px;border:1px solid #ddd;background:#fff;'} %>
<%= select_tag :course_group_id,options_for_select(course_group_option(@groups),0), {:id=>"course_group_id", :class=>"task-height-40 color-grey ml10", :style => 'width:400px;border:1px solid #ddd;background:#fff;'} %>
<div class="cl"></div>
<span class="color-orange none" id="choose_course_group_notice">请先选择一个分班</span>
<% end %>

View File

@ -24,7 +24,8 @@
<% if is_teacher %>
<p class="fl task-form-60 ml15">
<!--<a class="mr15 white-btn orange-btn">移动到</a>-->
<a href="javascript:void(0)" onclick="delete_students('has', <%= @course.id %>, '<%= @group.id %>');" class="white-btn">删除</a>
<a href="javascript:void(0)" onclick="join_group('has', <%= @course.id %>, <%= @group.id %>);" class="white-btn orange-btn">移动到</a>
<a href="javascript:void(0)" onclick="delete_students('has', <%= @course.id %>, '<%= @group.id %>');" class="ml15 white-btn">删除</a>
<span id="no_student_notice" class="ml15 font-12 color-red undis">请先选择学生</span>
</p>
<% elsif User.current.member_of_course?(@course) && @course.choose_group_allow && @course.members.where(:user_id => User.current.id).first.course_group_id != @group.id %>

View File

@ -15,7 +15,7 @@
<th width="10%">姓名</th>
<th width="12%">学号</th>
<th width="10%">分班</th>
<th width="13%" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis">作业成绩</th>
<th width="13%" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis">课堂成绩</th>
<th width="10%">发布资源</th>
<th width="10%">发布帖子</th>
<th width="10%">回复评论</th>
@ -41,7 +41,7 @@
<td><%= link_to user.show_real_name, user_path(user), :class => 'edu-txt-w140 task-hide mt5 alink-name', :target => '_blank' %></td>
<td><span class="edu-txt-w140 task-hide mt5"><%= user.user_extensions ? user.user_extensions.student_id : '' %></span></td>
<td><%= member.course_group_id == 0 ? '未分班' : member.course_group.name %></td>
<td><%= student_course_homework_score @course, user %></td><!--作业成绩-->
<td><%= format("%.1f",member.course_score) %></td><!--课堂成绩-->
<td><%= student_course_resource_num @course, user %></td>
<td><%= student_course_message_num @course, user %></td>
<td><%= student_course_reply_num @course, user %></td>

View File

@ -7,7 +7,8 @@
</script>
<input type="hidden" value="<%= @type%>" name="type" id="user_activities_type">
<div class="homepageRight mt0 " style="width:85%; float:left;">
<div class="with85 fl">
<div class="ml15 clearfix">
<% if false %>
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,@course) %>
<ul class="with100 mb20 ml15 clearfix df activities_btn font-16" style="width:1003px;">
@ -30,4 +31,5 @@
<div id="course_activities_content">
<%= render :partial => 'courses/course_activity_content', :locals => {:course_activities => @course_activities} %>
</div>
</div>
</div>

View File

@ -8,6 +8,12 @@ if($("#sy_08").length > 0){
} else{
$(".stud-class-set .news .container .member .people .left ul li[data-option='allstudent']").click();
}
<% elsif params[:type] == "has" %>
if($("#sy_08").length > 0){
window.location.href = "/courses/<%= @course.id %>/has_group_student_list?group_id=<%= @old_group.id %>";
} else{
$(".stud-class-set .news .container .member .people .left ul li[data-group-id='<%= @old_group.id %>']").click();
}
<% else %>
if($("#sy_09").length > 0){
window.location.href = "/courses/<%= @course.id %>/no_group_student_list";

View File

@ -1,6 +1,5 @@
console.log(111);
for(var i=0; i<$("#apply_add_department_<%= @apply_dep.id %>").nextAll().length; i++){
var index = parseInt($($("#apply_add_department_<%= @apply_dep.id %>").nextAll()[i]).children(":first").html());
$($("#apply_add_department_<%= @apply_dep.id %>").nextAll()[i]).children(":first").html(index - 1);
for(var i=0; i<$("#apply_add_department_<%= @department.id %>").nextAll().length; i++){
var index = parseInt($($("#apply_add_department_<%= @department.id %>").nextAll()[i]).children(":first").html());
$($("#apply_add_department_<%= @department.id %>").nextAll()[i]).children(":first").html(index - 1);
}
$("#apply_add_department_<%= @apply_dep.id %>").remove();
$("#apply_add_department_<%= @department.id %>").remove();

View File

@ -36,14 +36,14 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice <%= (index + 1) == exercise_question.exercise_standard_answers.first.exercise_choice_id ? 'check-option-bg' : '' %>" name="option_span" data-tip-down="点击设置答案" onclick="selectchoice(this)"><%=convert_to_char (index+1).to_s %></span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name='question_answer[<%=exercise_choice.id %>]' placeholder="请输入选项内容"><%=exercise_choice.choice_text %></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name='question_answer[<%=exercise_choice.id %>]' placeholder="请输入选项内容"><%=exercise_choice.choice_text %></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeSingle(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<div class="cl"></div>
<% end %>
<li class="clearfix mb20">
<label class="panel-form-label fl">
<span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span">D</span>
<span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span"><%=convert_to_char (exercise_question.exercise_choices.count+1).to_s %></span>
</label>
<div class="fl panel-box-sizing add-option-input border-dash-orange">
<a title="新增" href="javascript:void(0)" class="option_icon_add" onclick="addSingle(this)">新增选项</a>

View File

@ -40,7 +40,7 @@
<label class="panel-form-label fl">
<span class="<%= exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s.include?((index+1).to_s) ? 'check-option-bg' : '' %> option-item fr mr10 color-grey select-choice " onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案"><%=convert_to_char (index+1).to_s %></span>
</label>
<textarea name='question_answer[<%= exercise_choice.id %>]' class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入选项内容"><%=exercise_choice.choice_text %></textarea>
<textarea name='question_answer[<%= exercise_choice.id %>]' class="panel-form-width2-690 fl panel-box-sizing candiate_answer" placeholder="请输入选项内容"><%=exercise_choice.choice_text %></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<div class="cl"></div>
@ -49,7 +49,7 @@
<li class="clearfix mb20">
<label class="panel-form-label fl">
<span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_spans">D</span>
<span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_spans"><%=convert_to_char (exercise_question.exercise_choices.count+1).to_s %></span>
</label>
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" href="javascript:void(0)" onclick="addMuli(this)" class="option_icon_add">新增选项</a></div>
</li>

View File

@ -54,4 +54,4 @@
</p>
</li>
</div>
<% end %>
<% end %>

View File

@ -33,7 +33,7 @@
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" name="option_span" onclick="selectchoice(this)" data-tip-down="点击设置答案">A</span></label>
<input type="hidden" name="choice[answer][]">
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question_answer[]" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeSingle(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
@ -41,7 +41,7 @@
<script id="t:set-option-lists" type="text/html">
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案">A</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question_answer[]" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
@ -49,210 +49,15 @@
<script id="t:set-fillin-lists" type="text/html">
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="fill_span">答案 2</span></label>
<textarea class="candiate_answer panel-form-width2-690 fl panel-box-sizing" name="exercise_choice[]" placeholder="请输入参考答案(可选)"></textarea>
<textarea class="candiate_answer panel-form-width2-690 fl panel-box-sizing candiate_answer" name="exercise_choice[]" placeholder="请输入参考答案(可选)"></textarea>
<a title="移除" href="javascript:void(0)" onclick="removefill(this)" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
<script>
/*填空题操作*/
function addfill(item){
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var html = bt('t:set-fillin-lists', null);
$(item).parent().parent('.clearfix').before(html);
$(item).parent().parent('.clearfix').prev().find('textarea').attr("name", "exercise_choice["+new Date().getTime()+"]");
var inputs = document.getElementsByName("exercise_choice[]");
var inputs_spans=$(item).parents(".fillin_Temp").find("li span[name='fill_span']");
//var inputs_spans = document.getElementsByName("fill_span");
for (var j = 0; j < inputs_spans.length; j++) {
var countChar=convert_to_chi_num(j+1);
$(inputs_spans[j]).html("答案 "+countChar);
}
// for (var i = 0; i < inputs.length; i++) {
// autoTextarea(inputs[i], 0, 140);
// }
$(inputs[inputs.length - 1]).focus();
}
function convert_to_chi_num(num){
var toChar="";
switch(num){
case 1:
return toChar="一";
break;
case 2:
return toChar="二";
break;
case 3:
return toChar="三";
break;
case 4:
return toChar="四";
break;
case 5:
return toChar="五";
break;
case 6:
return toChar="六";
break;
case 7:
return toChar="七";
break;
case 8:
return toChar="八";
break;
case 9:
return toChar="九";
break;
}
}
function removefill(item){
var temp=$(item).parents(".fillin_Temp");
$(item).parents('li').remove();
var inputs_spans=temp.find("li span[name='fill_span']");
//var inputs_spans = document.getElementsByName("fill_span");
for (var j = 0; j < parseInt(inputs_spans.length); j++) {
var countChar=convert_to_chi_num(j+1);
$(inputs_spans[j]).html("答案 "+countChar);
}
}
/*选择题操作*/
function removeMuli(item){
var temp=$(item).parents("li").siblings("div").find(".current-option");
var count=0;
var exercise_choice = $(item).parents(".multiple_Temp").find("input[name='exercise_choice']");
var muil=$(item).parents(".multiple_Temp").find(".check-option-bg");
var pare=$(item).parents(".multiple_Temp");
if($(item).parents("li").find("label span").hasClass("check-option-bg")){
count++;
}
$(item).parents('li').remove();
var inputs_spans=pare.find("li span[name='option_spans']");
//var inputs_spans = document.getElementsByName("option_spans");
for (var j = 0; j < parseInt(inputs_spans.length)-count; j++) {
if(j >= 0 && j <= 26){
if(j >= 0 && j <= 26){
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
}
}
}
temp.html("");
if(parseInt(muil.length)-count>0){
for(var i=0;i<parseInt(muil.length)-count;i++){
temp.html(temp.html()+muil.eq(i).html());
}
exercise_choice.val(temp.html());
}else{
exercise_choice.val('');
temp.html("请点击正确选项");
}
}
function addMuli(item){
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var html = bt('t:set-option-lists', null);
$(item).parent().parent('.clearfix').before(html);
$(item).parent().parent('.clearfix').prev().find('textarea').attr("name", "question_answer["+new Date().getTime()+"]");
var inputs = document.getElementsByName("question_answer[]");
var inputs_spans=$(item).parents(".multiple_Temp").find("li span[name='option_spans']");
//var inputs_spans = document.getElementsByName("option_spans");
for (var j = 0; j < inputs_spans.length; j++) {
if(j >= 0 && j <= 26){
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
}
}
$(inputs[inputs.length - 1]).focus();
}
function selectMul(item){
var temp=$(item).parents(".multiple_Temp");
var exercise_choice = $(temp).find("input[name='exercise_choice']");
temp.find("li").removeClass("check-option-bg");
$(item).toggleClass("check-option-bg");
temp.find(".current-option").html("");
if(temp.find(".check-option-bg").length>0){
for(var i=0;i<temp.find(".check-option-bg").length;i++){
temp.find(".current-option").html(temp.find(".current-option").html()+temp.find(".check-option-bg").eq(i).html());
}
exercise_choice.val(temp.find(".current-option").html());
}else{
temp.find(".current-option").html("请点击正确选项");
exercise_choice.val('');
}
}
/*单选题操作*/
function addSingle(item){
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var html = bt('t:set-option-list', null);
$(item).parent().parent('.clearfix').before(html);
$(item).parent().parent('.clearfix').prev().find('textarea').attr("name", "question_answer["+new Date().getTime()+"]");
var inputs = document.getElementsByName("question_answer[]");
var inputs_spans=$(item).parents(".single_Temp").find("li span[name='option_span']");
//var inputs_spans = document.getElementsByName("option_span");
for (var j = 0; j < inputs_spans.length; j++) {
if(j >= 0 && j <= 26){
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
}
}
$(inputs[inputs.length - 1]).focus();
}
function removeSingle(item){
var temp=$(item).parents("li").siblings("div").find(".current-option");
var exercise_choice = $(item).parents(".single_Temp").find("input[name='exercise_choice']");
var singl=$(item).parents(".single_Temp").find(".check-option-bg");
var pare=$(item).parents(".single_Temp");
temp.html("");
var count=0;
if($(item).parents("li").find("label span").hasClass("check-option-bg")){
count++;
}
$(item).parents('li').remove();
var inputs_spans=pare.find("li span[name='option_span']");
//var inputs_spans = document.getElementsByName("option_span");
for (var j = 0; j < parseInt(inputs_spans.length)-count; j++) {
if(j >= 0 && j <= 26){
if(j >= 0 && j <= 26){
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
}
}
}
if(parseInt(singl.length)-count>0){
for(var i=0;i<parseInt(singl.length)-count;i++){
temp.html(temp.html()+singl.eq(i).html());
}
exercise_choice.val(temp.html());
}else{
temp.html("请点击正确选项");
exercise_choice.val('');
}
}
function selectchoice(item){
var temp=$(item).parents(".single_Temp");
var exercise_choice = $(temp).find("input[name='exercise_choice']");
$(temp).find("li span").removeClass("check-option-bg");
$(item).toggleClass("check-option-bg");
temp.find(".current-option").html("");
if(temp.find(".check-option-bg").length>0){
for(var i=0;i<temp.find(".check-option-bg").length;i++){
temp.find(".current-option").html(temp.find(".current-option").html()+temp.find(".check-option-bg").eq(i).html());
}
exercise_choice.val(temp.find(".current-option").html());
}else{
temp.find(".current-option").html("请点击正确选项");
exercise_choice.val('');
}
$(function(){
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
});
</script>

View File

@ -14,7 +14,7 @@
<div class="edu-find-input">
<input type="text" class="with100 panel-box-sizing" name="search" placeholder="输入试卷名称进行搜索" value="<%= @search %>" id="exercise_name_search">
<!--<i class="fa fa-close mr5 color-grey edu-close" onclick="colse_searchbox();"></i>-->
<span class="edu-close" onclick="colse_searchbox();" data-tip-down="关闭">×</span>
<span class="edu-close" onclick="colse_searchbox();" data-tip-down="清除">×</span>
</div>
<a href="javascript:void(0);" onclick="$('#exercise_search_form').submit();" class="edu-open font-16 color-grey "><i class="fa fa-search"></i></a>
</div>

View File

@ -8,6 +8,7 @@
<p class="ml15 fl font-16 mt5">发布设置</p>
<% if @is_teacher %>
<a href="javascript:void(0);" class="white-btn orange-btn fr mr15 mt15" title="编辑" onclick="show_ex_edit_setting();">编辑</a>
<% end %>
</div>
<div class="ml30 mr30">
@ -105,19 +106,19 @@
<p class="ml15 fl font-16 mt10">公开设置</p>
</div>
<div class="ml30 mr30 mb15">
<div class="clearfix">
<div class="clearfix pl30">
<ul>
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
<input class="magic-checkbox fl mt5 magic-checkbox_show" type="checkbox" disabled <%= @exercise.score_open ? 'checked' : '' %>>
<label class="fl">公开成绩</label>
<span class="fl color-grey">(选中则在截止时间之后对班级学生公开所有成员的成绩,否则不公开)</span>
<label class="fl" style="top: 0px">公开成绩</label>
<span class="fl color-grey mt4">(选中则在截止时间之后对班级学生公开所有成员的成绩,否则不公开)</span>
</li>
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
<input class="magic-checkbox fl mt5 magic-checkbox_show" type="checkbox" disabled <%= @exercise.answer_open ? 'checked' : '' %>>
<label class="fl">公开答案</label>
<span class="fl color-grey">(选中则在截止时间之后对班级学生公开试卷题目的答案,否则不公开)</span>
<label class="fl" style="top: 0px">公开答案</label>
<span class="fl color-grey mt4">(选中则在截止时间之后对班级学生公开试卷题目的答案,否则不公开)</span>
</li>
</ul>
</div>
@ -232,7 +233,7 @@
<p class="ml15 fl font-16 mt10">公开设置</p>
</div>
<div class="ml30 mr30">
<div class="clearfix">
<div class="clearfix pl30">
<ul>
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
@ -351,6 +352,6 @@
<div class="clearfix mt15 mb15 mr15 pr10 <%= edit_mode ? '' : 'none' %>" id="exam_setting_submit_block">
<a href="javascript:void(0);" onclick="ex_setting_form_submit();" class="task-btn task-btn-orange fr">保存</a>
<a href="javascript:void(0);" onclick="s_op_confirm_box('<%= student_exercise_list_exercise_path(@exercise) %>', '修改的内容将全部丢失<br/>是否确认取消保存')" class="task-btn fr mr10">取消</a>
<a href="javascript:void(0);" onclick="hide_ex_edit_setting()" class="task-btn fr mr10">取消</a>
</div>
</div>

View File

@ -1,10 +1,7 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#homework_page_right").css("min-height",$("#courseLSide").height()-33);
$("#Container").css("width","1000px");
var end_time = <%=@exercise.end_time.to_i%>;
getTime(end_time);
getTime();
/*start_time = new Date();
start_time.setFullYear(<%#=exercise_user.start_at.year%>);
start_time.setMonth(<%#=exercise_user.start_at.month%>);
@ -16,15 +13,43 @@
end_time = start_time.getTime() + 1000*60*<%#=exercise.time %>;
getTime(end_time);*/
});
function getTime(end_time) {
function getTime() {
var second=parseInt($("#time_second").html());
var minute=parseInt($("#time_minute").html());
var hour=parseInt($("#time_hour").html());
var inter=setInterval(function () {
second=parseInt($("#time_second").html());
minute=parseInt($("#time_minute").html());
hour=parseInt($("#time_hour").html());
$("#time_second").html(To_num(second));
if(hour>0 && To_num(second)=="59"){
$("#time_minute").html(To_num(minute));
if(To_num(minute)=="59"){
$("#time_hour").html(To_num(hour));
}
}
if(hour==0 && To_num(second)=="59"){
$("#time_minute").html(To_num(minute));
}
if(second==0 && minute==0 && hour==0){
//alert("over");
clearInterval(inter);
$("#time_second").html("00");
$("#time_minute").html("00");
$("#time_hour").html("00");
long_notice_box("时间到了,已自动提交");
}
},1000);
//alert(end_time);
now = new Date();
/*now = new Date();
var total_seconds = now.getTime()/1000 - end_time;
if (total_seconds > 0) {
$("#exercise_submit_btn").click();
return;
}
setTimeout("getTime("+end_time+");", 1000);
}*/
//setTimeout("getTime("+end_time+");", 1000);
//start = new Date(start_time);
//end_time = start_time;
//var total_seconds = total_seconds - 1;
@ -41,12 +66,25 @@
//setTimeout("getTime("+end_time+");", 1000);
//}
}
function To_num(num){
if(num<=10 && num>0){
num--;
return "0"+ num;
} else if(num==0){
return "59";
}else if(num>10){
num--;
return num;
}
console.log(num);
}
</script>
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<%= link_to @course.name, course_path(@course) %> &gt; <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> &gt; <%= link_to @exercise.exercise_name, student_exercise_list_exercise_path(@exercise) %> &gt; <%= @exercise_user.user.show_real_name %>
<%= link_to @course.name, course_path(@course) %> &gt; <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> &gt; <%= link_to "#"+(get_ex_index(@exercise, @course, @is_teacher) + 1).to_s, student_exercise_list_exercise_path(@exercise) %> &gt; <%= @exercise_user.user.show_real_name %>
</p>
<div class="edu-con-top clearfix user_bg_shadow bor-grey-e mb20">
<p class="ml15 fl color-grey3">
@ -56,7 +94,13 @@
<%= @exercise.exercise_name %>
</p>
<span class="fr mr15 mt3 color-grey"><%= format_time @exercise_user.start_at %> 开始答题</span>
<!--<div class="fr time_panel mr15 ml10">
<span class="time" id="time_hour">00</span>
<span class="factorial">:</span>
<span class="time" id="time_minute">00</span>
<span class="factorial">:</span>
<span class="time" id="time_second">10</span>
</div>-->
</div>
<% if !@exercise.try(:exercise_description).nil? && @exercise.try(:exercise_description) != "" %>
@ -73,6 +117,7 @@
<div class="clearfix pl15">
<span class="checkstatus_box_small post_btn_white mt10" style="border: 1px solid #CCCCCC;"></span><span class="fl mr20 font-12 mt3">已答</span>
<span class="checkstatus_box_small post_btn_grey mt10"></span><span class="fl mr20 font-12 mt3">未答</span>
<span class="fr mr15 mt3 color-grey font-12"><%= format_time @exercise_user.start_at %> 开始答题</span>
</div>
<% if @exercise.question_random == 1 %>
<% question_list = @exercise.exercise_questions.shuffle %>
@ -92,7 +137,7 @@
<div class="clearfix pl15 pr15">
<p class="fl font-15" id="mao<%=i+1 %>">第<%= i + 1 %>题:<span class="color-orange03 ml10">[<%= exercise_question.question_type_name %>]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
</div>
<div class="pl15 pr15 justify"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 justify upload_img table_maxWidth"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>
<% when 1 %>
<div class="pl15 pr15 mb15">
@ -180,6 +225,13 @@
<% when 3 %>
<div class="ml15 mr15 mb15 mt10">
<script>
$(function(){
$(function(){
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
})
})
function onblur_<%= exercise_question.id %>(obj)
{
$(window).unbind('beforeunload');
@ -205,7 +257,7 @@
});
}
</script>
<textarea placeholder="在此填入答案" class="pl15 task-height-40 with100" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %></textarea>
<textarea placeholder="在此填入答案" style="box-sizing: border-box" class="pl15 task-height-40 with100 candiate_answer" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %></textarea>
</div>
<% when 4 %>
<div class="ml15 mr15 mb15 mt10">
@ -235,7 +287,7 @@
});
}
</script>
<textarea class="task-height-150 with100 pl15" name="exercise_choice" placeholder="在此填入答案" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %></textarea>
<textarea class="task-height-150 with100 pl15" style="box-sizing: border-box" name="exercise_choice" placeholder="在此填入答案" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %></textarea>
</div>
<% end %>
</div>

View File

@ -13,7 +13,7 @@
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<%= link_to @course.name, course_path(@course) %> &gt; <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> &gt; <%= link_to @exercise.exercise_name, student_exercise_list_exercise_path(@exercise) %> &gt; <%= @exercise_user.user.show_real_name %>
<%= link_to @course.name, course_path(@course) %> &gt; <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> &gt; <%= link_to "#"+(get_ex_index(@exercise, @course, @is_teacher) + 1).to_s, student_exercise_list_exercise_path(@exercise) %> &gt; <%= @exercise_user.user.show_real_name %>
</p>
<div class="edu-con-top clearfix user_bg_shadow bor-grey-e mb20">
<p class="ml15 fl color-grey3">
@ -56,8 +56,8 @@
</div>
<div class="clearfix ml80 mt10 mb15">
<% @exercise.exercise_questions.where(:question_type => 4).each_with_index do |eq, index| %>
<% ea = User.current.exercise_answer.where(:exercise_question_id => eq.id).first %>
<a href="#mao<%= eq.question_number%>" style="cursor:pointer" id="ex_comment_status_<%= eq.id %>" class="checkstatus_box_big <%= (ea && ea.score != -1) ? 'post_btn_white' : 'post_btn_grey' %>"><%= eq.question_number %></a>
<% ea = @exercise_user.user.exercise_answer.where(:exercise_question_id => eq.id).first %>
<a href="#mao<%= eq.question_number%>" style="cursor:pointer" id="ex_comment_status_<%= eq.id %>" class="checkstatus_box_big <%= (ea && ea.score == -1) ? 'post_btn_grey' : 'post_btn_white' %>"><%= eq.question_number %></a>
<% end %>
</div>
@ -75,7 +75,7 @@
<p class="fr" id="multi_q_score_<%= exercise_question.id %>"><span class="<%= answer.empty? ? 'color-red' : (answer.first.score == -1 || answer.first.score == 0 ? "color-red" : "color-light-green") %> mr3"><%= answer.empty? ? 0 : (answer.first.score == -1 ? "未批" : answer.first.score) %></span><%= answer.empty? ? "分" : (answer.first.score == -1 ? "" : "分") %></p>
<% end %>
</div>
<div class="pl15 pr15 justify"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 justify upload_img table_maxWidth"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>
<% when 1 %>
<div class="pl15 pr15 mb15">

View File

@ -2,7 +2,7 @@
<div class="mh550">
<% @exercises.each do |exercise| %>
<div class="clearfix edu-class-con-list pr">
<div class="fl ml15 task-form-90 ">
<div class="fl task-form-100" style="box-sizing: border-box;padding-left: 15px">
<span class="fl mr10 mt3 color-grey3"># <%= get_ex_index(exercise, @course, @is_teacher) + 1 %></span>
<%= link_to exercise.exercise_name, student_exercise_list_exercise_path(exercise), :class => "edu-class-inner-list fl color-grey3" %>
<% unless exercise.is_public %>
@ -12,55 +12,84 @@
<% if ex_curr_status[:status] != "" %>
<span class="edu-filter-btn <%= homework_status_color ex_curr_status[:status] %> ml10 fl mt3"><%= ex_curr_status[:status] %></span>
<% end %>
<% if !@is_teacher && User.current.member_of_course?(@course) && exercise.exercise_users.where("user_id = #{User.current.id} and commit_status > 0").blank? %>
<span class="btn-top btn-cir-orange ml10 fl mt3">未提交</span>
<% end %>
<div class="cl"></div>
<p class="color-grey font-12 mt20">
<span>创建于<%=time_from_now exercise.created_at %></span>
<span class="ml25">更新于<%=time_from_now exercise.updated_at %></span>
<p class="color-grey font-12 mt20 fl">
<% if exercise.try(:exercise_status) == 1 %>
<span class="fl">创建于<%=time_from_now exercise.created_at %></span>
<% else %>
<span class="fl">发布于<%=time_from_now exercise.publish_time %></span>
<% end %>
<% if exercise.try(:exercise_status) > 1 %>
<% if @is_teacher %>
<span class="ml50">
<span class="ml50 fl">
<%= link_to exercise.exercise_users.where("commit_status = 1").count, student_exercise_list_exercise_path(exercise, :ex_status => ['1']), :class => "color-orange05 mr3", :target =>"_blank" %>
已答</span>
<span class="ml50">
<span class="ml50 fl">
<%= link_to (exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count), student_exercise_list_exercise_path(exercise, :ex_status => ['0']), :class => "color-orange05 mr3", :target =>"_blank" %>
未答</span>
<%# count = exercise.exercise_users.where("commit_status = 1 and subjective_score = -1").count %>
<span class="ml50">
<span class="ml50 fl">
<%= link_to un_commit_num(exercise), student_exercise_list_exercise_path(exercise, :ex_comment => ['0']), :class => "color-orange05 mr3", :target =>"_blank" %>
未评</span>
<% else %>
<span class="ml50">
<span class="ml50 fl">
<%= link_to exercise.exercise_users.where("commit_status = 1").count, student_exercise_list_exercise_path(exercise), :class => "color-orange05 mr3", :target =>"_blank" %>
已答</span>
<span class="ml50">
<span class="ml50 fl">
<%= link_to (exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count), student_exercise_list_exercise_path(exercise), :class => "color-orange05 mr3", :target =>"_blank" %>
未答</span>
<% end %>
<% end %>
<% if exercise.try(:exercise_status) == 1 && exercise.publish_time %>
<span class="ml50 color-grey">将于&nbsp;<span class="color-orange"><%= format_time(exercise.publish_time).to_s %></span>&nbsp;发布</span>
<span class="ml50 color-grey fl">将于&nbsp;<span class="color-orange"><%= format_time(exercise.publish_time).to_s %></span>&nbsp;发布</span>
<% else %>
<span class="ml50 <%= exercise.try(:exercise_status) == 3 ? 'color-grey' : 'color-orange' %>"><%= ex_curr_status[:time] %></span>
<span class="ml50 fl <%= exercise.try(:exercise_status) == 3 ? 'color-grey' : 'color-orange' %>"><%= ex_curr_status[:time] %></span>
<% end %>
</p>
<% if !@is_teacher && User.current.member_of_course?(@course) %>
<% exercise_user = exercise.exercise_users.where("user_id = #{User.current.id} and commit_status > 0").first %>
<% if exercise_user %>
<%= link_to '查看答题', exercise.exercise_status < 3 ? exercise_path(exercise,:user_id => User.current.id) : show_student_result_exercise_path(exercise,:user_id => User.current.id), :class => "fr white-btn orange-btn mr15 mt10" %>
<% else %>
<% if exercise.exercise_status == 2 %>
<%= link_to (exercise_user.try(:start_at).nil? ? "开始答题" : "继续答题"), exercise_path(exercise,:user_id => User.current.id), :class => "fr white-btn orange-btn mr15 mt10" %>
<% end %>
<% end %>
<% end %>
</div>
<% if @is_teacher %>
<div class="fr edu-position edu-position-hidebox mr20 mt5">
<div class="fr edu-position-hidebox" style="position: absolute;right: 20px;top: 15px;">
<a href="javascript:void(0);"><i class="fa fa-bars font-16"></i></a>
<ul class="edu-position-hide undis">
<% if exercise.exercise_status == 1 %>
<li><%= link_to "编辑", edit_exercise_path(exercise) %></li>
<% end %>
<!--<li><%#= link_to "预览", exercise_path(exercise) %></li>-->
<li><%= link_to "设置", student_exercise_list_exercise_path(exercise, :tab => 3) %></li>
<li><%= link_to "导出成绩", student_exercise_list_exercise_path(exercise.id,:course_id => @course.id, :format => 'xls') %></li>
<% unless exercise.is_public %>
<li id="set_exercise_public_<%= exercise.id %>">
<a href="javascript:void(0);" onclick="delete_confirm_box('<%= set_public_exercise_path(exercise) %>', '您确定要公开吗?<br/>公开后不能重设为私有')">设为公开</a>
</li>
<% end %>
<!--<li><a href="javascript:void(0)">加入题库</a></li>-->
<li><a href="javascript:void(0)" onclick="delete_confirm_box_3('<%= exercise_path(exercise) %>', '删除后,学生的答题情况将全部丢失,无法恢复<br/>确定要删除该试卷吗?')">删除</a></li>
<% if exercise.exercise_status == 1 %>
<li><%= link_to "编辑", edit_exercise_path(exercise) %></li>
<% end %>
<!--<li><%#= link_to "预览", exercise_path(exercise) %></li>-->
<li><%= link_to "设置", student_exercise_list_exercise_path(exercise, :tab => 3) %></li>
<% if exercise.exercise_status == 1 && exercise.publish_time %>
<li>
<a href="javascript:void(0);" onclick="s_op_confirm_box('<%= publish_exercise_exercise_path(exercise) %>', '将发布时间改为当前时间,即刻发布')">立即发布</a>
</li>
<% elsif exercise.exercise_status == 2 && exercise.end_time > Time.now %>
<li>
<a href="javascript:void(0);" onclick="s_op_confirm_box('<%= end_exercise_exercise_path(exercise) %>', '将截止时间改为当前时间,立即截止<br/>您将不能再修改截止时间')">立即截止</a>
</li>
<% end %>
<li><%= link_to "导出成绩", student_exercise_list_exercise_path(exercise.id,:course_id => @course.id, :format => 'xls') %></li>
<% unless exercise.is_public %>
<li id="set_exercise_public_<%= exercise.id %>">
<a href="javascript:void(0);" onclick="delete_confirm_box('<%= set_public_exercise_path(exercise) %>', '您确定要公开吗?<br/>公开后不能重设为私有')">设为公开</a>
</li>
<% end %>
<% if (User.current.teacher_of_course(exercise.course) || exercise.user == User.current) && exercise.exercise_bank_id.nil? %>
<li class="add_to_exercise_bank_<%= exercise.id %>">
<%= link_to "加入题库", add_to_exercise_bank_exercise_path(exercise), :remote => true %>
</li>
<% end %>
<li><a href="javascript:void(0)" onclick="delete_confirm_box_3('<%= exercise_path(exercise) %>', '删除后,学生的答题情况将全部丢失,无法恢复<br/>确定要删除该试卷吗?')">删除</a></li>
</ul>
</div>
<% end %>

View File

@ -23,21 +23,21 @@
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this)" name="option_span" data-tip-down="点击设置答案">A</span>
</label>
<textarea maxlength="200" name='question_answer[0]' class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入选项内容"></textarea>
<textarea maxlength="200" name='question_answer[0]' class="panel-form-width2-690 fl panel-box-sizing candiate_answer" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeSingle(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice " onclick="selectchoice(this)" name="option_span" data-tip-down="点击设置答案">B</span>
</label>
<textarea maxlength="200" name='question_answer[1]' class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入选项内容"></textarea>
<textarea maxlength="200" name='question_answer[1]' class="panel-form-width2-690 fl panel-box-sizing candiate_answer" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeSingle(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this)" name="option_span" data-tip-down="点击设置答案">C</span>
</label>
<textarea maxlength="200" name='question_answer[2]' class="panel-form-width2-690 fl panel-box-sizing" placeholder="请输入选项内容"></textarea>
<textarea maxlength="200" name='question_answer[2]' class="panel-form-width2-690 fl panel-box-sizing candiate_answer" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeSingle(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix mb20">
@ -69,5 +69,8 @@
$("#add_new_question").one('click', function(){
add_ex_question($(this),1);
});
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
});
</script>

View File

@ -14,32 +14,39 @@
</div>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">题目</span></label>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing candiate_answer undis"></textarea>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice " onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案">A</span>
</label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[0]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question_answer[0]" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice " onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案">B</span>
</label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[1]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question_answer[1]" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice " onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案">C</span>
</label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[2]" placeholder="请输入选项内容"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="question_answer[2]" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl">
<span class="option-item fr mr10 color-grey select-choice " onclick="selectMul(this)" name="option_spans" data-tip-down="点击设置答案">D</span>
</label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question_answer[3]" placeholder="请输入选项内容"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removeMuli(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix mb20">
<label class="panel-form-label fl">
<span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_spans">D</span>
<span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_spans">E</span>
</label>
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" href="javascript:void(0)" onclick="addMuli(this)" class="option_icon_add">新增选项</a></div>
</li>
@ -63,5 +70,8 @@
$("#add_new_question").one('click', function(){
add_ex_question($(this),2);
});
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
});
</script>

View File

@ -14,4 +14,22 @@
<p class="fr">
<a href="javascript:void(0)" onclick="ex_head_submit($(this));" class="fr task-btn mr15 task-btn-orange">保存</a>
</p>
<% end %>
<% end %>
<script>
$(function(){
$("#exercise_head_edit").on("keydown", "input[name='exercise[exercise_name]']", function(event){
var code;
if (!event) {
event = window.event; //针对ie浏览器
code = event.keyCode;
}
else {
code = event.keyCode;
}
if(code == 13) {
event.preventDefault();
return false;
}
});
});
</script>

View File

@ -14,12 +14,12 @@
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="fill_span">答案 一</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="exercise_choice[0]" placeholder="请输入参考答案"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="exercise_choice[0]" placeholder="请输入参考答案"></textarea>
<!--<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>-->
</li>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="fr mr10 color-grey" name="fill_span">答案 二</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="exercise_choice[1]" placeholder="请输入参考答案(可选)"></textarea>
<textarea class="panel-form-width2-690 fl panel-box-sizing candiate_answer" name="exercise_choice[1]" placeholder="请输入参考答案(可选)"></textarea>
<a title="移除" href="javascript:void(0)" class="position-delete option_icon_remove" onclick="removefill(this)"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
<li class="clearfix mb20">
@ -46,5 +46,8 @@
$("#add_new_question").one('click', function(){
add_ex_question($(this),3);
});
for (var i = 0; i < $(".candiate_answer").length; i++) {
autoTextarea($(".candiate_answer")[i], 0, 140);
}
});
</script>

View File

@ -5,8 +5,8 @@
</div>
<div class="task-popup-content">
<div class="clearfix mb15 test_nav_content">
<a href="javascript:void(0)" class="edu-filter-cir-grey mr20 active fl">我的试卷</a>
<!--<a href="javascript:void(0)" class="edu-filter-cir-grey mr20 fl">公共试卷</a>-->
<a href="<%= other_exercise_exercise_index_path(:type => 1) %>" id="user_exercises_choose" class="edu-filter-cir-grey active mr20 fl" data-remote="true">我的试卷</a>
<a href="<%= other_exercise_exercise_index_path(:type => 2) %>" id="public_exercises_choose" class="edu-filter-cir-grey mr20 fl" data-remote="true">公共试卷</a>
<div class="edu-find fr with40 mr20 pr">
<div class="edu-find-input">
<input type="text" class="with100 panel-box-sizing" name="search" maxlength="40" placeholder="输入试卷标题的关键字进行搜索" id="exercise_list_name_search">
@ -41,16 +41,6 @@
}
}
function search_exercise_list(){
$.ajax({
url: '/exercise/other_exercise?search='+ $("#exercise_list_name_search").val() +'&course_id=<%=@course_id %>',
type: 'get',
remote: true,
success: function(data){
}
});
}
//清空搜索框
function colse_searchbox(){
if($("#exercise_list_name_search").val().trim() == ""){

View File

@ -1,28 +1,60 @@
<div class="mh400">
<table class="edu-pop-table interval-td color-grey bor-grey-e" cellspacing="0" cellpadding="0">
<tbody>
<% @exercises.each do |exercise| %>
<tr>
<td class="pl5 pr5">
<input type="radio" name="exercise_id" value="<%= exercise.id %>" id="exercise_<%= exercise.id %>" class="ml-3 mr5 magic-radio">
<label style="top:0px;line-height: 27px;width: 544px;" class="task-hide color-grey3" for="exercise_<%= exercise.id %>"><%= exercise.exercise_name %></label>
</td>
</tr>
<% if @type == '1' || (@type == '2' && User.current.user_extensions.identity == 0 && User.current.professional_certification) %>
<div class="mh400">
<table class="edu-pop-table interval-td color-grey bor-grey-e" cellspacing="0" cellpadding="0">
<tbody>
<% if @type == '1' %>
<% @exercises.each do |exercise| %>
<tr>
<td class="pl5 pr5">
<input type="radio" name="exercise_id" value="<%= exercise.id %>" id="exercise_<%= exercise.id %>" class="ml-3 mr5 magic-radio">
<label style="top:0px;line-height: 27px;" for="exercise_<%= exercise.id %>"></label>
<%= link_to exercise.name, exercise_bank_path(exercise), :target => '_blank', :title => "#{exercise.name}", :style => "max-width: 540px; display: block;", :class => 'task-hide color-grey3 ml30' %>
</td>
</tr>
<% end %>
<% else %>
<% @exercises.each do |exercise| %>
<tr>
<td class="pl5 pr5">
<input type="radio" name="exercise_id" value="<%= exercise.id %>" id="exercise_<%= exercise.id %>" class="ml-3 mr5 magic-radio">
<label style="top:0px;line-height: 27px;" for="exercise_<%= exercise.id %>"></label>
<%= link_to exercise.name, exercise_bank_path(exercise), :target => '_blank', :title => "#{exercise.name}", :style => "max-width: 420px; display: block;", :class => 'task-hide color-grey3 ml30' %>
</td>
<td class="pl5 pr5 ml10">
<%= link_to exercise.user.show_real_name, user_path(exercise.user), :target => '_blank', :title => "#{exercise.user.show_real_name}", :style => "width: 120px; text-align: center; display: block;", :class => 'task-hide color-grey3' %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
<div class="clearfix mt15">
<p class="none c_red" id="choose_exercise_notice"></p>
<div class="fl pages_little_show">
<ul>
<%= pagination_links_full @ex_pages, @ex_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</tbody>
</table>
</div>
<div class="clearfix mt15">
<p class="none c_red" id="choose_exercise_notice"></p>
<div class="fr">
<a href="javascript:void(0)" class="task-btn task-btn-orange fr" onclick="submit_import_form();">确定</a>
<a href="javascript:void(0)" class="task-btn fr pop_close mr10" onclick="hideModal();">取消</a>
</div>
</div>
<div class="fl pages_little_show">
<ul>
<%= pagination_links_full @ex_pages, @ex_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
<div class="fr">
<a href="javascript:void(0)" class="task-btn task-btn-orange fr" onclick="submit_import_form();">确定</a>
<a href="javascript:void(0)" class="task-btn fr pop_close mr10" onclick="hideModal();">取消</a>
</div>
</div>
<% else %>
<div class="identity_con bor-grey-e" style="text-align: center;padding:155px 0px;">
<p class="font-16 mb30">已经过职业认证的教师才能访问公共题库</p>
<p><a href="<%= professional_certification_account_path %>" target="_blank" class="white-btn orange-btn">立即认证</a>
</p>
</div>
<div class="clearfix mt15">
<div class="fr">
<a href="javascript:void(0)" class="task-btn task-btn-orange fr" onclick="hideModal();">确定</a>
<a href="javascript:void(0)" class="task-btn fr pop_close mr10" onclick="hideModal();">取消</a>
</div>
</div>
<% end %>

View File

@ -55,6 +55,7 @@
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
new_quetion_title_editor.focus();
params.textarea.data('init', 1);
}
});

View File

@ -54,6 +54,7 @@
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
new_quetion_title_editor.focus();
params.textarea.data('init', 1);
}
});

View File

@ -47,6 +47,7 @@
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
new_quetion_title_editor.focus();
params.textarea.data('init', 1);
}
});

View File

@ -48,6 +48,7 @@
if(params.textarea.data('init') == undefined) {
params.editor = init_exercise_quetison_editor(params);
new_quetion_title_editor = params.editor;
new_quetion_title_editor.focus();
params.textarea.data('init', 1);
}
});

View File

@ -67,7 +67,7 @@
<% if @is_teacher %>
<%= link_to '评阅', show_student_result_exercise_path(@exercise,:user_id => exercise.user_id), :target => "_blank" %>
<% else %>
<%= link_to '查看', exercise.commit_status == 1 ? exercise_path(@exercise,:user_id => exercise.user_id) : show_student_result_exercise_path(@exercise,:user_id => exercise.user_id), :target => "_blank" %>
<%= link_to '查看', @exercise.exercise_status < 3 ? exercise_path(@exercise,:user_id => exercise.user_id) : show_student_result_exercise_path(@exercise,:user_id => exercise.user_id), :target => "_blank" %>
<% end %>
<% else %>
--

View File

@ -0,0 +1,2 @@
notice_sure_box("加入题库成功");
$(".add_to_exercise_bank_<%= @exercise.id %>").remove();

View File

@ -2,7 +2,7 @@
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<%= link_to @course.name, course_path(@course) %> &gt; <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> &gt; <%= link_to @exercise.exercise_name, student_exercise_list_exercise_path(@exercise) %> &gt; 编辑
<%= link_to @course.name, course_path(@course) %> &gt; <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> &gt; <%= link_to "#"+(get_ex_index(@exercise, @course, @is_teacher) + 1).to_s, student_exercise_list_exercise_path(@exercise) %> &gt; 编辑
</p>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20">
<p class="ml15 color-grey3 fl">编辑试卷</p>

View File

@ -1 +1,6 @@
notice_box_redirect("<%= student_exercise_list_exercise_path(@exercise, :tab => 3) %>", "导入成功");
<% if @status %>
var str = "该试卷中有未设置标准答案的题目,请务必先补充再发布";
<% else %>
var str = "导入成功";
<% end %>
notice_box_redirect("<%= student_exercise_list_exercise_path(@exercise, :tab => 3) %>", str);

View File

@ -51,8 +51,8 @@
<div class="edu-con-top clearfix">
<p class="ml15 color-grey3 fl">试卷列表</p>
<% if @is_teacher %>
<a href="<%= new_exercise_path(:course_id => @course.id) %>" class="white-btn orange-btn fr mr20 mt3" title="新建">+&nbsp;新建</a>
<a href="<%= other_exercise_exercise_index_path(:course_id => @course.id) %>" data-remote="true" class="white-btn orange-btn fr mr20 mt3">+&nbsp;试卷选用</a>
<a href="<%= new_exercise_path(:course_id => @course.id) %>" class="white-btn orange-btn fr mr20 mt3" title="新建">新建</a>
<a href="<%= other_exercise_exercise_index_path(:course_id => @course.id) %>" data-remote="true" class="white-btn orange-btn fr mr20 mt3">试卷选用</a>
<!--<a href="javascript:void(0)" class="white-btn orange-btn fr mr20 mt3" data-remote="true" title="题库选用">+&nbsp;题库选用</a>-->
<!--<a href="javascript:void(0)" class="white-btn orange-btn fr mr20 mt3" data-remote="true" title="导出成绩">导出成绩</a>-->
<% end %>

View File

@ -1,10 +1,25 @@
<% if @exercises.blank? %>
notice_box("您的其它班级下没有试卷可供导入");
<% else %>
<% unless params[:search] %>
var html_value = '<%= escape_javascript(render :partial => 'other_exercises') %>';
pop_box_new(html_value, 620, 568);
<% else %>
$("#test_nav_1").html("<%= j(render :partial => "select_examination_list") %>");
<% if params[:search] || params[:type] || params[:page] %>
$("#test_nav_1").html("<%= j(render :partial => "select_examination_list") %>");
<% if params[:type] && params[:search].nil? %>
$("#exercise_list_name_search").val('');
<% if @type == '1' %>
$("#user_exercises_choose").addClass("active");
$("#public_exercises_choose").removeClass("active");
<% else %>
$("#public_exercises_choose").addClass("active");
$("#user_exercises_choose").removeClass("active");
<% end %>
<% end %>
<% end %>
<% else %>
var html_value = '<%= escape_javascript(render :partial => 'other_exercises') %>';
pop_box_new(html_value, 620, 568);
<% end %>
function search_exercise_list(){
$.ajax({
url: '/exercise/other_exercise?search='+ $("#exercise_list_name_search").val() +'&type=<%=@type %>',
type: 'get',
remote: true,
success: function(data){
}
});
}

View File

@ -130,13 +130,13 @@
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
<input class="magic-checkbox fl mt5 magic-checkbox_show" type="checkbox" disabled <%= @exercise.score_open ? 'checked' : '' %>>
<label class="fl">公开成绩</label>
<label class="fl" style="top: 0px">公开成绩</label>
<span class="fl color-grey">(选中则在截止时间之后对班级学生公开所有成员的成绩,否则不公开)</span>
</li>
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
<input class="magic-checkbox fl mt5 magic-checkbox_show" type="checkbox" disabled <%= @exercise.answer_open ? 'checked' : '' %>>
<label class="fl">公开答案</label>
<label class="fl" style="top: 0px">公开答案</label>
<span class="fl color-grey">(选中则在截止时间之后对班级学生公开试卷题目的答案,否则不公开)</span>
</li>
</ul>

View File

@ -35,7 +35,7 @@
<li id="edu-tab-nav-3" class="new-tab-nav" onclick="HoverLi(3);">
<a href="javascript:void(0);" class="tab_type">设置</a>
</li>
<%= link_to "导出成绩", student_exercise_list_exercise_path(@exercise, :course_id => @course.id, :format => 'xls'), :id => "export_exercise_work", :class => "fr white-btn orange-btn ml10 mt10 mr15" %>
<%= link_to "导出成绩", student_exercise_list_exercise_path(@exercise, :course_id => @course.id, :format => 'xls'), :id => "export_exercise_work", :class => "fr white-btn orange-btn mt10 mr15" %>
<% else %>
<li id="edu-tab-nav-3" class="new-tab-nav" onclick="HoverLi(3);">
<a href="javascript:void(0);" class="tab_type">查看设置</a>
@ -44,7 +44,7 @@
<% ex_user = @exercise.exercise_users.where(:user_id => User.current).first %>
<% if ex_user %>
<% if ex_user.commit_status > 0 %>
<%= link_to '查看答题', ex_user.commit_status == 1 ? exercise_path(@exercise,:user_id => User.current.id) : show_student_result_exercise_path(@exercise,:user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<%= link_to '查看答题', @exercise.exercise_status < 3 ? exercise_path(@exercise,:user_id => User.current.id) : show_student_result_exercise_path(@exercise,:user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
<% else %>
<% if @exercise.exercise_status == 2 %>
<%= link_to (ex_user.start_at.nil? ? "开始答题" : "继续答题"), exercise_path(@exercise,:user_id => User.current.id), :class => "white-btn orange-btn fr mt10 mr15" %>
@ -53,6 +53,11 @@
<% end %>
</p>
<% end %>
<% if @exercise.exercise_status == 1 && @exercise.publish_time %>
<a href="javascript:void(0);" class="white-btn orange-btn fr mr15 mt10" onclick="s_op_confirm_box('<%= publish_exercise_exercise_path(@exercise) %>', '将发布时间改为当前时间,即刻发布')">立即发布</a>
<% elsif @exercise.exercise_status == 2 && @exercise.end_time > Time.now %>
<a href="javascript:void(0);" class="white-btn orange-btn fr mr15 mt10" onclick="s_op_confirm_box('<%= end_exercise_exercise_path(@exercise) %>', '将截止时间改为当前时间,立即截止<br/>您将不能再修改截止时间')">立即截止</a>
<% end %>
</ul>
<div id="edu-tab-con-1">
<div id="list_count" class="user_bg_shadow bor-grey-e padding15">
@ -177,7 +182,7 @@
<% end %>
</div>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE">
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
标准答案:<%= exercise_question.exercise_standard_answers.first ? convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) : "" %>
</div>
<% when 2 %>
<div class="pl15 pr15 mb15">
@ -190,7 +195,7 @@
<% end %>
</div>
<div class=" pl15 pr15 pt10 pb10 bor-top-greyE">
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
标准答案:<%= exercise_question.exercise_standard_answers.first ? convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) : "" %>
</div>
<% when 3 %>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE">

Some files were not shown because too many files have changed in this diff Show More