7
7
__author__ = "tna76874"
8
8
__credits__ = ["https://github.com/Swarthmore/extract-mbz" ]
9
9
__license__ = "GPL"
10
- __version__ = "0.1 "
10
+ __version__ = "0.3 "
11
11
__maintainer__ = "tna76874"
12
12
__email__ = "dev@hilberg.eu"
13
13
__status__ = "Prototype"
@@ -163,14 +163,18 @@ def extractmbz(self,zfile):
163
163
DF_tmp = pd .concat ([DF_tmp .reset_index (drop = True ),pd .DataFrame .from_dict (dict (DF_tmp ['assign' ]['activity' ]),orient = 'index' ).T .reset_index (drop = True )],axis = 1 ,sort = False )
164
164
DF_tmp .drop (columns = ['assign' ,'@id' ,'timemodified' ],inplace = True )
165
165
DF_assign = pd .concat ([DF_assign ,DF_tmp ])
166
-
166
+
167
167
# merge item informations
168
168
DF_items = pd .concat ([DF_assign ,DF_resource ])
169
169
DF_files = pd .merge (DF_files ,DF_items ,on = "contextid" )
170
170
DF_files = pd .merge (DF_files ,DF_things ,left_on = "contenthash" ,right_on = "filen" ,how = "outer" )
171
+
172
+ # Dataframes to work with
173
+ DF_feedback = DF_files [DF_files ['filearea' ]== 'download' ].rename (columns = {'@contextid' :'contextid' ,'@id' :'id1' })
171
174
DF_files = pd .merge (DF_files ,DF_user ,left_on = "userid" ,right_on = "id2" )
172
-
173
- #convert course files
175
+ DF_assign = DF_files [DF_files ['component' ].str .contains ('assign' )]
176
+
177
+ # convert course files
174
178
for i in DF_things [DF_things ['filen' ]== 'section.xml' ]['path' ]:
175
179
DF_resource = pdx .read_xml (i ).T .reset_index (drop = True )
176
180
try :
@@ -185,8 +189,7 @@ def extractmbz(self,zfile):
185
189
shutil .move (os .path .abspath (folderpath + '/' + DF_filescopy .loc [j ,'filen' ]),os .path .abspath (folderpath + '/' + DF_filescopy .loc [j ,'filen' ][:4 ] + '_' + DF_filescopy .loc [j ,'filename' ]))
186
190
except : pass
187
191
188
- #convert assignment files
189
- DF_assign = DF_files [DF_files ['component' ].str .contains ('assign' )]
192
+ # convert assignment files
190
193
for i in DF_assign .index :
191
194
try :
192
195
name = DF_assign .loc [i ,'lastname' ].replace (' ' ,'_' )+ '_' + DF_assign .loc [i ,'firstname' ]
@@ -198,7 +201,20 @@ def extractmbz(self,zfile):
198
201
shutil .copy (DF_assign .loc [i ,'path' ],folderpath )
199
202
shutil .move (os .path .abspath (folderpath + '/' + DF_assign .loc [i ,'filen' ]),os .path .abspath (folderpath + '/' + hashval + '_' + DF_assign .loc [i ,'filename' ]))
200
203
except : pass
201
-
204
+
205
+ # convert feedbacks
206
+ for i in DF_feedback .index :
207
+ try :
208
+ name = DF_feedback .loc [i ,'filename' ].split ("." )[0 ]
209
+ assignment = DF_feedback .loc [i ,'name' ]
210
+ hashval = DF_feedback .loc [i ,'contenthash' ][:5 ]
211
+ folderpath = os .path .join (os .path .abspath (self .exportdir ), 'feedback' , assignment , name )
212
+ if not os .path .exists (folderpath ):
213
+ os .makedirs (folderpath )
214
+ shutil .copy (DF_feedback .loc [i ,'path' ],folderpath )
215
+ shutil .move (os .path .abspath (folderpath + '/' + DF_feedback .loc [i ,'filen' ]),os .path .abspath (folderpath + '/' + hashval + '_' + DF_feedback .loc [i ,'filename' ]))
216
+ except : pass
217
+
202
218
# delete the extracted mbz files
203
219
shutil .rmtree (self .extractdir )
204
220
# zip all extracted files into one file
0 commit comments