I think as the data model is right now, if we have duplicate level_ids in a
script it won’t act asa “review level" because we store progress for a User
keyed on a Level not a ScriptLevel (the second appearance of the level will
be completed when the user completes the first one). If that’s a
requirement we’ll have to change the data model, so if we need that for one
of the upcoming milestones it would be good to know about it.




On Wed, Apr 30, 2014 at 9:19 AM, tobyk100 <notifications@github.com> wrote:

> In app/models/script.rb:
>
> > +      # Concepts are comma-separated, indexed by name
> > +      row['concept_ids'] = (concepts = row.delete('concepts')) && concepts.split(',').map(&:strip).map do |concept_name|
> > +        (Concept.find_by_name(concept_name) || raise("missing concept '#{concept_name}'")).id
> > +      end
> > +
> > +      # Reference one Level per element
> > +      level = custom ?
> > +        Level.find_by(name: row['name']) :
> > +        Level.where(game: Game.find_by(name: row.delete('game')), level_num: row['level_num']).first_or_create
> > +
> > +      raise "There does not exist a level with the name '#{row['name']}'. From the row: #{row}" if level.nil?
> > +      raise "Level #{level.to_json}, does not have a game." if level.game.nil?
> > +      stage = row.delete('stage')
> > +      level.update(row)
> > +
> > +      script_level = ScriptLevel.where(
>
> @laurelfan <https://github.com/laurelfan>, checked with @kapone97<https://github.com/kapone97>,
> we want to allow the possibility of duplicate level_ids in a script in case
> we want to do a review level.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/code-dot-org/dashboard/pull/538/files#r12151749>
> .
>