Setup:

Clear["Global`*"]

Needs["Algebra`Trigonometry`"]

(* Not Used 
     Needs["Calculus`FourierTransform`"]
*)

Example 1:

Clear["Global`*"]

Part a)

Clear[f];
f[x_]:=x /; x <= N[Pi];
f[x_]:=0 /; x >= N[Pi];

Plot[f[x],{x,0,2 Pi}];

c[0]= 1/(2 Pi) Integrate[ x  ,{x,0,1 Pi}]

c[m_]= 1/(2 Pi) Integrate[ x Exp[- I m x] ,{x,0,1 Pi}]

rule={Exp[+2 I Pi m] ->  1
     ,Exp[-2 I Pi m] ->  1
     ,Exp[+  I Pi m] -> (-1)^m
     ,Exp[-  I Pi m] -> (-1)^m
     };

(* Sometimes we have to work out special cases 
 to avoid divide by zero and other problems. *) 
 
term[0]= c[0];

term[1]= Limit[ c[m] Exp[I m x] + c[-m]  Exp[-I m x] ,m->1]

term[m_]= c[m] Exp[I m x] + c[-m]  Exp[-I m x] //.rule //Together

series[n_]:= Sum[ term[m] ,{m,0,n}]

Plot[ Join[{f[x]},Table[series[i],{i,2,5,1}] ] //Evaluate
  ,{x,0,2 Pi}];

Plot[ {f[x], series[30] } //Evaluate ,{x,0,2 Pi}];

term2[0] = term[0] //ComplexToTrig //Simplify;
term2[1] = term[1] //ComplexToTrig //Simplify;

term2[m_]= term[m] //ComplexToTrig //Simplify

series2[n_]:= Sum[ term2[m] ,{m,0,n}]

series[5]

series2[5]