Changeset ac1aa3 in indico


Ignore:
Timestamp:
03/02/11 14:03:36 (2 years ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, b8c30da8ebdbdcbd675a873997cc3e95f567de49, 4287315ec967a3da168d83963c14001db8487d53
Children:
ddf66a
Parents:
4bd61a
git-author:
Alexis Castilla Hernandez <alexis.castilla.hernandez@…> (01/24/11 17:43:15)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (03/02/11 14:03:36)
Message:

[FTR] Remove question and keep the results

  • Implemented the functionality of removing questions choosing if you want to keep the judgements of the question which you are removing, or you want to remove every previous judgement of that question.
Location:
indico
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/review.py

    r4bd61a rac1aa3  
    11211121            abs.recalculateRating(scaleLower, scaleHigher) 
    11221122 
     1123    def removeAnswersOfQuestion(self, questionId): 
     1124        ''' Remove a question results for each abstract ''' 
     1125        for abs in self.getAbstractList(): 
     1126            abs.removeAnswersOfQuestion(questionId) 
    11231127 
    11241128    def notifyModification(self): 
     
    23742378            self._rating = "%.2f" % (ratingSum/judNum) 
    23752379 
     2380    def removeAnswersOfQuestion(self, questionId): 
     2381        ''' Remove the answers of the question with questionId value ''' 
     2382        for track in self.getTrackListSorted(): 
     2383            for jud in self.getJudgementsHistoricalByTrack(track): 
     2384                jud.removeAnswer(questionId) 
     2385 
    23762386 
    23772387 
     
    24702480        self._totalJudValue = self.calculateAnswersTotalValue() 
    24712481 
     2482    def removeAnswer(self, questionId): 
     2483        ''' Remove the current answers of the questionId ''' 
     2484        for ans in self._answers: 
     2485            if ans.getQuestionId() == questionId: 
     2486                self._answers.remove(ans) 
    24722487 
    24732488 
  • indico/MaKaC/reviewing.py

    r4bd61a rac1aa3  
    11141114        """ Returns the list of questions 
    11151115        """ 
    1116         return self._reviewingQuestions 
    1117  
    1118     def removeReviewingQuestion(self, questionId): 
     1116        # Filter the non visible questions 
     1117        visibleQuestions = [] 
     1118        for question in self._reviewingQuestions: 
     1119            if question.getVisible(): 
     1120                visibleQuestions.append(question) 
     1121        return visibleQuestions 
     1122 
     1123    def removeReviewingQuestion(self, questionId, keepJud): 
    11191124        """ Removes a question from the list 
    11201125        """ 
     
    11221127 
    11231128        if question: 
    1124             self._reviewingQuestions.remove(question) 
    1125             self.notifyModification() 
     1129            if keepJud: 
     1130                question.setVisible(False) 
     1131            else: 
     1132                self._reviewingQuestions.remove(question) 
     1133                self.notifyModification() 
    11261134        else: 
    11271135            raise MaKaCError("Cannot remove a question which doesn't exist") 
     
    12711279        self._id = newId 
    12721280        self._text = text 
     1281        self._visible = True 
    12731282 
    12741283    def getId(self): 
     
    12781287        return self._text 
    12791288 
     1289    def getVisible(self): 
     1290        return self._visible 
     1291 
    12801292    def setText(self, text): 
    12811293        self._text = text 
     1294 
     1295    def setVisible(self, value): 
     1296        self._visible = value 
    12821297 
    12831298    def notifyModification(self): 
  • indico/MaKaC/services/implementation/reviewing.py

    r4bd61a rac1aa3  
    947947        AbstractReviewingBase._checkParams(self) 
    948948        self._value = self._params.get("value") # value is the question id 
    949  
    950     def _getAnswer(self): 
    951         self._confAbstractReview.removeReviewingQuestion(self._value) 
     949        self._keepJud = self._params.get("keepJud") # keep the previous judgements of the question 
     950 
     951    def _getAnswer(self): 
     952        # remove the question 
     953        self._confAbstractReview.removeReviewingQuestion(self._value, self._keepJud) 
     954        if not self._keepJud: 
     955            # Purge all the judgements already exist with answers of this question 
     956            self._conf.getAbstractMgr().removeAnswersOfQuestion(self._value) 
     957            self._conf.getAbstractMgr().recalculateAbstractsRating(self._confAbstractReview.getScaleLower(), self._confAbstractReview.getScaleHigher()) 
    952958        reviewingQuestions = self._confAbstractReview.getReviewingQuestions() 
     959        # Build the answer 
    953960        fossils = [] 
    954961        for question in reviewingQuestions: 
  • indico/MaKaC/webinterface/tpls/ConfModifAbstractReviewingSettings.tpl

    rbcaaf6 rac1aa3  
    4545        'edit': 'reviewing.abstractReviewing.editQuestion'}, 
    4646        {conference: '<%= abstractReview.getConference().getId() %>'},'question', 
    47         'Add the questions that the abstract reviewers must answer')); 
     47        'Add the questions that the abstract reviewers must answer', true)); 
    4848 
    4949 
  • indico/htdocs/js/indico/Core/Dialogs/Popup.js

    r8272ae rac1aa3  
    505505             var self = this; 
    506506 
    507              var okButton = Html.input('button', {style:{marginRight: pixels(3)}}, $T('OK')); 
     507             var okButton = Html.input('button', {style:{marginRight: pixels(3)}}, $T(this.buttonTitle)); 
    508508             okButton.observeClick(function(){ 
    509509                 self.close(); 
     
    523523    }, 
    524524 
    525     function(title, content, handler) { 
     525    function(title, content, handler, buttonTitle) { 
    526526        var self = this; 
    527527 
     528        if (buttonTitle) { 
     529            this.buttonTitle = buttonTitle; 
     530        } else { 
     531            this.buttonTitle = 'OK'; 
     532        } 
    528533        this.content = content; 
    529534        this.handler = handler; 
     
    578583 
    579584/** 
    580  * Works exactly the same as the ConfirmPopup, but includes a parametermanager to perform checks when pressing OK 
    581  */ 
    582 type("ConfirmPopupWithPM", ["ExclusivePopupWithButtons"], 
    583         { 
    584              draw: function() { 
    585                  var self = this; 
    586  
    587                  var okButton = Html.input('button', {style:{marginRight: pixels(3)}}, $T('OK')); 
    588                  okButton.observeClick(function(){ 
    589                      checkOK = self.parameterManager.check(); 
    590                      if(checkOK){ 
    591                          self.handler(true); 
    592                      } 
    593                  }); 
    594  
    595                  var cancelButton = Html.input('button', {style:{marginLeft: pixels(3)}}, $T('Cancel')); 
    596                  cancelButton.observeClick(function(){ 
    597                      self.close(); 
    598                      self.handler(false); 
    599                  }); 
    600  
    601                  return this.ExclusivePopupWithButtons.prototype.draw.call(this, 
    602                          this.content, 
    603                          Html.div({}, okButton, cancelButton)); 
    604              } 
    605         }, 
    606  
    607         function(title, content, handler) { 
    608             var self = this; 
    609  
    610             this.content = content; 
    611             this.handler = handler; 
    612             this.parameterManager = new IndicoUtil.parameterManager(); 
    613             this.ExclusivePopupWithButtons(Html.div({style:{textAlign: 'center'}}, title), function(){ 
    614                 self.handler(false); 
    615                 return true; 
    616             }); 
    617         } 
    618     ); 
    619  
    620  * It will have a title, a close button, an SAVE button and a Cancel button. 
     585 * Utility function to display a three buttons popup. 
     586 * The difference with ConfirmButton is the existence of a third button. 
     587 * Apart from the title and close button, the three buttons display, two of them configurables and Cancel 
    621588 * @param {Html or String} title The title of the error popup. 
    622589 * @param {Element} content Anything you want to put inside. 
    623  * @param {function} handler A function that will be called with a boolean as argument: 
    624  *                   true if the user pressers "Save", or false if the user presses "Cancel" 
    625  */ 
    626 type("SavePopup", ["ExclusivePopupWithButtons"], 
     590 * @param {function} handler A function that will be called with an Integer as argument: 
     591 *                   1 if the user press button1, 2 for button2, 0 for "Cancel" 
     592 */ 
     593type("SpecialRemovePopup", ["ExclusivePopupWithButtons"], 
    627594    { 
    628595         draw: function() { 
    629596             var self = this; 
    630597 
    631              var saveButton = Html.input('button', {style:{marginRight: pixels(3)}}, $T('Save')); 
    632              saveButton.observeClick(function(){ 
    633                  self.close(); 
    634                  self.handler(true); 
     598             var button1 = Html.input('button', {style:{marginRight: pixels(3)}}, $T(this.buttonTitle1)); 
     599             button1.observeClick(function(){ 
     600                 self.close(); 
     601                 self.handler(1); 
     602             }); 
     603 
     604             var button2 = Html.input('button', {style:{marginLeft: pixels(3), marginRight: pixels(3)}}, $T(this.buttonTitle2)); 
     605             button2.observeClick(function(){ 
     606                 self.close(); 
     607                 self.handler(2); 
    635608             }); 
    636609 
     
    638611             cancelButton.observeClick(function(){ 
    639612                 self.close(); 
     613                 self.handler(0); 
    640614             }); 
    641615 
    642616             return this.ExclusivePopupWithButtons.prototype.draw.call(this, 
    643617                     this.content, 
    644                      Html.div({}, saveButton, cancelButton)); 
     618                     Html.div({}, button1, button2, cancelButton)); 
    645619         } 
    646620    }, 
    647621 
    648     function(title, content, handler) { 
     622    function(title, content, handler, buttonTitle1, buttonTitle2) { 
    649623        var self = this; 
    650624 
     625        this.buttonTitle1 = buttonTitle1; 
     626        this.buttonTitle2 = buttonTitle2; 
    651627        this.content = content; 
    652628        this.handler = handler; 
    653629        this.ExclusivePopupWithButtons(Html.div({style:{textAlign: 'center'}}, title), function(){ 
     630            self.handler(0); 
    654631            return true; 
    655632        }); 
    656633    } 
    657634); 
     635 
    658636 
    659637/** 
     
    710688    } 
    711689); 
     690 
    712691 
    713692type("WarningPopup", ["AlertPopup"], 
  • indico/htdocs/js/indico/Legacy/Widgets.js

    rbcaaf6 rac1aa3  
    12091209        @param methods: get, add, remove, edit 
    12101210        @param kindOfElement: Title of the element that you want to manage. Example 'question' 
    1211         @param header: Header for the table of elements 
     1211        @param header: Header text for the table of elements 
     1212        @param specialRemove: Shows if is necessary a special way to remove items 
    12121213        @return result (return of request): list of items with the fields 'text': content of the item, 'id': element id. 
    12131214        @return the content of the component. Table with list of elements and input and button to add new elements to the list 
    12141215      */ 
    1215         manageListOfElements: function(methods, attributes, kindOfElement, header) { 
     1216        manageListOfElements: function(methods, attributes, kindOfElement, header, specialRemove) { 
    12161217 
    12171218            var widgetContent = Html.div(); 
     
    12621263            }; 
    12631264 
    1264         // Draw the list of current questions added 
    1265         var drawListOfElements = function(result) { 
    1266             // Initialize the i counter 
    1267             this.i = 0; 
    1268             self = this; 
    1269  
    1270             // Remove previous elements 
    1271             if ($E('elementsDiv')) { 
    1272                 widgetContent.remove($E('elementsDiv')); 
    1273             } 
    1274  
    1275             if (result.length) { 
    1276                 var content = Html.div({id:'elementsDiv'}); 
    1277                 var table = Html.table({className:'infoQuestionsTable', cellspacing:'0'}); 
    1278                 content.append(table); 
    1279  
    1280                 // Create the table with the required data 
    1281                 var tr; 
    1282                 var spanRemoveList = []; 
    1283                 var spanEditList = []; 
    1284                 var tdEdit; 
    1285                 var tdRemove; 
    1286  
    1287                 for (var i=0; i < result.length ; i++) { 
    1288                     tr = Html.tr({className: 'infoTR'}); 
    1289                     tdElement = Html.td({className: 'questionContent'}, result[i].text); 
    1290                     tdElement.dom.id = "TEID_"+result[i].id; 
    1291  
    1292                     // 'Edit' elements and functionality 
    1293                     tdEdit = Html.td({className: 'content'}); 
    1294                     var spanEdit = Html.span({className: 'link'},'Edit'); 
    1295                     spanEdit.dom.id = "QEID_"+result[i].id; // Set the span id with the question id included 
    1296                     spanEdit.dom.name = result[i].text; 
    1297                     spanEditList.push(spanEdit); 
    1298                     tdEdit.append(spanEdit); 
    1299  
    1300                     spanEditList[i].observeClick(function(event) { 
    1301                         var spanId = event.target.id.split('_')[1]; 
    1302                         var previousText = $E('TEID_'+spanId).dom.textContent; 
    1303                         var popupContent = Html.textarea({id:'modifyArea', cols:'40', rows:'7'}, previousText); 
    1304                         var popup = new SavePopup('Edit '+kindOfElement, popupContent, 
    1305                                 function(event) { 
    1306                                     var attr = attributes; 
    1307                                     attr['id'] = spanId; 
    1308                                     attr['text'] = popupContent.dom.value; 
    1309                                     indicoRequest(methods.edit, 
    1310                                         attr, 
    1311                                         function(result, error){ 
    1312                                             if (!error) { 
    1313                                                 widgetContent.append(drawListOfElements(result)); 
    1314                                                 widgetContent.append(drawFooter()); 
     1265                // Draw the list of current questions added 
     1266                var drawListOfElements = function(result) { 
     1267                    // Initialize the i counter 
     1268                    this.i = 0; 
     1269                    self = this; 
     1270 
     1271                    // Remove previous elements 
     1272                    if ($E('elementsDiv')) { 
     1273                        widgetContent.remove($E('elementsDiv')); 
     1274                    } 
     1275 
     1276                    if (result.length) { 
     1277                        var content = Html.div({id:'elementsDiv'}); 
     1278                        var table = Html.table({className:'infoQuestionsTable', cellspacing:'0'}); 
     1279                        content.append(table); 
     1280 
     1281                        // Create the table with the required data 
     1282                        var tr; 
     1283                        var spanRemoveList = []; 
     1284                        var spanEditList = []; 
     1285                        var tdEdit; 
     1286                        var tdRemove; 
     1287 
     1288                        for (var i=0; i < result.length ; i++) { 
     1289                            tr = Html.tr({className: 'infoTR'}); 
     1290                            tdElement = Html.td({className: 'questionContent'}, result[i].text); 
     1291                            tdElement.dom.id = "TEID_"+result[i].id; 
     1292 
     1293                            // 'Edit' elements and functionality 
     1294                            tdEdit = Html.td({className: 'content'}); 
     1295                            var spanEdit = Html.span({className: 'link'},'Edit'); 
     1296                            spanEdit.dom.id = "QEID_"+result[i].id; // Set the span id with the question id included 
     1297                            spanEdit.dom.name = result[i].text; 
     1298                            spanEditList.push(spanEdit); 
     1299                            tdEdit.append(spanEdit); 
     1300 
     1301                            spanEditList[i].observeClick(function(event) { 
     1302                                var spanId = event.target.id.split('_')[1]; 
     1303                                var previousText = $E('TEID_'+spanId).dom.textContent; 
     1304                                var popupContent = Html.textarea({id:'modifyArea', cols:'40', rows:'7'}, previousText); 
     1305                                var popup = new ConfirmPopup('Edit '+kindOfElement, popupContent, 
     1306                                        function(action) { 
     1307                                        if (action) { 
     1308                                                    var attr = attributes; 
     1309                                                    attr['id'] = spanId; 
     1310                                                    attr['text'] = popupContent.dom.value; 
     1311                                                    indicoRequest(methods.edit, 
     1312                                                        attr, 
     1313                                                        function(result, error){ 
     1314                                                            if (!error) { 
     1315                                                                widgetContent.append(drawListOfElements(result)); 
     1316                                                                widgetContent.append(drawFooter()); 
     1317                                                            } 
     1318                                                        }); 
     1319                                            } 
     1320                                        }, 'Save'); 
     1321                                popup.open(); 
     1322                            }); 
     1323 
     1324                            // 'Remove' elements and functionality 
     1325                            tdRemove = Html.td({className: 'content'}); 
     1326                            var spanRemove = Html.span({className: 'link'},'Remove'); 
     1327                            spanRemove.dom.id = "QRID_"+result[i].id; // Set the span id with the question id included 
     1328                            spanRemoveList.push(spanRemove); 
     1329                            tdRemove.append(spanRemove); 
     1330 
     1331                            spanRemoveList[i].observeClick(function(event){ 
     1332                                var spanId = event.target.id.split('_')[1]; 
     1333 
     1334                                var attr = attributes; 
     1335                                attr['value'] = spanId; 
     1336                                if (!specialRemove) { 
     1337                                        var popupContent = Html.span({}, 'Are you sure you want to remove the element?'); 
     1338                                        var popup = new ConfirmPopup('Remove '+kindOfElement, popupContent, 
     1339                                                function(action) { 
     1340                                            if (action) { 
     1341                                                            var attr = attributes; 
     1342                                                            attr['id'] = spanId; 
     1343                                                            indicoRequest(methods.remove, 
     1344                                                                attr, 
     1345                                                                function(result, error){ 
     1346                                                                    if (!error) { 
     1347                                                                        widgetContent.append(drawListOfElements(result)); 
     1348                                                                        widgetContent.append(drawFooter()); 
     1349                                                                        } 
     1350                                                                }); 
     1351                                                } 
     1352                                                }, 'Remove'); 
     1353                                } else { 
     1354                                        var popupContent = Html.span({}, 'Do you want to keep the ratings of the judgements of this question (if they exist)?'); 
     1355                                        // For this popup we need two handlers 
     1356                                        var popup = new SpecialRemovePopup('Remove '+kindOfElement, popupContent, 
     1357                                    function(option) { 
     1358                                                        if (option == 0) { 
     1359                                                // close popup option 
     1360                                                null; 
    13151361                                            } 
    1316                                         }); 
    1317                                     }); 
    1318                         popup.open(); 
    1319                     }); 
    1320  
    1321                     // 'Remove' elements and functionality 
    1322                     tdRemove = Html.td({className: 'content'}); 
    1323                     var spanRemove = Html.span({className: 'link'},'Remove'); 
    1324                     spanRemove.dom.id = "QRID_"+result[i].id; // Set the span id with the question id included 
    1325                     spanRemoveList.push(spanRemove); 
    1326                     tdRemove.append(spanRemove); 
    1327  
    1328                     spanRemoveList[i].observeClick(function(event){ 
    1329                         var spanId = event.target.id.split('_')[1]; 
    1330  
    1331                         var attr = attributes; 
    1332                         attr['value'] = spanId; 
    1333  
    1334                         var popupContent = Html.span({}, 'Are you sure you want to remove the element?'); 
    1335                         var popup = new SavePopup('Remove '+kindOfElement, popupContent, 
    1336                                 function(event) { 
    1337                                     var attr = attributes; 
    1338                                     attr['id'] = spanId; 
    1339                                     indicoRequest(methods.remove, 
    1340                                         attr, 
    1341                                         function(result, error){ 
    1342                                             if (!error) { 
    1343                                                 widgetContent.append(drawListOfElements(result)); 
    1344                                                 widgetContent.append(drawFooter()); 
    1345                                                 } 
    1346                                         }); 
    1347                                 }); 
    1348                         popup.open(); 
    1349                     }); 
    1350  
    1351  
    1352                     table.append(tr); 
    1353                     tr.append(tdElement); 
    1354                     tr.append(tdEdit); 
    1355                     tr.append(tdRemove); 
    1356                 } 
    1357             } 
    1358             return content; 
    1359  
    1360           }; 
     1362                                            if (option == 1) { 
     1363                                                // Keep ratings handler 
     1364                                                            var attr = attributes; 
     1365                                                            attr['id'] = spanId; 
     1366                                                            attr['keepJud'] = true; 
     1367                                                            indicoRequest(methods.remove, 
     1368                                                                attr, 
     1369                                                                function(result, error){ 
     1370                                                                    if (!error) { 
     1371                                                                        widgetContent.append(drawListOfElements(result)); 
     1372                                                                        widgetContent.append(drawFooter()); 
     1373                                                                        } 
     1374                                                                }); 
     1375                                                } 
     1376                                            if (option == 2) { 
     1377                                                // Remove ratings handler 
     1378                                                var attr = attributes; 
     1379                                                attr['id'] = spanId; 
     1380                                                            attr['keepJud'] = false; 
     1381                                                            indicoRequest(methods.remove, 
     1382                                                                attr, 
     1383                                                                function(result, error){ 
     1384                                                                    if (!error) { 
     1385                                                                        widgetContent.append(drawListOfElements(result)); 
     1386                                                                        widgetContent.append(drawFooter()); 
     1387                                                                        } 
     1388                                                                }); 
     1389                                                } 
     1390                                                }, 'Keep ratings', 'Remove ratings'); 
     1391                                } 
     1392                                popup.open(); 
     1393                            }); 
     1394 
     1395 
     1396                            table.append(tr); 
     1397                            tr.append(tdElement); 
     1398                            tr.append(tdEdit); 
     1399                            tr.append(tdRemove); 
     1400                        } 
     1401                    } 
     1402                    return content; 
     1403 
     1404                  }; 
    13611405 
    13621406          return widgetContent; 
Note: See TracChangeset for help on using the changeset viewer.