errs=append(errs,fmt.Sprintf("%q: unable to add ucq: %s",path.Base(exercice.Path),err))
}else{
fornline,quest:=rangestrings.Split(ucq,"\n"){
iflen(quest)==0{
continue
}
iflen(quest)<2{
errs=append(errs,fmt.Sprintf("%q: error in ucq file at line %d: missing response",path.Base(exercice.Path),nline+1))
continue
}
// Expect 0 or 1
ifquest[0]!=48&&quest[0]!=49{
errs=append(errs,fmt.Sprintf("%q: error in ucq file at line %d: invalid format: first character has to be either 0 or 1",path.Base(exercice.Path),nline+1))
errs=append(errs,fmt.Sprintf("%q: error in mcq file at line %d: %s",path.Base(exercice.Path),nline+1,err))
continue
}else{
hasOne:=false
forcid,choice:=rangequest_splt[1:]{
// Expect 0 or 1
ifchoice[0]!=48&&choice[0]!=49{
errs=append(errs,fmt.Sprintf("%q: error in mcq file at line %d,%d: invalid format: first character has to be either 0 or 1",path.Base(exercice.Path),nline+1,cid))
errs=append(errs,fmt.Sprintf("%q: error in mcq file at line %d,%d: %s",path.Base(exercice.Path),nline+1,cid,err))
continue
}
ifchoice[0]==49{
ifhasOne{
flag.Kind="checkbox"
flag.Update()
errs=append(errs,fmt.Sprintf("%q: warning in mcq file at line %d: multiple expected response, switching to ucq-like quiz; is this really expected?",path.Base(exercice.Path),nline+1))
}else{
hasOne=true
}
}
}
if!hasOne{
errs=append(errs,fmt.Sprintf("%q: warning in mcq file at line %d: no valid answer defined, is this really expected?",path.Base(exercice.Path),nline+1))