hackergame icon indicating copy to clipboard operation
hackergame copied to clipboard

移除“打开题目”按钮

Open SmartHypercube opened this issue 6 years ago • 3 comments

并针对典型的题目描述中的需求提供一些工具

SmartHypercube avatar Oct 16 '19 06:10 SmartHypercube

对于目前的几种题目:

  • 打开一个网页
  • 通过 nc 交互
  • 下载一个文件

是要设置不同的提示吗?

cjc7373 avatar May 29 '20 15:05 cjc7373

是的,以前认为每个题目包含标题、描述文字、一个“打开题目”链接,这种模型是错误的。题目可以有很多种链接,我能想到两种正确的建模方式:

  1. 题目有“网页”、“nc 连接参数”、源代码文件等多个字段,哪些非空就在界面上显示哪些,配上合理的图标
  2. 把链接的概念从模型中去掉,题目作者自己在“描述文字”底部写上即可,但平台提供一些预置的 CSS class,以便显示效果统一

另外,有时题目描述中需要插入一点动态内容,例如一个链接,它带着选手 token 作为参数。目前的解决方法是 https://github.com/ustclug/hackergame/blob/159812f625564e7043e8df800df7c58d7bd0b356/frontend/templates/hub.html#L99 和 https://github.com/ustclug/hackergame/blob/159812f625564e7043e8df800df7c58d7bd0b356/frontend/templates/hub.html#L102 (强行替换)不知道有没有更好的做法,但我觉得选上面说的第二种方法,配合这个就可以

SmartHypercube avatar May 29 '20 15:05 SmartHypercube

如果用第一种方法,比如接口写成:

{
    ...
    "web_url": "...",
    "nc_url": null,
    "file_url": null
}

后端可以构造一下url(加上token)再发给前端。而不必去查找替换了。 不过这样相当于硬编码了三种题目的打开方式,可能会不利于拓展..

cjc7373 avatar May 30 '20 03:05 cjc7373