[virtualcommons-svn] Sanitation experiment
Status: Beta
Brought to you by:
alllee
From: Allen L. <All...@as...> - 2011-06-14 18:04:58
|
Ah ok. That's much more useful information. You should probably also add href='#' to your a tags; some browsers don't like it when the href is blank. Next, there's two ways to get around this - the first is a quick & easy solution and the second is probably what we would go with longer-term. 1. Turn off autoescaping via {%autoescape off %} ... {% endautoescape %} or via the safe filter, e.g., {{game_state|safe}} (Try the safe filter first, it's more concise). 2. I think we'll eventually want to create a custom template tag / filter (pollutify?) that takes two parameters - a string resource ("Sanitation is blah blah blah ...") and a list of active pollution (basically character positions) and returns a new string with hrefs inserted into the text at each position specified by the active pollution list. I can show you how to do this the next time you come in. On Tue, Jun 14, 2011 at 2:07 AM, Marcel Hurtado <mar...@gm...> wrote: > Thank you. > Here's what I meant. > The sanitation text is in views.py at the moment saved to a variable called > game_state as a global: > game_state = "Sanitation is .... by more than 40 percent." > The symbols are inserted as urls with html tags into that text, like this: > game_state = "Sanitation <a href=''>@</a>is .... by more than <a > href=''>@</a>40 percent." > The method for "play" looks like this, still using the globals. > def play(request, experiment): > treatment = "In-group" > logger.debug("handling play") > return render_to_response('sanitation/play.html', globals(), > context_instance=RequestContext(request)) > When play.html loads the sanitation text is shown on the page like this: > "Sanitation <a href=''>@</a>is .... by more than <a href=''>@</a>40 > percent." > but it should be like this: > "Sanitation @is .... by more than @40 percent." > > > On Mon, Jun 13, 2011 at 10:05 PM, Allen Lee <All...@as...> wrote: >> >> current_location should probably be an extra column on >> ParticipantExperimentRelationship in core, but you'd get & set it in >> your sanitation game code. I can push that out soon, but am working >> on some other bugs first. Not sure what you mean by passing strings >> from views to templates not rendering as html, can you clarify or show >> code examples that aren't working? >> >> On Mon, Jun 13, 2011 at 6:50 PM, Marcel Hurtado >> <mar...@gm...> wrote: >> > Allen, >> > I have some questions. Does the "current_location" variable get >> > initiallized >> > in the sanitation directory, or in the core? >> > Also, when I pass a string from views to template it does not render it >> > as >> > html. That is to say, the string for the resource passes with no problem >> > but >> > the symbols which should be links show up as <a href=''>@</a>. >> > Marcel >> >> >> >> -- >> Allen Lee >> Center for the Study of Institutional Diversity [http://csid.asu.edu] >> School of Human Evolution and Social Change [http://shesc.asu.edu] >> College of Liberal Arts and Sciences >> Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 >> 480.727.0401 | Fax: 480.965.7671 | e-mail: all...@as... > > -- Allen Lee Center for the Study of Institutional Diversity [http://csid.asu.edu] School of Human Evolution and Social Change [http://shesc.asu.edu] College of Liberal Arts and Sciences Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402 480.727.0401 | Fax: 480.965.7671 | e-mail: all...@as... |