[virtualcommons-developer] commit/vcweb: 2 new changesets
Status: Beta
Brought to you by:
alllee
|
From: <com...@bi...> - 2013-03-19 23:06:19
|
2 new commits in vcweb: https://bitbucket.org/virtualcommons/vcweb/commits/a975b53ad569/ changeset: a975b53ad569 user: alllee date: 2013-03-19 21:47:10 summary: version bump bootbox affected #: 1 file diff -r 4dbb0ffe297cfd0e71a9ef19d20d0dbf97ddaf9d -r a975b53ad5697269d712da8d2ed0b7e05eddfdc4 vcweb/static/js/bootbox.min.js --- a/vcweb/static/js/bootbox.min.js +++ b/vcweb/static/js/bootbox.min.js @@ -1,16 +1,17 @@ /** - * bootbox.js v3.0.0 + * bootbox.js v3.2.0 * * http://bootboxjs.com/license.txt */ -var bootbox=window.bootbox||function(v,n){function h(b,a){null==a&&(a=r);return"string"===typeof l[a][b]?l[a][b]:a!=s?h(b,s):b}var r="en",s="en",t=!0,q="static",u="",g={},m={setLocale:function(b){for(var a in l)if(a==b){r=b;return}throw Error("Invalid locale: "+b);},addLocale:function(b,a){"undefined"===typeof l[b]&&(l[b]={});for(var c in a)l[b][c]=a[c]},setIcons:function(b){g=b;if("object"!==typeof g||null==g)g={}},alert:function(){var b="",a=h("OK"),c=null;switch(arguments.length){case 1:b=arguments[0]; -break;case 2:b=arguments[0];"function"==typeof arguments[1]?c=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];c=arguments[2];break;default:throw Error("Incorrect number of arguments: expected 1-3");}return m.dialog(b,{label:a,icon:g.OK,callback:c},{onEscape:c||!0})},confirm:function(){var b="",a=h("CANCEL"),c=h("CONFIRM"),e=null;switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"function"==typeof arguments[1]?e=arguments[1]:a=arguments[1];break;case 3:b= -arguments[0];a=arguments[1];"function"==typeof arguments[2]?e=arguments[2]:c=arguments[2];break;case 4:b=arguments[0];a=arguments[1];c=arguments[2];e=arguments[3];break;default:throw Error("Incorrect number of arguments: expected 1-4");}var j=function(){"function"===typeof e&&e(!1)};return m.dialog(b,[{label:a,icon:g.CANCEL,callback:j},{label:c,icon:g.CONFIRM,callback:function(){"function"===typeof e&&e(!0)}}],{onEscape:j})},prompt:function(){var b="",a=h("CANCEL"),c=h("CONFIRM"),e=null,j="";switch(arguments.length){case 1:b= -arguments[0];break;case 2:b=arguments[0];"function"==typeof arguments[1]?e=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];"function"==typeof arguments[2]?e=arguments[2]:c=arguments[2];break;case 4:b=arguments[0];a=arguments[1];c=arguments[2];e=arguments[3];break;case 5:b=arguments[0];a=arguments[1];c=arguments[2];e=arguments[3];j=arguments[4];break;default:throw Error("Incorrect number of arguments: expected 1-5");}var d=n("<form></form>");d.append("<input autocomplete=off type=text value='"+ -j+"' />");var j=function(){"function"===typeof e&&e(null)},k=m.dialog(d,[{label:a,icon:g.CANCEL,callback:j},{label:c,icon:g.CONFIRM,callback:function(){"function"===typeof e&&e(d.find("input[type=text]").val())}}],{header:b,show:!1,onEscape:j});k.on("shown",function(){d.find("input[type=text]").focus();d.on("submit",function(a){a.preventDefault();k.find(".btn-primary").click()})});k.modal("show");return k},dialog:function(b,a,c){var e="",j=[];c=c||{};null==a?a=[]:"undefined"==typeof a.length&&(a= -[a]);for(var d=a.length;d--;){var k=null,g=null,h=null,l="",m=null;if("undefined"==typeof a[d].label&&"undefined"==typeof a[d]["class"]&&"undefined"==typeof a[d].callback){var k=0,g=null,p;for(p in a[d])if(g=p,1<++k)break;1==k&&"function"==typeof a[d][p]&&(a[d].label=g,a[d].callback=a[d][p])}"function"==typeof a[d].callback&&(m=a[d].callback);a[d]["class"]?h=a[d]["class"]:d==a.length-1&&2>=a.length&&(h="btn-primary");k=a[d].label?a[d].label:"Option "+(d+1);a[d].icon&&(l="<i class='"+a[d].icon+"'></i> "); -g=a[d].href?a[d].href:"javascript:;";e="<a data-handler='"+d+"' class='btn "+h+"' href='"+g+"'>"+l+""+k+"</a>"+e;j[d]=m}d=["<div class='bootbox modal' tabindex='-1' style='overflow:hidden;'>"];if(c.header){h="";if("undefined"==typeof c.headerCloseButton||c.headerCloseButton)h="<a href='javascript:;' class='close'>×</a>";d.push("<div class='modal-header'>"+h+"<h3>"+c.header+"</h3></div>")}d.push("<div class='modal-body'></div>");e&&d.push("<div class='modal-footer'>"+e+"</div>");d.push("</div>"); -var f=n(d.join("\n"));("undefined"===typeof c.animate?t:c.animate)&&f.addClass("fade");(e="undefined"===typeof c.classes?u:c.classes)&&f.addClass(e);f.find(".modal-body").html(b);f.on("hidden",function(){f.remove()});f.on("keyup.dismiss.modal",function(a){if(27==a.which&&c.onEscape){if("function"===typeof c.onEscape)c.onEscape();f.modal("hide")}});f.on("shown",function(){f.find("a.btn-primary:first").focus()});f.on("click",".modal-footer a, a.close",function(b){var c=n(this).data("handler"),d=j[c], -e=null;"undefined"!==typeof c&&"undefined"!==typeof a[c].href||(b.preventDefault(),"function"==typeof d&&(e=d()),!1!==e&&f.modal("hide"))});n("body").append(f);f.modal({backdrop:"undefined"===typeof c.backdrop?q:c.backdrop,keyboard:!1,show:!1});f.on("show",function(){n(v).off("focusin.modal")});("undefined"===typeof c.show||!0===c.show)&&f.modal("show");return f},modal:function(){var b,a,c,e={onEscape:null,keyboard:!0,backdrop:q};switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0]; -"object"==typeof arguments[1]?c=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];c=arguments[2];break;default:throw Error("Incorrect number of arguments: expected 1-3");}e.header=a;c="object"==typeof c?n.extend(e,c):e;return m.dialog(b,[],c)},hideAll:function(){n(".bootbox").modal("hide")},animate:function(b){t=b},backdrop:function(b){q=b},classes:function(b){u=b}},l={en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},de:{OK:"OK",CANCEL:"Abbrechen", -CONFIRM:"Akzeptieren"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},ru:{OK:"OK",CANCEL:"\u041e\u0442\u043c\u0435\u043d\u0430",CONFIRM:"\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"}};return m}(document,window.jQuery);window.bootbox=bootbox; +var bootbox=window.bootbox||function(w,n){function k(b,a){"undefined"===typeof a&&(a=p);return"string"===typeof j[a][b]?j[a][b]:a!=t?k(b,t):b}var p="en",t="en",u=!0,s="static",v="",l={},g={},m={setLocale:function(b){for(var a in j)if(a==b){p=b;return}throw Error("Invalid locale: "+b);},addLocale:function(b,a){"undefined"===typeof j[b]&&(j[b]={});for(var c in a)j[b][c]=a[c]},setIcons:function(b){g=b;if("object"!==typeof g||null===g)g={}},setBtnClasses:function(b){l=b;if("object"!==typeof l||null=== +l)l={}},alert:function(){var b="",a=k("OK"),c=null;switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"function"==typeof arguments[1]?c=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];c=arguments[2];break;default:throw Error("Incorrect number of arguments: expected 1-3");}return m.dialog(b,{label:a,icon:g.OK,"class":l.OK,callback:c},{onEscape:c||!0})},confirm:function(){var b="",a=k("CANCEL"),c=k("CONFIRM"),e=null;switch(arguments.length){case 1:b=arguments[0]; +break;case 2:b=arguments[0];"function"==typeof arguments[1]?e=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];"function"==typeof arguments[2]?e=arguments[2]:c=arguments[2];break;case 4:b=arguments[0];a=arguments[1];c=arguments[2];e=arguments[3];break;default:throw Error("Incorrect number of arguments: expected 1-4");}var h=function(){if("function"===typeof e)return e(!1)};return m.dialog(b,[{label:a,icon:g.CANCEL,"class":l.CANCEL,callback:h},{label:c,icon:g.CONFIRM,"class":l.CONFIRM, +callback:function(){if("function"===typeof e)return e(!0)}}],{onEscape:h})},prompt:function(){var b="",a=k("CANCEL"),c=k("CONFIRM"),e=null,h="";switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"function"==typeof arguments[1]?e=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];"function"==typeof arguments[2]?e=arguments[2]:c=arguments[2];break;case 4:b=arguments[0];a=arguments[1];c=arguments[2];e=arguments[3];break;case 5:b=arguments[0];a=arguments[1]; +c=arguments[2];e=arguments[3];h=arguments[4];break;default:throw Error("Incorrect number of arguments: expected 1-5");}var q=n("<form></form>");q.append("<input autocomplete=off type=text value='"+h+"' />");var h=function(){if("function"===typeof e)return e(null)},d=m.dialog(q,[{label:a,icon:g.CANCEL,"class":l.CANCEL,callback:h},{label:c,icon:g.CONFIRM,"class":l.CONFIRM,callback:function(){if("function"===typeof e)return e(q.find("input[type=text]").val())}}],{header:b,show:!1,onEscape:h});d.on("shown", +function(){q.find("input[type=text]").focus();q.on("submit",function(a){a.preventDefault();d.find(".btn-primary").click()})});d.modal("show");return d},dialog:function(b,a,c){function e(){var a=null;"function"===typeof c.onEscape&&(a=c.onEscape());!1!==a&&f.modal("hide")}var h="",l=[];c||(c={});"undefined"===typeof a?a=[]:"undefined"==typeof a.length&&(a=[a]);for(var d=a.length;d--;){var g=null,k=null,j=null,m="",p=null;if("undefined"==typeof a[d].label&&"undefined"==typeof a[d]["class"]&&"undefined"== +typeof a[d].callback){var g=0,k=null,r;for(r in a[d])if(k=r,1<++g)break;1==g&&"function"==typeof a[d][r]&&(a[d].label=k,a[d].callback=a[d][r])}"function"==typeof a[d].callback&&(p=a[d].callback);a[d]["class"]?j=a[d]["class"]:d==a.length-1&&2>=a.length&&(j="btn-primary");g=a[d].label?a[d].label:"Option "+(d+1);a[d].icon&&(m="<i class='"+a[d].icon+"'></i> ");k=a[d].href?a[d].href:"javascript:;";h="<a data-handler='"+d+"' class='btn "+j+"' href='"+k+"'>"+m+""+g+"</a>"+h;l[d]=p}d=["<div class='bootbox modal' tabindex='-1' style='overflow:hidden;'>"]; +if(c.header){j="";if("undefined"==typeof c.headerCloseButton||c.headerCloseButton)j="<a href='javascript:;' class='close'>×</a>";d.push("<div class='modal-header'>"+j+"<h3>"+c.header+"</h3></div>")}d.push("<div class='modal-body'></div>");h&&d.push("<div class='modal-footer'>"+h+"</div>");d.push("</div>");var f=n(d.join("\n"));("undefined"===typeof c.animate?u:c.animate)&&f.addClass("fade");(h="undefined"===typeof c.classes?v:c.classes)&&f.addClass(h);f.find(".modal-body").html(b);f.on("keyup.dismiss.modal", +function(a){27===a.which&&c.onEscape&&e("escape")});f.on("click","a.close",function(a){a.preventDefault();e("close")});f.on("shown",function(){f.find("a.btn-primary:first").focus()});f.on("hidden",function(){f.remove()});f.on("click",".modal-footer a",function(b){var c=n(this).data("handler"),d=l[c],e=null;"undefined"!==typeof c&&"undefined"!==typeof a[c].href||(b.preventDefault(),"function"===typeof d&&(e=d()),!1!==e&&f.modal("hide"))});n("body").append(f);f.modal({backdrop:"undefined"===typeof c.backdrop? +s:c.backdrop,keyboard:!1,show:!1});f.on("show",function(){n(w).off("focusin.modal")});("undefined"===typeof c.show||!0===c.show)&&f.modal("show");return f},modal:function(){var b,a,c,e={onEscape:null,keyboard:!0,backdrop:s};switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"object"==typeof arguments[1]?c=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];c=arguments[2];break;default:throw Error("Incorrect number of arguments: expected 1-3");}e.header=a; +c="object"==typeof c?n.extend(e,c):e;return m.dialog(b,[],c)},hideAll:function(){n(".bootbox").modal("hide")},animate:function(b){u=b},backdrop:function(b){s=b},classes:function(b){v=b}},j={en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},de:{OK:"OK",CANCEL:"Abbrechen",CONFIRM:"Akzeptieren"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},ru:{OK:"OK",CANCEL:"\u041e\u0442\u043c\u0435\u043d\u0430", +CONFIRM:"\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"}};return m}(document,window.jQuery);window.bootbox=bootbox; https://bitbucket.org/virtualcommons/vcweb/commits/42abc2730526/ changeset: 42abc2730526 user: alllee date: 2013-03-20 00:06:12 summary: fixing transition from welcome -> general instructions round for boundaries experiment affected #: 8 files diff -r a975b53ad5697269d712da8d2ed0b7e05eddfdc4 -r 42abc273052667a4bb840d3ff8b20856f0f5bcd4 vcweb/boundaries/templates/boundaries/participate.html --- a/vcweb/boundaries/templates/boundaries/participate.html +++ b/vcweb/boundaries/templates/boundaries/participate.html @@ -342,7 +342,6 @@ model.isTimerRunning = ko.computed(function() { return model.secondsLeft() > 0; }); - model.templateName = ko.observable("WELCOME"); // activate instructions click bindings model.activateInstructionsPageOne = function() { model.templateName('GENERAL_INSTRUCTIONS'); @@ -477,19 +476,6 @@ $('#harvestDecision').keyup(function() { $('#harvestDecision').val(this.value.match(/\d+/)); }); - $('#pick-template').change(function() { - var templateName = $(this).val(); - console.debug("switching to template: " + templateName); - if (templateName === "PRACTICE") { - templateName = "REGULAR"; - experimentModel.practiceRound(true); - } - else if (templateName === "REGULAR") { - experimentModel.practiceRound(false); - } - experimentModel.templateName(templateName); - }); - } //send the message when submit is clicked var experimentModelJson = $.parseJSON("{{ experimentModelJson|escapejs }}"); diff -r a975b53ad5697269d712da8d2ed0b7e05eddfdc4 -r 42abc273052667a4bb840d3ff8b20856f0f5bcd4 vcweb/boundaries/views.py --- a/vcweb/boundaries/views.py +++ b/vcweb/boundaries/views.py @@ -5,7 +5,7 @@ from vcweb.core.decorators import participant_required from vcweb.core.http import JsonResponse from vcweb.core.models import (is_participant, is_experimenter, Experiment, ParticipantGroupRelationship, - ParticipantExperimentRelationship, ChatMessage, ParticipantRoundDataValue) + ParticipantExperimentRelationship, ChatMessage, ParticipantRoundDataValue, GroupRelationship) from vcweb.boundaries.forms import HarvestDecisionForm from vcweb.boundaries.models import (get_experiment_metadata, get_regrowth_rate, get_harvest_decision_parameter, get_cost_of_living, get_resource_level, get_initial_resource_level, get_total_storage, get_storage, @@ -54,6 +54,7 @@ return JsonResponse(dumps({'success': False })) +# FIXME: need to distinguish between instructions / welcome rounds and practice/regular rounds def get_view_model_json(experiment, participant_group_relationship, **kwargs): ec = experiment.experiment_configuration current_round = experiment.current_round @@ -65,7 +66,7 @@ regrowth_rate = get_regrowth_rate(current_round) cost_of_living = get_cost_of_living(current_round) own_group = participant_group_relationship.group - own_resource_level = 0 + own_resource_level = get_resource_level(own_group) last_harvest_decision = get_last_harvest_decision(participant_group_relationship, round_data=previous_round_data) experiment_model_dict['playerData'] = [{ 'id': pgr.participant_number, @@ -86,7 +87,7 @@ if group != own_group: group_data.append({ 'groupId': unicode(group), - 'resourceLevel': resource_level, + 'resourceLevel': get_resource_level(group), 'totalStorage': get_total_storage(group), 'regrowthRate': regrowth_rate, 'costOfLiving': cost_of_living, @@ -95,13 +96,22 @@ # round / experiment configuration data experiment_model_dict['participantsPerGroup'] = ec.max_group_size - experiment_model_dict['roundType'] = current_round.round_type experiment_model_dict['regrowthRate'] = regrowth_rate experiment_model_dict['costOfLiving'] = cost_of_living experiment_model_dict['participantNumber'] = participant_group_relationship.participant_number experiment_model_dict['participantGroupId'] = participant_group_relationship.pk - experiment_model_dict['dollarsPerToken'] = ec.exchange_rate - experiment_model_dict['chatEnabled'] = current_round.chat_enabled + experiment_model_dict['dollarsPerToken'] = float(ec.exchange_rate) + experiment_model_dict['roundType'] = current_round.round_type + experiment_model_dict['practiceRound'] = current_round.is_practice_round + experiment_model_dict['chatEnabled'] = False + if current_round.is_regular_round: + experiment_model_dict['chatEnabled'] = current_round.chat_enabled + if current_round.is_practice_round: + experiment_model_dict['templateName'] = 'REGULAR' + else: + experiment_model_dict['templateName'] = current_round.round_type + + # FIXME: defaults hard coded in for now experiment_model_dict['maxEarnings'] = 20.00 experiment_model_dict['warningCountdownTime'] = 10 @@ -112,7 +122,6 @@ # FIXME: these need to be looked up experiment_model_dict['maxHarvestDecision'] = 10 experiment_model_dict['hasSubmit'] = False - experiment_model_dict['practiceRound'] = current_round.is_practice_round experiment_model_dict['instructions'] = current_round.get_custom_instructions() experiment_model_dict.update(**kwargs) return dumps(experiment_model_dict) diff -r a975b53ad5697269d712da8d2ed0b7e05eddfdc4 -r 42abc273052667a4bb840d3ff8b20856f0f5bcd4 vcweb/core/models.py --- a/vcweb/core/models.py +++ b/vcweb/core/models.py @@ -528,11 +528,11 @@ def get_participant_group_relationship(self, participant): session_id = self.current_round.session_id - if session_id is None: - return ParticipantGroupRelationship.objects.get(group__experiment=self, participant=participant) - else: + if session_id: return ParticipantGroupRelationship.objects.get(group__experiment=self, participant=participant, group__session_id=session_id) + else: + return ParticipantGroupRelationship.objects.get(group__experiment=self, participant=participant) def all_participants_have_submitted(self): return ParticipantRoundDataValue.objects.filter(submitted=False, round_data=self.current_round_data).count() == 0 @@ -888,13 +888,14 @@ # maps round type name to (description, default_template_name) ROUND_TYPES_DICT = dict( WELCOME=('Initial welcome round', 'welcome.html'), + GENERAL_INSTRUCTIONS=('General instructions round (introduction)', 'general-instructions.html'), REGULAR=('Regular experiment round', 'participate.html'), CHAT=('Chat round', 'chat.html'), DEBRIEFING=('Debriefing round', 'debriefing.html'), INSTRUCTIONS=('Instructions round', 'instructions.html'), PRACTICE=('Practice round', 'practice.html'), QUIZ=('Quiz round', 'quiz.html')) - ROUND_TYPES = (CHAT, DEBRIEFING, INSTRUCTIONS, PRACTICE, QUIZ, REGULAR, WELCOME) = sorted(ROUND_TYPES_DICT.keys()) + ROUND_TYPES = (CHAT, DEBRIEFING, GENERAL_INSTRUCTIONS, INSTRUCTIONS, PRACTICE, QUIZ, REGULAR, WELCOME) = sorted(ROUND_TYPES_DICT.keys()) ROUND_TYPE_CHOICES = Choices(*[(round_type, ROUND_TYPES_DICT[round_type][0]) for round_type in ROUND_TYPES]) PLAYABLE_ROUND_CONFIGURATIONS = (PRACTICE, REGULAR) @@ -958,12 +959,16 @@ if not self.is_instructions_round: logger.warning("tried to get custom instructions for a non-instructions round %s", self) return None - instructions_template = select_template([self.template_path]) - if context_dict is None: - context_dict = {} - context_dict.update(kwargs, session_number=self.session_id) - c = Context(context_dict) - return instructions_template.render(c) + try: + instructions_template = select_template([self.template_path]) + if context_dict is None: + context_dict = {} + context_dict.update(kwargs, session_number=self.session_id) + c = Context(context_dict) + return instructions_template.render(c) + except: + logger.warning("no template found for custom instructions: %s", self.template_path) + return None @property def template_path(self): diff -r a975b53ad5697269d712da8d2ed0b7e05eddfdc4 -r 42abc273052667a4bb840d3ff8b20856f0f5bcd4 vcweb/core/templates/experimenter/monitor.html --- a/vcweb/core/templates/experimenter/monitor.html +++ b/vcweb/core/templates/experimenter/monitor.html @@ -137,6 +137,16 @@ </div></div></div> +<div id='progress-modal' class='modal hide fade'> + <div class='model-header'> + <h3>Updating experiment status</h3> + </div> + <div class='modal-body'> + <div class='progress progress-striped active'> + <div id='progress-bar' class='bar' style='width: 50%'></div> + </div> + </div> +</div> {% endblock page %} {% block javascript %} {{ block.super }} @@ -159,6 +169,7 @@ function update(experimentModel) { return function(data) { ko.mapping.fromJS(data, experimentModel); + $('#progress-modal').modal('hide'); } } function initialize(experimentModelJson) { @@ -183,6 +194,7 @@ bootbox.confirm(description + " Continue?", function(confirmed) { if (confirmed) { Dajaxice.vcweb.core.experiment_controller(update(experimentModel), {'pk': {{experiment.pk}}, 'action':action}); + $('#progress-modal').modal({keyboard: false}); } return false; }); Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |