33
44use Mooc \UI \Block ;
55use Opencast \LTI \OpencastLTI ;
6+ use Opencast \LTI \LtiLink ;
67use Opencast \LTI \LTIResourceLink ;
78use Opencast \Models \OCConfig ;
89
@@ -46,20 +47,36 @@ public function student_view()
4647
4748 $ config = OCConfig::getConfigForCourse ($ course_id );
4849
49- $ lti_launch_data = OpencastLTI::generate_lti_launch_data (
50- $ GLOBALS ['user ' ]->id ,
51- $ course_id ,
52- LTIResourceLink::generate_link ('series ' ,'view complete series for course ' )
53- //OpencastLTI::generate_tool('series', $this->connectedSeries[0]['series_id'])
54- );
50+ $ current_user_id = $ GLOBALS ['auth ' ]->auth ['uid ' ];
5551
56- $ lti_data = OpencastLTI:: sign_lti_data (
57- $ lti_launch_data ,
52+ $ lti_link = new LtiLink (
53+ OpencastLTI:: getSearchUrl ( $ course_id ) ,
5854 $ config ['lti_consumerkey ' ],
59- $ config ['lti_consumersecret ' ],
60- OpencastLTI::getSearchUrl ($ course_id )
55+ $ config ['lti_consumersecret ' ]
56+ );
57+
58+ if ($ GLOBALS ['perm ' ]->have_studip_perm ('tutor ' , $ course_id , $ current_user_id )) {
59+ $ role = 'Instructor ' ;
60+ } else if ($ GLOBALS ['perm ' ]->have_studip_perm ('autor ' , $ course_id , $ current_user_id )) {
61+ $ role = 'Learner ' ;
62+ }
63+
64+ $ lti_link ->setUser ($ current_user_id , $ role );
65+ $ lti_link ->setCourse ($ course_id );
66+ $ lti_link ->setResource (
67+ $ connectedSeries ,
68+ 'series ' ,
69+ 'view complete series for course '
6170 );
6271
72+ $ launch_data = $ lti_link ->getBasicLaunchData ();
73+ $ signature = $ lti_link ->getLaunchSignature ($ launch_data );
74+
75+ $ launch_data ['oauth_signature ' ] = $ signature ;
76+
77+ $ lti_data = json_encode ($ launch_data );
78+ $ lti_url = $ lti_link ->getLaunchURL ();
79+
6380 return array_merge ($ this ->getAttrArray (),
6481 array (
6582 'oc_present ' => $ oc_present ,
@@ -68,7 +85,7 @@ public function student_view()
6885 'useplayer ' => $ useplayer ,
6986 'url_isset ' => ($ url_opencast != '' ),
7087 'lti_data ' => json_encode ($ lti_data ),
71- 'search_url ' => OpencastLTI:: getSearchUrl ( $ course_id )
88+ 'search_url ' => $ lti_url
7289 )
7390 );
7491 }
0 commit comments