-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String PID support #511
String PID support #511
Conversation
vj4/handler/homework.py
Outdated
@@ -157,7 +157,7 @@ class HomeworkCodeHandler(base.OperationHandler): | |||
file_name='{}.zip'.format(tdoc['title'])) | |||
|
|||
|
|||
@app.route('/homework/{tid}/{pid:-?\d+|\w{24}}', 'homework_detail_problem') | |||
@app.route('/homework/{tid}/{pid:[A-Z0-9]+}', 'homework_detail_problem') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not allowing lowercase letters and maybe other characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What conflict? Can you explain more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emmm. Then I think we should not simply support string PIDs without changing the URL scheme. I think depending on URL case sensitivity is not a good idea.
By the way, it would be better to text instead of screenshot for code snippets. It is more friendly for more types of browsers/screen readers. For example:
@app.route(...)
class XxxHandler:
pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some user may just collected a URL in his browser.
Changing the URL scheme will make then confused as it throws 404 error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course we should change the URL in a backward compatible way, and preferably still generate the same URL for numeric/objectid PIDs. This can be achieved by making multiple routes to point to the same handler.
One proposal is to use (optional) named parameter in URL. For example: /homework/tid=xxx/pid=xxx/scoreboard
. We can also use query strings.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scoreboard for each problem?
so weird...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. The example should be /homework/tid=xxx/pid=xxx/submit
. It is just an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the submit handler can work properly.
but handlers like 'homework_edit' 'homework_scoreboard' will be handled by 'homework_problem' handler if we enables lowercase pid.
@@ -10,7 +10,7 @@ | |||
{%- endif %} | |||
> | |||
{%- endif %} | |||
{% if pdoc['doc_id']|string|length < 10 %}P{{ pdoc['doc_id'] }} {% endif %}{{ pdoc['title'] }} | |||
{% if pdoc['doc_id'] is number %}P {{ pdoc['doc_id'] }}{% elif pdoc['doc_id']|string|length < 10 %} {{ pdoc['doc_id'] }} {% endif %}{{ pdoc['title'] }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here seems complicated and incorrect. Can we implement them at Python side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we have to make a new template but I think it's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the logic is:
If it is a number,we add a 'p' before.
Else if it's not an object id, show the specified string PID.
Otherwise, no ID will be shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added a space between P and the numeric doc_id
.
I'm not sure what number
is in jinja2 but I suspect it includes floating point number which should not be included.
Why is there a magic number 10
?
Again you added some random spaces in the string doc_id
rendering.
Why is not displaying doc_id
preferred in some situations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh..I added this space by mistake,I'll fix later.
If we always show doc_id,It will show pid 'A123' as 'PA12'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acturally I don't wrote the number 10.
It's in older version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should I do if I want an ObjectId as PID?
Why the object id is needed? |
Some users may need that... This is back-compatibility. |
Can we write a regular expression to match the strings other than some meaningful words like |
if a user want's to create a problem called 'copy'... |
And I don't understand why objectid is better than numid for user. |
It is the default behavior to allocate ObjectIds as PIDs. And I don't think we should change the default behavior. |
Why shouldn't? |
It seems that most users want's number PIDs instead of Object ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are so many lines changed? Could you please do not change the order of the handlers?
The new URL schema is under discussion. |
Replaced by #514 |
For #510
There's maybe some bug.
Still testing.