Modul:Studienprofil

Aus MAV
Wechseln zu: Navigation, Suche

Aufruf der Funktion

Bitte exakt nach folgendem Schema in der "Vorlage:MAV" aufrufen

{{#invoke:Studienprofil|combinedStudienprofiles|{{SUBPAGENAME}}}}

local p = {}

function p.getStudents(Beginn, Ende)
	
	local searchresult = ''
	searchresult = mw.smw.ask( '[[Kategorie:Ausbildung]][[Beginn::<' .. Ende .. ']][[Ende::>' .. Beginn .. ']][[Geographikum::Universität Wittenberg]]|?Beginn=Beginn|?Ende=Ende|limit=500' )

	if not searchresult then
		return 'Keine Einträge gefunden'
	end
	
	local out = '{| class="wikitable sortable"\n'
	out = out .. '! Name !! Beginn !! Ende\n'
	
	for _, row in ipairs(searchresult) do
	  out = out .. '|-\n'
  	  out = out .. '| ' .. row[1] .. '\n'
	  out = out .. '| ' .. (row.Beginn or '') .. '\n'
	  out = out .. '| ' .. (row.Ende or '') .. '\n'
	end
	out = out .. '|}\n'
	return out
end

function p.getPrintedDissertations(Beginn, Ende)
	
	local searchresult = ''
	searchresult = mw.smw.ask( '[[Kategorie:Disputation]][[DisputationDatumBeginn::<' .. Ende .. ']][[DisputationDatumEnde::>' .. Beginn .. ']]|?Druck=GedrucktIn|?DisputationTyp=Typ|?DisputationDatumBeginn=Datum|?VDTitel=Titel|?Schlagworte=Schlagworte|?Präses=Praeses|?Respondent=Respondent|limit=500' )

	if not searchresult then
		return 'Keine Einträge gefunden'
	end
	
	local out = '{| class="wikitable sortable"\n'
	out = out .. '! Gedruckt in !! Disputationstyp !! Ende !! Titel\n'
	
	for _, row in ipairs(searchresult) do
	  out = out .. '|-\n'
  	  out = out .. '| ' .. row.GedrucktIn .. '\n'
	  out = out .. '| ' .. (row.Typ or '') .. '\n'
	  out = out .. '| ' .. (row.Datum or '') .. '\n'
  	  out = out .. '| ' .. (row.Titel or '') .. '\n'
  	  out = out .. '| ' .. (row.Schlagworte or '') .. '\n'
  	  out = out .. '| ' .. (row.Praeses or '') .. '\n'
  	  out = out .. '| ' .. (row.Respondent or '') .. '\n'
	end
	out = out .. '|}\n'
	return out
end


function p.createSingleStudienprofil(Beginn, Ende)
	
	local returnstring = ''
	
	returnstring = returnstring .. "'''Mitstudenten: '''\n" .. p.getStudents(Beginn, Ende)
	returnstring = returnstring .. "'''Mitstudenten: '''\n" .. p.getStudents(Beginn, Ende)

	return returnstring
end

function p.combinedStudienprofiles(frame)

	local queryResult = ''
	local pagename = frame.args[1] 
	local returnvalue = ''
	
    queryResult = mw.smw.ask( '[[Kategorie:Ausbildung]][[Person::' .. pagename .. ']][[Geographikum::Universität Wittenberg]]|mainlabel=-|?Beginn|?Ende|sort=DatumSortiert|format=plainlist' )

    if queryResult == nil then
        return 'Keine Angaben zu einem Studium in Wittenberg gefunden.'
    end

    if type( queryResult ) == "table" then
        local Beginn = ''
        local Ende = ''
        for num, row in pairs( queryResult ) do
            for property, data in pairs( row ) do
                if property == 'Beginn' then
                	Beginn = data
                elseif property == 'Ende' then
                	Ende = data 
                end
            end
            returnvalue = returnvalue .. '=== Studium (von ' .. Beginn .. ' bis ' .. Ende .. ') ===\n' .. p.createSingleStudienprofil(Beginn, Ende)
		end
    end
	return returnvalue
end

return p