def import_scoring(self, force):
        """
        Create the Scoring models.

        @param force: Should the Scoring settings be written if the model already exist?
        @returns: A flag indicating if the import was successful.
        """
        result = True
        if not self.store.has_scoring():
            logger.debug('Scoring not configured')
        
        admin = User.objects.filter(is_superuser=True)
        if admin.count() == 0:
            logger.debug('There was no superuser installed; ScoreDisplays need to be assigned ownership to a superuser.')
            return False
        else:
            admin = admin[0]

        # Import score displays.
        for sd in self.store.filter_scoredisplays():
            lb = LegislativeBody.objects.get(name=sd.get('legislativebodyref'))
             
            sd_obj, created = ScoreDisplay.objects.get_or_create(
                name=sd.get('id')[:50],
                title=sd.get('title')[:50],
                legislative_body=lb,
                is_page=sd.get('type') == 'leaderboard',
                cssclass=(sd.get('cssclass') or '')[:50],
                owner=admin
            )

            for locale in [l[0] for l in settings.LANGUAGES]:
                po = self.poutils[locale]
                po.add_or_update(
                    msgid=u'%s short label' % sd.get('id'),
                    msgstr=sd.get('title') or '',
                    occurs=[(os.path.abspath(self.store.datafile), sd.sourceline,)]
                )
                po.add_or_update(
                    msgid=sd.get('id') % u'%s label',
                    msgstr=sd.get('title') or '',
                    occurs=[(os.path.abspath(self.store.datafile), sd.sourceline,)]
                )
                po.add_or_update(
                    msgid=u'%s long description' % sd.get('id'),
                    msgstr='',
                    occurs=[(os.path.abspath(self.store.datafile), sd.sourceline,)]
                )


            if created:
                logger.debug('Created ScoreDisplay "%s"', sd.get('title'))
            else:
                logger.debug('ScoreDisplay "%s" already exists', sd.get('title'))

            # Import score panels for this score display.
            for spref in self.store.filter_displayed_score_panels(sd):
                sp = self.store.get_score_panel(spref.get('ref'))
                name = sp.get('id')[:50]
                position = int(sp.get('position'))
                template = sp.get('template')[:500]
                cssclass = (sp.get('cssclass') or '')[:50]
                pnltype = sp.get('type')[:20]

                is_ascending = sp.get('is_ascending')
                if is_ascending is None:
                    is_ascending = True
                
                ascending = sp.get('is_ascending')
                sp_obj, created = ScorePanel.objects.get_or_create(
                    type=pnltype,
                    position=position,
                    name=name,
                    template=template,
                    cssclass=cssclass,
                    is_ascending=(ascending is None or ascending=='true'), 
                )

                if created:
                    sd_obj.scorepanel_set.add(sp_obj)

                    logger.debug('Created ScorePanel "%s"', name)
                else:
                    attached = sd_obj.scorepanel_set.filter(id=sp_obj.id).count() == 1
                    if not attached:
                        sd_obj.scorepanel_set.add(sp_obj)

                    logger.debug('ScorePanel "%s" already exists', name)

                for locale in[l[0] for l in settings.LANGUAGES]:
                    po = self.poutils[locale]
                    po.add_or_update(
                        msgid=u'%s short label' % sp_obj.name,
                        msgstr=sp.get('title') or '',
                        occurs=[(os.path.abspath(self.store.datafile), sp.sourceline,)]
                    )
                    po.add_or_update(
                        msgid=u'%s label' % sp_obj.name,
                        msgstr=sp.get('title') or '',
                        occurs=[(os.path.abspath(self.store.datafile), sp.sourceline,)]
                    )
                    po.add_or_update(
                        msgid=u'%s long description' % sp_obj.name,
                        msgstr='',
                        occurs=[(os.path.abspath(self.store.datafile), sp.sourceline,)]
                    )

                # Import score functions for this score panel
                for sfref in self.store.filter_paneled_score_functions(sp):
                    sf_node = self.store.get_score_function(sfref.get('ref'))
                    sf_obj = self.import_function(sf_node, force)

                    # Add ScoreFunction reference to ScorePanel
                    sp_obj.score_functions.add(sf_obj)

        # It's possible to define ScoreFunctions that are not part of any ScorePanels, yet
        # still need to be added to allow for user selection. Find and import these functions.
        for sf_node in self.store.filter_score_functions():
            self.import_function(sf_node, force)

        # Import validation criteria.
        if not self.store.has_validation():
            logger.debug('Validation not configured')
            return False;

        for vc in self.store.filter_criteria():
            lb = LegislativeBody.objects.get(name=vc.get('legislativebodyref'))

            for crit in self.store.filter_criteria_criterion(vc):
                # Import the score function for this validation criterion
                sfref = self.store.get_criterion_score(crit)
                try:
                    sf = self.store.get_score_function(sfref.get('ref'))
                except:
                    logger.info("Couldn't import ScoreFunction for Criteria %s", crit.get('name'))
                    result = False

                sf_obj = self.import_function(sf, force)

                # Import this validation criterion
                attributes = {
                    'name': crit.get('id')[0:50],
                    'function': sf_obj,
                    'legislative_body': lb
                }
                crit_obj, created, changed, message = check_and_update(ValidationCriteria, overwrite=force, **attributes)

                for locale in [l[0] for l in settings.LANGUAGES]:
                    po = self.poutils[locale]
                    po.add_or_update(
                        msgid=u'%s short label' % attributes['name'],
                        msgstr=crit.get('name') or '',
                        occurs=[(os.path.abspath(self.store.datafile), crit.sourceline,)]
                    )
                    po.add_or_update(
                        msgid=u'%s label' % attributes['name'],
                        msgstr=crit.get('name') or '',
                        occurs=[(os.path.abspath(self.store.datafile), crit.sourceline,)]
                    )
                    po.add_or_update(
                        msgid=u'%s long description' % attributes['name'],
                        msgstr=crit.get('description') or '',
                        occurs=[(os.path.abspath(self.store.datafile), crit.sourceline,)]
                    )

                if changed and not force:
                    logger.info(message)
                else:
                    logger.debug(message)

        return result
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/config.py/ConfigImporter.import_scoring/swapped operands of `%`