Tags:
create new tag
, view all tags

SID-02279: Creating multiple user based topics

Status: Answered Answered TWiki version: 6.0.2 Perl version: ?
Category: CategoryForms Server OS: ? Last update: 8 months ago

As an extreme novice user, I'm trying to achieve something that seems not to be possible, but I thought that I'd ask just in case there is a solution.

I am trying to create a voting system on our TWiki for various proposals and have got to the point where I can now create the required form structure (still have a problem with missing "add form" command though) but I want to create multiple form based topics, one for each user.

I am creating a subweb for each proposal and then a set of voting topics within that subweb, one for each group user.

I can do this manually, but it will be very difficult due to the number of group members and the number of proposals.

Is their any way to automate this based on the user group variables?

I suspect not, but had to ask.

Thanks.

Brent Hayhoe.

-- Brent Hayhoe - 2016-12-06

Discussion and Answer

I've learned that the terms "TWiki" and "not possible" don't go together well... there are so many ways to tackle a problem that often it is more a matter of finding the most readable one. But let me first try to describe what I think that you want to achieve: You want to create something we call a "TWiki Application".

  • You have various proposals, I guess that over time more proposals might be added, or some might hit their deadline for voting.
  • You have many users, but I don't understand what the role of a "group user" is. Is there a separate - maybe overlapping - group of users which is entitled to vote on each proposal?
  • You want to create one topic per user per proposal. That sounds pretty straightforward.
  • I do not fully understand your problem with a missing "add form" command. To add a form to an individual topic, there's the link "More topic actions" (bottom right on each page), from where there's the option to add or replace a form.
  • I guess that you want to have a page which shows all "proposals available for voting" - with individual content for each user. That's possible.
  • You might even want to have a page like "create a new proposal". That's possible, too.
  • I guess that when a user clicks on one of these proposals, she should be able to read the text of the proposal. Possible.
  • And, of course, the user should be able to vote for - or against - a proposal, and maybe also add a comment. There are various solutions for this.
  • I guess that finally, either at every time or at some deadline, there should be a statistics page counting votes. Possible.

So in total, I don't see any impossible step, but it requires tackling quite a few tasks, As I don't think that I've enough spare time to guide you through every step in the next weeks (and I'm not even sure whether I understood your question correctly), I can just give you a couple of pointers:

  • VarSEARCH (in particular QuerySearch) and FormattedSearch are the main components of "show me all proposals" and the voting statistics.
  • TWikiAccessControl helps if not every user should see every proposal (there are other approaches as well but they might be difficult to understand).
  • TWikiForms and TWikiTemplates are the path towards a "add new proposal" page and the individual voting pages. It is a matter of taste whether you create a subweb for every new proposal or have them all in one web.
  • TWikiScripts helps with defining the action of the HTML forms you create to drive the actions. In particular, the save script allows to create a topic without going through an edit cycle. The idea is that you don't have to set up voting topics for every proposal and every user in advance - the topics are created "on the fly" at the very moment when a user adds her vote. The topics will have the appropriate form attached if you specify it in the template page. The manage script can create a new web for a new proposal, in that case you should create a template web (baseweb) from which the topics in the new web are derived, so that it already contains all the forms and templates you need. You could as well keep all forms and templates in one place, though.
  • SpreadsheetPlugin helps with manipulating strings and numbers and stuff, even if you don't have anything which looks like a spreadsheet (though your statistics table might look like a spreadsheet).
  • CommentPlugin and VarINCLUDE can help to improve readability of your TWiki application by separating application stuff from content.

Have fun, and if there are questions regarding these features, please go ahead!

-- Harald Jörg - 2016-12-06

Thanks for the reply. I'll try and elaborate on various points.

  • Missing "add form" - as briefly as possible. Our TWiki was running an older version which was then transferred to a new host and upgraded to the latest version. In so doing, there are a couple of features not working and we have limited support to correct these. The "Add or replace form" link under the "More topic actions" just isn't present. I did raise this as a support question and Peter Thoeny's answer pointed me to using HTML form elements to create a topic with a form attached. This I can now do as a work-around (currently we do not have the support to investigate and fix this problem with our installation).

  • Our TWiki supports some of the IEEE working groups handling extensions to various hardware description language reference manuals. TWiki users are subdivided into user groups for each of these working groups. I am dealing with the VHDL group. It's the variable(s) defining the list of TWiki users for this VHDL working group that I'm referring to here.

  • I've got my head around generating a sub-web per proposal, generating a general form for each proposal vote, generating a search topic to present the voting results and generating Header and Template topics to support all this. I can see how to set this up as a TWiki Application. The knowledge that I am lacking is how to set up some HTML or TML to generate (easily) a set of topics (+forms) based on the user group list for each new sub-web I create (for each new proposal vote). I have searched through the support topics and found a few requests for similar ideas, but the response seemed to be that It wasn't Possible (easily?) to do.

  • Allowing user vote topics to be created 'on the fly' may work, but I really wanted to set them up as a default set at creation time. The status page would then list users that haven't yet (or ever!) voted. This is important for collating voting 'rights' for our procedural compliance. If I allowed these to be created on the fly, I still can't see how to detect those user voting topics that have not been generated yet? A 'baseweb' might work but we can have quite a high turnover of new and leaving users. We would need a means of keeping the 'baseweb' up to date.

