LoadQuestions.m 772 B

12345678910111213141516171819202122232425262728
  1. % LoadQuestions.m
  2. %
  3. % This function loads the question files and returns them in a cell
  4. % array. The first column is the question identifier
  5. %
  6. % input:
  7. % inputFile - name of the file
  8. %
  9. % output:
  10. % qIds - question IDs, nx1 cell array
  11. % options - options following the question ID. It is an nx1 cell array which contains
  12. % the available options as another cell array in each line
  13. function [qIds, options] = LoadQuestions(inputFile)
  14. fid = fopen(inputFile);
  15. qIds = {};
  16. options = {};
  17. line = fgetl(fid);
  18. ind = 1;
  19. while ischar(line);
  20. tmpLine = strsplit(line, ',');
  21. qIds{ind,1} = tmpLine{1,1};
  22. options{ind,1} = {tmpLine{2:end}};
  23. line = fgetl(fid);
  24. ind = ind + 1;
  25. end
  26. end