0

In For - Where - Do Script - Add a loop

Hi, 

I'm struggling with an issue. I'm using a for-where-do script to look for the specific Students concerned with an Exam (an Exam is connected to only one Course, so I look for Students where Course = s), and automatically create records in another Individual_Assignement table, where it creates a line associating Student_name, Exam_name with the last column is Grade, which will be manually assigned to the teacher. 

I want to add an extra column to this Individual Assignement table, an Individual Assignment for each Individual Assignment, different from its ID.

I tried this formula :

let s := this;
let number := 1;
for p in select Course where Course = s.Course do
let number := number + 1;
let a := (create Individual_Assignment);
a.(Student_Course := p);
a.(Exam := s);
a.(assignement_number := number)
let number := number +1

void
end

The code works great, and creates the appropriate lines, for each Student and its Individual Assignment. The problem is that my number counter loop does not work : all Individual Assignements are set to 1, meaning that the let number := number + 1 is not taken into account. 

Could anyone suggest a workaround ?

Thanks !

P.

10 replies

null
    • JGM
    • Jose_Monteiro
    • 4 yrs ago
    • Reported - view

    You should use first
    let number := 1 ;
    to set number variable and its initial value.

    then use only 
    number := number + 1 ;

    For instance the following code:
    let arr := ["a", "b", "c"];
    let number := 1;
    for i in arr do
      let number := number + 1 ;
      number
    end

    produces the following output in Console:
    2
    2
    2

    While with this code:
    let arr := ["a", "b", "c"];
    let number := 1;
    for i in arr do
      number := number + 1 ;
      number
    end

    you get:
    2
    3
    4

    • Pierre_Laniray
    • 4 yrs ago
    • Reported - view

    Thanks, it works great ! 
    Just getting used to the syntax :-)

    P.

    • HoustonED
    • Joseph_York
    • 4 yrs ago
    • Reported - view

    Hello, I'm a college professor from KEDGE Business School (Talence, France) and I stuggle to understand the Ninox script language from the manuals. I spent much time on it, when I had students taking late exams (which is quite often) and I had to re-enter the answers and then assign (again) constant value. Though it does help me keep track of my online students. Where can I find the tutorial for the Individual_Assignement table? Thanks.

     

    https://ninoxdb.de/en/manual/tables/table-references-and-relations https://theessayservice.org

    • JGM
    • Jose_Monteiro
    • 4 yrs ago
    • Reported - view

    Hello,

    I am not an expert on Ninox.
    But you are not saying much about your problem.

    If you could describe it in more detail, maybe someone could get a better idea of the problem and help you solve it.

    Jose

    • Sean
    • 4 yrs ago
    • Reported - view

    @Jose, I think it's a new version of spam post.

    • JGM
    • Jose_Monteiro
    • 4 yrs ago
    • Reported - view

    @Sean,

    I never thought this could happen in Forums where people are looking for help.
    Learning every day. :)
    Thanks!

    • Ninox partner
    • RoSoft_Steven.1
    • 4 yrs ago
    • Reported - view

    Spam bots are getting smarter and smarter.....

    • jordenalez65
    • 3 yrs ago
    • Reported - view

    Good Work I like it

    • nonw
    • Aurora
    • 3 yrs ago
    • Reported - view

    [url]https://ninox.com/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/how-to-delete-files-and-folders-that-are-locked-from-being-deleted-6156db0521cbbb48088a6d21[/url]

Content aside

  • 3 yrs agoLast active
  • 10Replies
  • 2125Views