Thanks for your help. I am not expecting full blown answers here and your pointers in your comments above have been very useful so far.

-- Brent Hayhoe - 2016-12-07

Thus far I can see that you are not at all an extreme novice user smile

I did some experiments, just for fun, maybe you'll find them useful...

  • If I need to bulk create many topics, I usually use a TWiki client program which fires up all the save scripts. However, I'm still not convinced this is necessary, because the list of people who haven't voted yet should be available with another approach.
  • One relevant question is whether the list of voters should be more or less fixed when a proposal is created, or whether it should dynamically reflect changes in the groups composition. In the latter case, I don't see a way how the "missing" vote topics can be created automatically.
  • If the list of voters is more or less static once a proposal is created, you can expand this list into a form field of the proposal on topic creation (SID-02278 contains a trick for expansion of nested groups). Then, the contents of this form field can be used to detect who hasn't voted yet, and it is possible to modify the voters list by editing the form field, without affecting the group definition.

The solution to enumerate non-existing vote topics is to iterate over the voters using the SpreadSheetPlugin and its $EXISTS() function. Assuming your vote topics are just a concatenation of the proposal name, the voter's wiki name and "Vote" and the voters are listed in a form field Voters, this could be achieved like that:

No votes from: 
%CALCULATE{
$LISTJOIN($comma ,$LISTEACH($IF($EXISTS(%TOPIC%$SUBSTITUTE($item,Main.,)Vote),,$item), $LISTSORT(%FORMFIELD{Voters}%)))
}%

Of course, the available votes can be collected with a FormattedSearch. For taking sums, again SpreadSheetPlugin can help with the $COUNTITEMS function.

Using the same form field contents, you can also offer readers who have not yet voted (but are entitled to) to directly click their vote - and if they have voted they see how they have voted. Here's a copy from my experiments:

Current Voters are: %FORMFIELD{Voters}%

<!--
A few settings help with readability (though not too much ;))
   * Set VOTETOPIC = %TOPIC%%WIKINAME%Vote
   * Set MYVOTE = %FORMFIELD{"Vote" topic="%VOTETOPIC%"}%
   * Set MAYVOTE = $COUNTSTR(%FORMFIELD{Voters}%, %WIKIUSERNAME%)
   * Set HASVOTED = $EXISTS(%VOTETOPIC%)
-->
%CALCULATE{$IF(%MAYVOTE%,$IF(%HASVOTED%,Your Vote: %MYVOTE%,Vote: %INCLUDE{"%TOPIC%" section="Vote"}%),You are not allowed to vote)}%

<!--
This form definition is hidden in normal view

%STARTSECTION{name="Vote" type="section"}%
<form action="%SCRIPTURLPATH{save}%/Sandbox/" method="post">
<div>
<input type='submit' name='Vote' value='yes' />
<input type='submit' name='Vote' value='no' />
<input type='hidden' name='topic' value='%TOPIC%HaraldJoergVote' />
<input type='hidden' name='formtemplate' value='VoteForm' />
<input type='hidden' name='redirectto' value='%TOPIC%' />
</div>
</form>
%ENDSECTION{name="Vote" type="section"}%
-->

-- Harald Jörg - 2016-12-11

Hi Harald,

Thanks for your time. I am an electronics design engineer and hopefully my intelligence becomes evident. However, when it comes to HTML and TWiki I am an extreme novice. (I don't even consider Javascript and CSS stuff.)

I am starting to understand more of how to approach the task now, which I think I was lacking before, so thanks for that.

You raise some interesting points, e.g. "whether the list of voters should be more or less fixed" to which the answer is obviously - yes ... and no!

Thanks for the pointers and tips and I will try and progress this. Unfortunately time and tasks have stalled me of late, but I will get back to it.

I have marked this topic as 'answered', but I will endeavour to post back if I ever get a working solution.

-- Brent Hayhoe - 2016-12-20

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Creating multiple user based topics
SupportCategory CategoryForms
TWiki version 6.0.2
Server OS ?
Web server ?
Perl version ?
Browser & version Firefox 50.0.2
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2016-12-20 - BrentHayhoe
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.