WikiEducationFoundation / WikiEduDashboard

Wiki Education Foundation's Wikipedia course dashboard system
https://dashboard.wikiedu.org
MIT License
387 stars 625 forks source link

Assignments in foreign wikis shows as interwiki in wikipage #2491

Open urbanecm opened 5 years ago

urbanecm commented 5 years ago

Hi,

I noticed that assignments in foreign wikis (in other wiki than course's home wiki) in courses with wiki page enabled shows as interwiki in the page. See https://cs.wikipedia.org/w/index.php?title=Wikipedie:N%C3%A1st%C4%9Bnka/Wikimedia_%C4%8CR/Workshop_psan%C3%AD_Wikipedie_-_zima_2019_(14-02-2019)&oldid=16952366 as an example (permanent link). Talien73's assignments are Pendon Museum@cswiki (shows correctly) and Slavonic Library in Prague@enwiki (doesn't show visually at all). If you examine the code, it's included as [[En:Slavonic Library in Prague]]. However, this is an (old school) method how to add an interwiki. If you want to link to a page at another wiki, the link must be prefixed with additional colon, so it will look like [[:En:Slavonic Library in Prague]].

Thanks for fixing,

Martin Urbanec cs.wikipedia

khyatisoneji commented 5 years ago

@ragesoss If I am correct, here the issue is caused by wikitext/format_assignment_title function. In the following lines:

    # For other wikis a language prefix is required, except for wikidata where the language is nil
    language_prefix = language ? ":#{language}" : ''
    # If the project is different, a project prefix is also necessary.
    project_prefix = project == home_wiki.project ? '' : ":#{project}"

    (INTERWIKI_PREFIXES[project_prefix] || project_prefix) + language_prefix + ':' + title

Here according to the code, it should add :En: prefix, why does it ignore the : at the beginning?

ragesoss commented 5 years ago

@urbanecm What happened in this case is (I think) that the user entered the assignment title "en:Slavonic Library in Prague" while leaving cs.wikipedia as the wiki. So the Dashboard has treated this as a cs.wikipedia article rather than an interwiki assignment. When inputting the article, users can either paste in a URL from any wiki (which will automatically be parsed to set the target wiki) or use the wiki language/project selectors at the bottom of the assignment form.

This is the first time I've seen this problem. How often is it happening that you've seen? If it's common, we could probably add handling for it.

urbanecm commented 5 years ago

Looks like it, after comparing with other interwiki assignments. I've no idea about how often this happens, I was reported this by a Czech user, I considered it a bug, so I filled a GitHub issue :-). If it's an easy thing, a handling could be useful, if not, I guess we can live with this too.

urbanecm commented 5 years ago

I've just reassigned this particular assignment as a proper interwiki assignment, it works, thanks for explaining this.

ragesoss commented 5 years ago

@khyatisoneji one the concepts the Dashboard uses for each course is home wiki, which is the wiki that automatically gets tracked for edits by participants. The default is that any assigned articles are on the home wiki, but it is possible to assign articles from other languages if you do so explicitly. In this case, the Dashboard frontend has some special handling so that it makes it clear that it's a page on a different wiki, and we use the same convention as "interwiki links" on Wikipedia, so that [[:en:Foo]] is a link to the English Wikipedia page "Foo".

In this case, a user followed that interwiki link format (rather than pasting in a full URL or using the language / project selector when adding an assignment), and entered "en:Slavonic Library in Prague" as the title of the assigned article. The Dashboard did not correctly interpret this as intended, but instead treated it as an article on the home wiki with the title "En:Slavonic Library in Prague".

If we're going to do something about this, it would involve updating the handling of assignment title input (which already detects and handles full URLs) so that it can interpret cases where the user puts in something in interwiki link format like the above (or the format where both the language and the project differ, like :en:wiktionary:Foo). The only trick is that it needs to match the interwiki link pattern based on language codes and project names, because colons are allowed in article titles. So "en:Something" is an interwiki link that should be interpreted a page on the corresponding English wiki, but "engineer:Something" is a valid article title.

urbanecm commented 5 years ago

Pro Tip: There are a lot of other interwikis, and on some wikis, engineer:Something might be invalid. https://www.mediawiki.org/wiki/API:Siteinfo can give a list of interwikis you can use in the dashboard. Non-WP assignments are rare and non-WM projects assignments are even more rare, but if you have time, it'll be great :-).

Aeropio commented 5 years ago

@ragesoss is this issue still open?