#!/bin/sh -
#
#	Generates an alphabetical (i.e. sorted by surname) version of
#	the PPT_map information, giving realnames and login-names,
#	PPT-group by PPT-group, on the standard output.
#
progname=`basename $0`
ex_category="labs"
marker_category=`show_marker_category_for $ex_category`
if [ $? -ne 0 ]; then
	echo "$progname: fatal error: no marker category for exercise category '$ex_category'" >&2
	exit 1
fi


if [ $# -ne 1 ]; then
	echo "usage: $progname <labgroup>" >&2
	exit 1
fi


labgroup=$1
if [ `show_all_labgroups | grep -wc $labgroup` -ne 1 ]; then
	echo "$progname: error: no labgroup $labgroup" >&2
	exit 1
fi


echo "=========Alphabetical ${marker_category}-group listing for $labgroup:========="
echo ""

for marker in `show_all_${marker_category}s $labgroup | sort_by_surname` ; do
	echo "*****Students of ${marker_category} `findname $marker` ($marker)*****"
	for student in `show_students_of_${marker_category} $labgroup $marker | sort_by_surname` ; do
		echo "`findname $student` ($student)"
	done #for student

	echo ""
done #for marker

echo "=========End of alphabetical ${marker_category}-group listing for $labgroup.========="
