%grade_printout.m
%Print grades. Put in file 'total_grade.text'
%Calculate grades first
%modified  12/12/2010
%
%grade_parameters       % run the script file that assigns grade paramets


fid=fopen('total_grade.text','w');   %open data file with grades
 
number_on_page=3;               %number of students to print before form feed

fprintf(fid, '  \n\n\n  TAM 2020 GRADES  %s\n\n\n ',   datestr(now)   );

for i=1:nstud     %once through the loop for each student

    thisname = char(names(i,1:4)); 
    
   fprintf(fid,'\n%s', '****************************************************************');
    fprintf(fid,'\n%s:', thisname);
   fprintf(fid,' %4.1f --> %s     ', total_grade(i), letter_grade(i,:) );
   fprintf(fid,'   %s  ',   datestr(now)   );

   
   fprintf(fid, '\n%s', '              ');
   fprintf(fid, 'bonus       iclicker      survey     ');
         fprintf(fid,'%s', '   lab 1    lab 2    lab 3    labave');
 
   fprintf(fid, '\n%s', 'This stud:   ');
   fprintf(fid, '%4.1f         ', bonus(i), clickerraw(i), survey(1)); 
          fprintf(fid, '  %4.1f   ', labs(i,1:3), labtot(i)); 

   fprintf(fid, '\n%s', 'class Median:');
   fprintf(fid, '%4.1f         ', bonusmed, clickerrawmed, surveymed); 
          fprintf(fid, '  %4.1f   ', labsmed(1:3), labtotmed); 
       
          fprintf(fid, '\n%s', 'Class max:   ');
   fprintf(fid, '%4.1f         ', bonusmax, clickerrawmax, surveymax); 
          fprintf(fid, '  %4.1f   ', labsmax(1:3), labtotmax); 
   
          


   fprintf(fid, '\n\n           ',' ');
   fprintf(fid, 'HW%-2.0f ', 1:14 ); fprintf(fid, '\n',' ');
  fprintf(fid, 'This stud: ',' ');
   fprintf(fid, '%-5.1f', homeworks(i,:)); fprintf(fid, '\n',' ');
     fprintf(fid, 'Median:    ',' ');
   fprintf(fid, '%-5.1f', homeworksmed(:)); fprintf(fid, '\n',' '); 
  fprintf(fid, 'Max:       ',' ');
   fprintf(fid, '%-5.1f', homeworksmax(:)); fprintf(fid, '\n',' ');
   

   fprintf(fid, '\n',' '); 
   fprintf(fid, 'PREL/FIN   P1    P2    P3    P4    P5    P6    P7    P8    P9    F10   ');
   fprintf(fid,'F11   F12   F13   F14\n');
    fprintf(fid, 'This stud: ',' ');
    fprintf(fid,  '%-6.1f', prelimsraw(i,1:2:18), finalexam(i,:)); fprintf(fid, '\n',' ');
   fprintf(fid, 'Class med: ',' ');
   fprintf(fid, '%-6.1f', prelimsrawmed(1:2:18),finalexammed(:)); fprintf(fid, '\n',' ');
   fprintf(fid, 'Class max: ',' ');
  fprintf(fid, '%-6.1f', prelimsrawmax(1:2:18),finalexammax(:)); fprintf(fid, '\n',' ');
   fprintf(fid, 'Redo:      ',' ');
  fprintf(fid, '%-6.1f', prelimsraw(i,2:2:18)); fprintf(fid, '\n',' ');
 fprintf(fid, 'Scaled:    ',' ');
  fprintf(fid, '%-6.1f', examsscaled(i,:)); fprintf(fid, '\n',' ');

   
  
   

   fprintf(fid, '%s',  '                   ');
   fprintf(fid,'\n%s\n', '                HWtot    ClickerTot  Examstot      HWexam   GRAND TOTAL');
   fprintf(fid, 'This stud: ',' ');
     fprintf(fid, '  %7.1f   ', homeworktot(i), clickerdrop(i), examtot(i),hwexam(i), total_grade(i)); 
   fprintf(fid, '\nClass med: ',' ');
     fprintf(fid, '  %7.1f   ', homeworktotmed, clickerdropmed, examtotmed, 0, total_grademed); 
   fprintf(fid, '\nClass max: ',' ');
     fprintf(fid, '  %7.1f   ', homeworktotmax, clickerdropmax, examtotmax, 4, total_grademax); 
  
   

   fprintf(fid, '\n\n\n',' ');   %blank lines between students
%   
%   %Put page break after number_on_paage students have been printed out  
  if (rem(i,number_on_page)==0) fprintf(fid, '\f',' ');   end;
%    
   
end   %one loop for each student
status = fclose(fid);
%disp(fileread('total_grade.text'))
disp(['Grade printing finished:   '  datestr(now)])
