Module talk:TrainingPages

(Redirected from Module talk:TrainingPages/doc)
Latest comment: 10 years ago by Ragesoss in topic bugs with reading index pages

(Some examples)

edit

I've deleted some examples that were here; they're now part of the now standard unit tests (Module:TrainingPages/testcases) - see the talk for that page for the results. Wnt (talk) 18:55, 20 March 2014 (UTC)Reply

script error on template page

edit

I've started using this for an updated navigation framing for the trainings. It's working on the pages themselves, but it gives script errors on the template page: Wikipedia:Training/header/draft. It seems to be related to how the module treats "index=[nothing]".--Sage Ross (WMF) (talk) 15:31, 8 April 2013 (UTC)Reply

Sorry, I wasn't paying attention to this page! The problem right now is that the module is trying to look up an index file [[Wikipedia:Training/header/{{{topic}}} index]], and it doesn't exist. I've modified the message slightly, but I don't see a way to avoid having some kind of error if the module doesn't know what to use for an index page. Wnt (talk) 03:31, 25 April 2013 (UTC)Reply
OK, I've made it so that it returns a text-based message which is hopefully a little bit comprehensible. Or you can set noerr = (nonblank value) to have it return nothing if there's an error, for neatness. Wnt (talk) 03:51, 25 April 2013 (UTC)Reply
Excellent.--Sage Ross (WMF) (talk) 15:22, 25 April 2013 (UTC)Reply

feature request: get_page by number

edit

It'd be handy if this had a function to return the name of page X (eg, the first page) given an index.--Sage Ross (WMF) (talk) 22:39, 8 April 2013 (UTC)Reply

OK, I've jury-rigged it so that if "page" is a number (i.e. tonumber() gives a true result) it is interpreted directly as a page number. Used with function main this returns the name of the page with a given number. It also stacks with next_page or displacement to return other pages or the default page as appropriate for the displacement. Wnt (talk) 04:13, 25 April 2013 (UTC)Reply

new bug: total_pages not working correctly

edit

Now total_pages is working incorrectly. For example:

