﻿<?xml version="1.0" encoding="utf-8"?>
<ReportsExport>
  <Reports>
    <Report id="f47d3aac-5c2f-433a-9ba8-5c03c5be4745" codekey="ADAC_MissingTestStatistics" categoryCodekey="SpecialPurpose" name="Missing test statistics" description="Report lists test results which were not generated in teststatistics">
      <MetaData created="2013-07-15T12:05:24" createdBy="Administrator Zentrale (Administrator)" createdBy_user_id="2" modified="2013-07-30T16:44:34" modifiedBy="Administrator Zentrale" />
      <ExecutionDetails format="TableResult" commandType="SqlCommandOrQuery" exportHandler="" adminControl="" exportMultipleTablesToSheets="False" datesWithTime="False" extraParams="" />
      <Mandators mandatorMode="OnlyOwner" mandator_id="7da81670-5067-49c3-a371-379bb5dc4f11" mandatorName="ADAC" isStandard="False" isUsedByMenu="False">
        <Mandator mandatorName="ADAC" />
      </Mandators>
      <Parameters>
        <Parameter id="a785aecc-668a-4609-9613-394bd4d708c2" isRequired="False" name="Mandant" contextName="Mandant" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
        <Parameter id="e2101142-a646-4cb0-83c7-9efa25715454" isRequired="True" name="Jahr" contextName="Jahr" defaultValue="" renderHint="DropDownList" disableParameter="DontDisable" />
      </Parameters>
      <Roles />
      <command>
        SELECT descUserCn as 'Kennung', 
	            Vorname, Nachname, 
              tblMandators.name as 'Mandant',
	            tblItems.title as 'Test-Title',
              tblItems.titleForLearners as 'TitleForLearner',
              lastPing as 'StartDate',
              cast(case when (select COUNT(*) from tblTasTestSessionQuestions where testSessionId = tblTasTestSessions.id)=0 then 0 else
              ((select COUNT(*) from tblTasTestSessionQuestions where testSessionId = tblTasTestSessions.id and answeredCorrectly=1)*100)
              /(select COUNT(*) from tblTasTestSessionQuestions where testSessionId = tblTasTestSessions.id) end as varchar) + '%'
	            as 'Testresult'
        FROM tblTasTestSessions 
	          inner join tblTasTests on tblTasTestSessions.test_id = tblTasTests.id 
	          inner join tblItems on tblItems.id = tblTasTests.id 
	          inner join v_Users on tblTasTestSessions.user_id = v_Users.intUserCn 
	          inner join tblMandators on tblMandators.id = tblTasTests.mandator_id 
        WHERE 
	          (@mandator_id is null or v_Users.mandator_id=@mandator_id)
            and mode&lt;=1
            and testSessionState=3
            and DATEDIFF( MINUTE, lastPing, GETDATE() ) &gt; 1
            and not exists(select * from tblTasStatsTestSessions where tblTasStatsTestSessions.testsession_id=tblTasTestSessions.id)
            and not exists(select * from tblActionLog where action_id in (85,128) and effectedObject_id=tblTasTestSessions.id)
            and not exists(select * from tblActionLog where action_id in (85,128) and effectedObject_id=tblTasTestSessions.test_id and effectedObjectInt_id=tblTasTestSessions.user_id)
            and exists(select * from tblTasTestSessionQuestions where testSessionId = tblTasTestSessions.id and answeredCorrectly=1)
            and year(lastPing) = @year
        ORDER BY startDate, Nachname, Vorname, tblItems.title
      </command>
    </Report>
  </Reports>
  <Parameters>
    <Parameter id="a785aecc-668a-4609-9613-394bd4d708c2" isSystem="True" name="Mandant" reportParameterType_id="6b8fa242-5449-45b3-a81a-65a7e5e3b51d" queryParameterName="@mandator_id" />
    <Parameter id="e2101142-a646-4cb0-83c7-9efa25715454" isSystem="False" name="Jahr" reportParameterType_id="472e4587-12a6-49cd-8063-5f6d315f9c3d" queryParameterName="@year" />
  </Parameters>
  <ParameterTypes>
    <ParameterType id="6b8fa242-5449-45b3-a81a-65a7e5e3b51d" isSystem="True" name="Mandator" datatype="Mandator" dataValueField="" dataTextField="" />
    <ParameterType id="472e4587-12a6-49cd-8063-5f6d315f9c3d" isSystem="False" name="Jahre" datatype="IntegerDDL" dataValueField="year_id" dataTextField="year_name">
      <query>select distinct cast(year(lastPing) as int) as year_id,
cast(year(lastPing) as nvarchar(64)) as year_name
from tblTasTestSessions inner join tblTasTests on tblTasTestSessions.test_id = tblTasTests.id
where (@mandator_id is null or tblTasTests.mandator_id = @mandator_id)
  and mode&lt;=1
  and testSessionState=3
  and DATEDIFF( MINUTE, lastPing, GETDATE() ) &gt; 1
  and not exists(select * from tblTasStatsTestSessions where tblTasStatsTestSessions.testsession_id=tblTasTestSessions.id)
  and not exists(select * from tblActionLog where action_id in (85,128) and effectedObject_id=tblTasTestSessions.id)
  and not exists(select * from tblActionLog where action_id in (85,128) and effectedObject_id=tblTasTestSessions.test_id and effectedObjectInt_id=tblTasTestSessions.user_id)
  and exists(select * from tblTasTestSessionQuestions where testSessionId = tblTasTestSessions.id and answeredCorrectly=1)
order by year(lastPing)</query>
      <Parameters>
        <Parameter id="a785aecc-668a-4609-9613-394bd4d708c2" isRequired="False" name="Mandant" contextName="Mandant" defaultValue="" renderHint="Undefined" disableParameter="DontDisable" />
      </Parameters>
    </ParameterType>
  </ParameterTypes>
</ReportsExport>