Switch Among Academic terms Automatically,in Odk

*Good day all,please is there a simplified process of switching among academic terms in kobotoolbox.

I intend to collect students data,but want to create a formula expression that will collect student information based on the current academic cycle.

I have 3 academic cycles in a year

Acdemic cycles are:

Firstterm start:Septemeber 10th-December15th
Secondterm start:Jan10th-April2nd.

Thirdterm start:
Start from May 2nd-July 30th

Each term have a separate 3month intervals.

How do i carry out this task in odk,to detect the term,as first term,secondterm,third term respectively,with the session year as

2022/2023
2024/2025
Based on the session that make up the 3 academic terms;

I have added this into the calculation column and was unable to get my form deployed:
if(today()>=date(concat(year(today()),"-09-10")) and today()<=date(concat(year(today()),"-12-15")), "First Term "&concat(year(today()),"/",year(today())+1), if(today()>=date(concat(year(today())+1,"-01-10")) and today()<=date(concat(year(today())+1,"-04-02")), "Second Term "&concat(year(today()),"/",year(today())+1), if(today()>=date(concat(year(today()),"-05-02")) and today()<=date(concat(year(today()),"-07-30")), "Third Term "&concat(year(today()),"/",year(today())+1), "")))

unable to deploy your forms beacuse it contains error?
Unexpected KoBoCAT error 400: b'{"detail":"ODK Validate Errors:\n>> XForm is invalid. See above for the errors.\n: Invalid calculate for the bind attached to \"${calculate_qc6aq08}\" : Couldn't understand the expression starting at this point: ..., \"First Term \"\xcd\x8e&concat(year(to... in expression if(today()>=date(concat(year(today()),\"-09-10\")) and today()<=date(concat(year(today()),\"-12-15\")), \"First Term \"&concat(year(today()),\"/\",year(today())+1), if(today()>=date(concat(year(today())+1,\"-01-10\")) and today()<=date(concat(year(today())+1,\"-04-02\")), \"Second Term \"&concat(year(today()),\"/\",year(today())+1), if(today()>=date(concat(year(today()),\"-05-02\")) and today()<=date(concat(year(today()),\"-07-30\")), \"Third Term \"&concat(year(today()),\"/\",year(today())+1), \"\")))\n\nThe following files failed validation:\n${tmp3vmguwel}\n\nResult: Invalid"}'

a4dkxyjr6AFuteyRK36ZDY.xlsx (10.6 KB)

This isnt a valid expression. I think you probably want something like:

concat("First Term ", ...)

Further, year() is not a valid ODK XPath function (see https://docs.getodk.org/form-operators-functions/). Try this instead to extract the year from a date:

format-date(today(), "%Y")

Which is to say, you probably need to rewrite the entire calculation along the lines of uisng:

concat("First Term ", format-date(today(), "%Y"), "/", format-date(today(), "%Y")+1)

1 Like

Thank you @Xiphware , this work around you supplied works.

1 Like