{{#invoke:TrainingPages|total_pages|index=Wikipedia:Training/For students/The Core index }}

yields: 14

The expected value is 15: Wikipedia:Training/For students/The Core index.

When used in the context of a page on that index, it is now returning the same value as page_number rather than the actual total pages. See Wikipedia:Training/For students/No original research.--Sage Ross (WMF) (talk) 15:22, 25 April 2013 (UTC)Reply

I've fixed it, but I'm not clear whether setting "returnpage" was the right thing for when total_pages catches an error.--Sage Ross (WMF) (talk) 15:28, 25 April 2013 (UTC)Reply
Oh, phooey - not sure why I did that but it looks like you caught it. Sigh... writing unit tests is not a great pleasure for me but it looks like I'm well past the point where it was needed! Wnt (talk) 15:36, 25 April 2013 (UTC)Reply
OK, testcases at Module talk:TrainingPages/testcases. Hopefully if I foul something else up I'll notice now. :) Wnt (talk) 16:27, 25 April 2013 (UTC)Reply

request: allow use of namespace synonyms in index pages

edit

I've been working on making it easier to port the trainings to other wikis (starting with moving them to Meta where it will be possible to use the translate extension). With most of the templates and content, I can change page names in the Wikipedia: namespace to "Project:" so that they will work the same no matter which wiki they are on. But the index pages used by this module only work if the local name of the Project: namespace is used. (So on meta, after I imported all the training pages I had to change the index pages to refer to Meta:, and they will have to be changed again by anyone porting them to other wikis.)

I would be very handy if the module could recognize that Wikipedia:Training is the same as Project:Training, and work the same with either.--Sage Ross (WMF) (talk) 16:38, 6 June 2013 (UTC)Reply

At a first glance, it looks like it ought to work if the index uses Project: in its entries. But it's hard to debug a script for sure when it's going to be run under other conditions. Can you link to the actual location you were trying to get the script to work, so I can check how it behaves there? Wnt (talk) 17:41, 6 June 2013 (UTC)Reply
m:Meta:Training/Example/Welcome, using m:Meta:Training/Example/Welcome index (the current version of which uses Project: links, so the 'next' link on the training page does not appear, until the index is changed back to using Meta: links). It's possible that I've overlooked a problem with my footer template where the module call is made, m:Meta:Training/footer, but if so I can't find it.--Sage Ross (WMF) (talk) 17:50, 6 June 2013 (UTC)Reply
At first glance I'm leaning that way - I just tried {{#invoke:TrainingPages|next_page|index=Project:Training/Example/Welcome index|page=Project:Training/Example/Welcome}} previewed from the template page and it seemed to work find, returning .."/The End". Wnt (talk) 18:12, 6 June 2013 (UTC)Reply
I think the problem comes with pulling the current page that it's called from... it looks for "Meta:Training/Example/Welcome" and doesn't find that on the index, so it returns nothing for "next".--Sage Ross (WMF) (talk) 18:14, 6 June 2013 (UTC)Reply
I got the arrows to appear by adding /Example/ in the topic, but you may be right about this part, because they don't link to anything. Wnt (talk) 18:21, 6 June 2013 (UTC)Reply
The arrows will appear (but linked to the image files) if there's no index at all (because it was looking for an index at Meta:Training/Example/Example/Welcome_index, in this case).--Sage Ross (WMF) (talk) 18:39, 6 June 2013 (UTC)Reply
OK, I think I've got it - try it out and see what you think. I've also implemented Module:UnitTests and Module talk:TrainingPages/testcases over there. There is one unit test I haven't fixed because it involves a "default index" from the very earliest versions of this on Wikipedia - I probably should take all mention of it out of the module and implement an error instead because it only has the power to confuse at this point. Also, I've made the module so it always returns the local project name (Meta:page instead of Project:page) - I could alter that behavior or put in a parameter. Last but not least... there has been some development of each of these modules and we should resync them and make sure one project's version is the master version. Wnt (talk) 19:18, 6 June 2013 (UTC)Reply
Excellent! I suggest we make this one the master version, and we can import the newest revision to Meta when necessary to sync them.--Sage Ross (WMF) (talk) 14:51, 7 June 2013 (UTC)Reply
OK, I think I've implemented all of the above; let me know if you have more ideas... or if I broke anything. Wnt (talk) 01:10, 8 June 2013 (UTC)Reply

bugs with reading index pages

edit

There are two things that prevent index pages from working as intended:

  1. If a linked page name has underscores instead of spaces
  2. If a linked page has a space at the end of the page name before the pipe

--ragesoss (talk) 18:09, 20 March 2014 (UTC)Reply

@Wnt: These aren't a big deal, but if you get a chance to have a look, please do! :-) --ragesoss (talk) 18:11, 20 March 2014 (UTC)Reply
@Ragesoss: Tell me if this fixes it - if not, please point me to an example of the problem. Wnt (talk) 18:50, 20 March 2014 (UTC)Reply
@Wnt: This fixes underscores, but not trailing spaces, like I inserted for testing here: https://meta.wikimedia.org/w/index.php?title=Programs:Evaluation_portal/Learning_modules/Designing_Effective_Questions_index&diff=prev&oldid=7905305 . If you revert to that version, the arrows disappear on the corresponding pages.--ragesoss (talk) 18:59, 20 March 2014 (UTC)Reply
Oh -- I was battening down the text input for the module call, not the index lookup. I'll see about this...
@Ragesoss: OK, this should do it, or at least did on my test index. Wnt (talk) 19:16, 20 March 2014 (UTC)Reply
@Wnt: Yep, that did the trick. Thanks once again!--ragesoss (talk) 19:22, 20 March 2014 (UTC)Reply