﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="70e5beeb-a3f6-4ef5-af40-8e703083b44b" codekey="ERGODirekt_TeststatusübersichtFürZielgruppen" categoryCodekey="TestsAndQuestions" name="Teststatusübersicht für Zielgruppen" description="">
      <MetaData created="2015-06-26T13:20:47" createdBy="Administrator TestAllFeatures (Administrator)" createdBy_user_id="12" modified="2015-06-26T17:25:15" modifiedBy="Administrator TestAllFeatures" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="c5fd8bcc-2b1a-4f1d-b30d-9063c3f768cc" mandatorName="ERGODirekt" isStandard="False" isUsedByMenu="False" />
      <Parameters>
        <Parameter id="4aaf4f45-f70a-452a-92b5-f8e9b8b0dfb6" isRequired="True" allowMultiSelect="False" name="Test" contextName="Test" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="999ebf32-9a9f-466d-b89d-00fdc224a282" isRequired="False" allowMultiSelect="True" name="Zielgruppe abhängig vom Test" contextName="Zielgruppe abhängig vom Test" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
      <Roles>
        <Role id="90" />
      </Roles>
      <command>
  SELECT title as TestName FROM tblItems where id=@test_id
  
  SELECT title as Zielgruppe,
	   (select count(*) 
	      from tblUsersTargetGroups 
		 where targetGroup_id=tblTargetGroups.id) as 'Benutzer in Zielgruppe',
	   (select count(*) 
	      from tblUsersTargetGroups utg
		 where targetGroup_id=tblTargetGroups.id
		   and exists(select * from tblStatusUserItemHistory where user_id=utg.UserCn and item_id=@test_id and overrideDate is null)
		 ) as 'Benutzer - Test bearbeitet',
	   (select count(*) 
	      from tblUsersTargetGroups utg
		 where targetGroup_id=tblTargetGroups.id
		   and exists(select * from tblStatusUserItemHistory where user_id=utg.UserCn and item_id=@test_id and overrideDate is null)
		   and not exists(select * from tblStatusUserItemHistory where user_id=utg.UserCn and item_id=@test_id and overrideDate is null and status=2)
		 ) as 'Benutzer - Test nicht bestanden',
	   (select count(*) 
	      from tblUsersTargetGroups utg
		 where targetGroup_id=tblTargetGroups.id
		   and exists(select * from tblStatusUserItemHistory t1 where t1.user_id=utg.UserCn and t1.item_id=@test_id and t1.overrideDate is null and t1.status=2 
		     and exists(select * from tblStatusUserItemHistory t2 where t2.user_id=utg.UserCn and t2.item_id=@test_id and t2.overrideDate is null and t2.endDate&lt;=t1.startDate and t2.status=3
		        and exists(select * from tblStatusUserItemHistory t3 where t3.user_id=utg.UserCn and t3.item_id=@test_id and t3.overrideDate is null and t3.endDate&lt;=t2.startDate and t3.status=3)
                   )
                 )
		 ) as 'Benutzer - Anzahl Test bestanden: Versuche &gt; 2'
  FROM tblTargetGroups 
 where tblTargetGroups.id in (SELECT * FROM @targetGroup_id)
 order by title</command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="4aaf4f45-f70a-452a-92b5-f8e9b8b0dfb6" isSystem="True" name="Test" reportParameterType_id="c613c165-96af-465b-bf6c-c0cba9a2dc5d" queryParameterName="@test_id" />
    <Parameter id="999ebf32-9a9f-466d-b89d-00fdc224a282" isSystem="True" name="Zielgruppe abhängig vom Test" reportParameterType_id="eb1b254d-e920-43f2-8d5b-52510017d16e" queryParameterName="@targetGroup_id" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="c613c165-96af-465b-bf6c-c0cba9a2dc5d" isSystem="True" name="Test" datatype="Test" dataValueField="" dataTextField="" />
    <ParameterType id="eb1b254d-e920-43f2-8d5b-52510017d16e" isSystem="False" name="Zielgruppe abhängig von Test" datatype="IntegerDDL" dataValueField="id" dataTextField="title">
      <query>
        SELECT DISTINCT tblTargetGroups.title, tblTargetGroups.id 
        FROM          tblTargetGroups   
        INNER JOIN tblEduOffersTargetGroups ON tblTargetGroups.id = tblEduOffersTargetGroups.targetGroup_id   
        INNER JOIN tblEduOffersModules ON tblEduOffersTargetGroups.eduOffer_id = tblEduOffersModules.eduOffer_id   
        INNER JOIN tblModuleItems ON tblEduOffersModules.module_id = tblModuleItems.module_id    
        WHERE tblModuleItems.item_id = @test_id</query>
      <Parameters>
        <Parameter id="4aaf4f45-f70a-452a-92b5-f8e9b8b0dfb6" isRequired="False" allowMultiSelect="False" name="Test" contextName="Test" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>