Index: openacs-4/packages/dotlrn-ecommerce/www/admin/applications.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/applications.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/dotlrn-ecommerce/www/admin/applications.tcl	23 Jun 2005 16:22:24 -0000	1.3
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/applications.tcl	23 Jun 2005 17:47:33 -0000	1.4
@@ -33,18 +33,20 @@
 	    label "Application"
 	    display_template {
 		<if @applications.asm_url@ not nil>
-		<a href="@applications.asm_url;noquote@" class="button" target="_blank">Application</a>
+		<a href="@applications.asm_url;noquote@" class="button" target="_blank">View</a>
 		</if>
 		<else>
 		N/A
 		</else>
 	    }
+	    html { align center }
 	}
 	actions {
 	    label ""
 	    display_template {
 		<a href="@applications.approve_url;noquote@" class="button">Approve</a>
 	    }
+	    html { align center }
 	}
     }
 
@@ -58,19 +60,27 @@
 
     # Get associated assessment
     if { [db_0or1row assessment {
-	select a.session_id
+	select ss.session_id
 
 	from dotlrn_ecommerce_section s,
-	dotlrn_catalogi c,
-	cr_items i,
-	as_sessions a
+	(select c.*
+	 from dotlrn_catalogi c,
+	 cr_items i
+	 where c.course_id = i.live_revision) c,
+	(select a.*
+	 from as_assessmentsi a,
+	 cr_items i
+	 where a.assessment_id = i.latest_revision) a,
+	as_sessions ss
 
-	where s.course_id = c.item_id
-	and c.course_id = i.live_revision
-	and c.assessment_id = a.assessment_id
-	and s.community_id = :community_id
-	and a.subject_id = :user_id
+	where s.community_id = :community_id
+	and s.course_id = c.item_id
+	and c.assessment_id = a.item_id
+	and a.assessment_id = ss.assessment_id
+	and ss.subject_id = :user_id
 
+	order by creation_datetime desc
+
 	limit 1
     }] } {
 	set asm_url [export_vars -base /assessment/asm-admin/results-session { session_id }]